Skip to content

Commit

Permalink
Sync from server repo (6e855f0c1f4)
Browse files Browse the repository at this point in the history
  • Loading branch information
cchen-vertica committed Jun 24, 2024
1 parent 937a09c commit d83e09f
Show file tree
Hide file tree
Showing 39 changed files with 782 additions and 518 deletions.
41 changes: 16 additions & 25 deletions commands/cmd_add_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,8 @@ func makeCmdAddNode() *cobra.Command {
cmd := makeBasicCobraCmd(
newCmd,
addNodeSubCmd,
"Add host(s) to an existing database",
`This command adds one or more hosts to an existing database.
You must provide the --new-hosts option followed by one or more hosts to add as
a comma-separated list.
You cannot add hosts to a sandbox subcluster in an Eon Mode database.
Use the --node-names option to address issues resulting from a failed node
addition attempt. It's crucial to include all expected nodes in the catalog
when using this option. This command removes any surplus nodes from the
catalog, provided they are down, before commencing the node addition process.
Omitting the option will skip this node trimming process.
"Adds host(s) to a database",
`Adds one or more user-specified hosts as nodes to an existing database. You cannot add nodes to a sandboxed subcluster.
Examples:
# Add a single host to the existing database with config file
Expand Down Expand Up @@ -90,44 +79,46 @@ func (c *CmdAddNode) setLocalFlags(cmd *cobra.Command) {
&c.addNodeOptions.NewHosts,
addNodeFlag,
[]string{},
"Comma-separated list of host(s) to add to the database",
"A comma-separated list of hosts to add to the database.",
)
cmd.Flags().BoolVar(
&c.addNodeOptions.ForceRemoval,
"force-removal",
false,
"Whether to force clean-up of existing directories before adding host(s)",
"Whether to delete any existing database directories in the new hosts before attempting to add them.",
)
cmd.Flags().BoolVar(
c.addNodeOptions.SkipRebalanceShards,
"skip-rebalance-shards",
false,
util.GetEonFlagMsg("Skip the subcluster shards rebalancing"),
util.GetEonFlagMsg("Whether to skip shard rebalancing."),
)
cmd.Flags().StringVar(
&c.addNodeOptions.SCName,
subclusterFlag,
"",
util.GetEonFlagMsg("The Name of subcluster"+
" to which the host(s) must be added. If empty default subcluster is considered"),
util.GetEonFlagMsg("The name of the subcluster to which the host(s) should be added."+
"This string must conform to the format used for database names."),
)
cmd.Flags().StringVar(
&c.addNodeOptions.DepotSize,
"depot-size",
"",
util.GetEonFlagMsg("Size of depot"),
util.GetEonFlagMsg("Size of depot in one of the following formats:\n"+
"integer{K|M|G|T}, where K is kilobytes, M is megabytes, G is gigabytes, and T is terabytes.\n"+
"integer%, which expresses the depot size as a percentage of the total disk size."),
)
cmd.Flags().StringVar(
&c.nodeNameListStr,
"node-names",
"",
"Comma-separated list of node names that exist in the cluster",
"[Use only with support guidance] A comma-separated list of node names that exist in the cluster.",
)
cmd.Flags().IntVar(
&c.addNodeOptions.TimeOut,
"add-node-timeout",
util.GetEnvInt("NODE_STATE_POLLING_TIMEOUT", util.DefaultTimeoutSeconds),
"The timeout to wait for the nodes to add",
"The time, in seconds, to wait for the specified nodes to be added.",
)
}

Expand Down Expand Up @@ -177,7 +168,7 @@ func (c *CmdAddNode) parseNewHostList() error {
if err != nil {
// the err from util.ParseHostList will be "must specify a host or host list"
// we overwrite the error here to provide more details
return fmt.Errorf("must specify at least one host to add")
return fmt.Errorf("you must specify at least one host")
}
}
return nil
Expand All @@ -188,7 +179,7 @@ func (c *CmdAddNode) parseNodeNameList() error {
if c.parser.Changed("node-names") {
if c.nodeNameListStr == "" {
return fmt.Errorf("when --node-names is specified, "+
"must provide all existing node names in %q", c.addNodeOptions.DBName)
"you must provide all existing nodes in %q", c.addNodeOptions.DBName)
}

c.addNodeOptions.ExpectedNodeNames = strings.Split(c.nodeNameListStr, ",")
Expand All @@ -204,14 +195,14 @@ func (c *CmdAddNode) Run(vcc vclusterops.ClusterCommands) error {

vdb, err := vcc.VAddNode(options)
if err != nil {
vcc.LogError(err, "fail to add node")
vcc.LogError(err, "failed to add node")
return err
}

// write db info to vcluster config file
err = writeConfig(&vdb, true /*forceOverwrite*/)
if err != nil {
vcc.DisplayWarning("fail to write config file, details: %s", err)
vcc.DisplayWarning("Failed to write config file: %s", err)
}

vcc.DisplayInfo("Successfully added nodes %v to database %s", c.addNodeOptions.NewHosts, options.DBName)
Expand Down
29 changes: 13 additions & 16 deletions commands/cmd_add_subcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,7 @@ func makeCmdAddSubcluster() *cobra.Command {
newCmd,
addSCSubCmd,
"Add a subcluster",
`This command adds a new subcluster to an existing Eon Mode database.
You must provide a subcluster name with the --subcluster option.
By default, the new subcluster is secondary. To add a primary subcluster, use
the --is-primary option.
`This command adds a new subcluster to an Eon Mode database.
Examples:
# Add a subcluster with config file
Expand Down Expand Up @@ -101,43 +96,45 @@ func (c *CmdAddSubcluster) setLocalFlags(cmd *cobra.Command) {
&c.addSubclusterOptions.SCName,
subclusterFlag,
"",
"The name of the new subcluster",
"The name of the new subcluster. This string must conform to the format used for database names.",
)
cmd.Flags().BoolVar(
&c.addSubclusterOptions.IsPrimary,
"is-primary",
false,
"The new subcluster will be a primary subcluster",
"Whether the new subcluster should be a primary subcluster. If this option is omitted, new subclusters are secondary.",
)
cmd.Flags().IntVar(
&c.addSubclusterOptions.ControlSetSize,
"control-set-size",
vclusterops.ControlSetSizeDefaultValue,
"The number of nodes that will run spread within the subcluster",
"The number of control nodes in the subcluster (default: -1, all nodes in the subcluster are control nodes).",
)
cmd.Flags().StringSliceVar(
&c.addSubclusterOptions.NewHosts,
addNodeFlag,
[]string{},
"Comma-separated list of host(s) to add to the new subcluster",
"A comma-separated list of hosts or IP addresses to add to the subcluster.",
)
cmd.Flags().BoolVar(
&c.addSubclusterOptions.ForceRemoval,
"force-removal",
false,
"Whether to force clean-up of existing directories before adding host(s)",
"Whether to delete any existing database directories in the new hosts before attempting to add them.",
)
cmd.Flags().BoolVar(
c.addSubclusterOptions.SkipRebalanceShards,
"skip-rebalance-shards",
false,
util.GetEonFlagMsg("Skip the subcluster shards rebalancing"),
util.GetEonFlagMsg("Whether to skip shard rebalancing."),
)
cmd.Flags().StringVar(
&c.addSubclusterOptions.DepotSize,
"depot-size",
"",
util.GetEonFlagMsg("Size of depot"),
util.GetEonFlagMsg("Size of depot in one of the following formats:\n"+
"integer{K|M|G|T}, where K is kilobytes, M is megabytes, G is gigabytes, and T is terabytes.\n"+
"integer%, which expresses the depot size as a percentage of the total disk size.\n"),
)
}

Expand Down Expand Up @@ -215,15 +212,15 @@ func (c *CmdAddSubcluster) Run(vcc vclusterops.ClusterCommands) error {

vdb, err := vcc.VAddNode(&options.VAddNodeOptions)
if err != nil {
const msg = "Fail to add nodes into the new subcluster"
vcc.DisplayError("%s\nHint: subcluster %q is successfully created, you should use add_node to add nodes\n",
const msg = "Failed to add nodes to the new subcluster"
vcc.DisplayError("%s\nHint: The subcluster %q was successfully created; use add_node to add the nodes.\n",
msg, options.VAddNodeOptions.SCName)
return err
}
// update db info in the config file
err = writeConfig(&vdb, true /*forceOverwrite*/)
if err != nil {
vcc.DisplayWarning("fail to write config file, details: %s", err)
vcc.DisplayWarning("Failed to write config file, details: %s", err)
}
}

Expand Down
Loading

0 comments on commit d83e09f

Please sign in to comment.