Skip to content

Commit

Permalink
Sync from server repo (a3da6d0cb2)
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Spilchen committed Sep 16, 2023
1 parent 871e603 commit 5d77c8b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 25 deletions.
22 changes: 0 additions & 22 deletions .vscode/launch.json

This file was deleted.

38 changes: 35 additions & 3 deletions vclusterops/remove_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,12 +286,13 @@ func produceRemoveNodeInstructions(vdb *VCoordinationDatabase, options *VRemoveN
instructions = append(instructions, &httpsRebalanceClusterOp)
}

httpsSpreadRemoveNodeOp, err := makeHTTPSSpreadRemoveNodeOp(options.HostsToRemove, initiatorHost, usePassword,
username, password, vdb.HostNodeMap)
// only call HTTPSSpreadRemoveNodeOp when there are secondary nodes to remove
err = produceSpreadRemoveNodeOp(&instructions, options.HostsToRemove,
usePassword, username, password,
initiatorHost, vdb.HostNodeMap)
if err != nil {
return instructions, err
}
instructions = append(instructions, &httpsSpreadRemoveNodeOp)

err = produceDropNodeOps(&instructions, options.HostsToRemove, initiatorHost,
usePassword, username, password, vdb.HostNodeMap, vdb.IsEon)
Expand Down Expand Up @@ -371,6 +372,37 @@ func produceDropNodeOps(instructions *[]ClusterOp, targetHosts, hosts []string,
return nil
}

// produceSpreadRemoveNodeOp calls HTTPSSpreadRemoveNodeOp
// when there is at least one secondary node to remove
func produceSpreadRemoveNodeOp(instructions *[]ClusterOp, hostsToRemove []string,
useHTTPPassword bool, userName string, httpsPassword *string,
initiatorHost []string, hostNodeMap vHostNodeMap) error {
// find secondary nodes from HostsToRemove
hasSecondaryNodesToRemove := false
for _, h := range hostsToRemove {
vnode, ok := hostNodeMap[h]
if !ok {
return fmt.Errorf("cannot find host %s from vdb.HostNodeMap", h)
}
if !vnode.IsPrimary {
hasSecondaryNodesToRemove = true
break
}
}

// only call HTTPSSpreadRemoveNodeOp when there are secondary nodes to remove
if hasSecondaryNodesToRemove {
httpsSpreadRemoveNodeOp, err := makeHTTPSSpreadRemoveNodeOp(hostsToRemove, initiatorHost,
useHTTPPassword, userName, httpsPassword, hostNodeMap)
if err != nil {
return err
}
*instructions = append(*instructions, &httpsSpreadRemoveNodeOp)
}

return nil
}

// setInitiator sets the initiator as the first primary up node that is not
// in the list of hosts to remove.
func (o *VRemoveNodeOptions) setInitiator(primaryUpNodes []string) error {
Expand Down

0 comments on commit 5d77c8b

Please sign in to comment.