diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..a090e4c --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,22 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "vcluster", + "type": "go", + "request": "launch", + "mode": "test", + "program": "${workspaceFolder}/vclusterops" + }, + { + "name": "commands", + "type": "go", + "request": "launch", + "mode": "test", + "program": "${workspaceFolder}/commands" + } + ] +} diff --git a/commands/cmd_add_node.go b/commands/cmd_add_node.go index 98cb07e..d52af97 100644 --- a/commands/cmd_add_node.go +++ b/commands/cmd_add_node.go @@ -60,6 +60,8 @@ func makeCmdAddNode() *CmdAddNode { addNodeOptions.ConfigDirectory = newCmd.parser.String("config-directory", "", util.GetOptionalFlagMsg("Directory where "+vclusterops.ConfigFileName+" is located")) addNodeOptions.DataPrefix = newCmd.parser.String("data-path", "", util.GetOptionalFlagMsg("Path of data directory")) + addNodeOptions.ForceRemoval = newCmd.parser.Bool("force-removal", false, + util.GetOptionalFlagMsg("Force removal of existing directories before adding nodes")) addNodeOptions.SkipRebalanceShards = newCmd.parser.Bool("skip-rebalance-shards", false, util.GetOptionalFlagMsg("Skip the subcluster shards rebalancing")) diff --git a/vclusterops/add_node.go b/vclusterops/add_node.go index 17f7948..c0e54b4 100644 --- a/vclusterops/add_node.go +++ b/vclusterops/add_node.go @@ -36,6 +36,8 @@ type VAddNodeOptions struct { DepotSize *string // like 10G // Skip rebalance shards if true SkipRebalanceShards *bool + // Use force remove if true + ForceRemoval *bool // Names of the existing nodes in the cluster. // This options can be used to remove partially added nodes from catalog. @@ -56,6 +58,7 @@ func (o *VAddNodeOptions) SetDefaultValues() { o.SCName = new(string) o.SkipRebalanceShards = new(bool) o.DepotSize = new(string) + o.ForceRemoval = new(bool) } func (o *VAddNodeOptions) validateEonOptions() error { @@ -363,7 +366,7 @@ func (vcc *VClusterCommands) produceAddNodeInstructions(vdb *VCoordinationDataba // contains the hosts to add. newHostNodeMap := vdb.copyHostNodeMap(options.NewHosts) nmaPrepareDirectoriesOp, err := makeNMAPrepareDirectoriesOp(newHostNodeMap, - false /*force cleanup*/, false /*for db revive*/) + *options.ForceRemoval /*force cleanup*/, false /*for db revive*/) if err != nil { return instructions, err }