Skip to content

Commit

Permalink
Sync from server repo (6670d18834b)
Browse files Browse the repository at this point in the history
  • Loading branch information
roypaulin committed May 27, 2024
1 parent 9b9e623 commit 4d33ccd
Show file tree
Hide file tree
Showing 71 changed files with 2,471 additions and 560 deletions.
12 changes: 6 additions & 6 deletions commands/cluster_command_launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
const defaultLogPath = "/opt/vertica/log/vcluster.log"
const defaultExecutablePath = "/opt/vertica/bin/vcluster"

const CLIVersion = "1.2.0"
const CLIVersion = "2.0.0"
const vclusterLogPathEnv = "VCLUSTER_LOG_PATH"
const vclusterKeyFileEnv = "VCLUSTER_KEY_FILE"
const vclusterCertFileEnv = "VCLUSTER_CERT_FILE"
Expand Down Expand Up @@ -152,16 +152,16 @@ const (
configShowSubCmd = "show"
replicationSubCmd = "replication"
startReplicationSubCmd = "start"
listAllNodesSubCmd = "list_allnodes"
listAllNodesSubCmd = "list_all_nodes"
startDBSubCmd = "start_db"
dropDBSubCmd = "drop_db"
addSCSubCmd = "db_add_subcluster"
removeSCSubCmd = "db_remove_subcluster"
addSCSubCmd = "add_subcluster"
removeSCSubCmd = "remove_subcluster"
stopSCSubCmd = "stop_subcluster"
addNodeSubCmd = "db_add_node"
addNodeSubCmd = "add_node"
startSCSubCmd = "start_subcluster"
stopNodeCmd = "stop_node"
removeNodeSubCmd = "db_remove_node"
removeNodeSubCmd = "remove_node"
restartNodeSubCmd = "restart_node"
reIPSubCmd = "re_ip"
sandboxSubCmd = "sandbox_subcluster"
Expand Down
4 changes: 2 additions & 2 deletions commands/cmd_add_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ Omitting the option will skip this node trimming process.
Examples:
# Add a single host to the existing database with config file
vcluster db_add_node --db-name test_db --new-hosts 10.20.30.43 \
vcluster add_node --db-name test_db --new-hosts 10.20.30.43 \
--config /opt/vertica/config/vertica_cluster.yaml
# Add multiple hosts to the existing database with user input
vcluster db_add_node --db-name test_db --new-hosts 10.20.30.43,10.20.30.44 \
vcluster add_node --db-name test_db --new-hosts 10.20.30.43,10.20.30.44 \
--data-path /data --hosts 10.20.30.40 \
--node-names v_test_db_node0001,v_test_db_node0002
`,
Expand Down
16 changes: 9 additions & 7 deletions commands/cmd_add_subcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,22 @@ the --is-primary option.
Examples:
# Add a subcluster with config file
vcluster db_add_subcluster --subcluster sc1 \
vcluster add_subcluster --subcluster sc1 \
--config /opt/vertica/config/vertica_cluster.yaml \
--is-primary --control-set-size 1
# Add a subcluster with user input
vcluster db_add_subcluster --subcluster sc1 --db-name test_db \
vcluster add_subcluster --subcluster sc1 --db-name test_db \
--hosts 10.20.30.40,10.20.30.41,10.20.30.42 \
--is-primary --control-set-size -1
# Add a subcluster and new nodes in the subcluster with config file
vcluster db_add_subcluster --subcluster sc1 \
vcluster add_subcluster --subcluster sc1 \
--config /opt/vertica/config/vertica_cluster.yaml \
--is-primary --control-set-size 1 --new-hosts 10.20.30.43
# Add a subcluster new nodes in the subcluster with user input
vcluster db_add_subcluster --subcluster sc1 --db-name test_db \
vcluster add_subcluster --subcluster sc1 --db-name test_db \
--hosts 10.20.30.40,10.20.30.41,10.20.30.42 \
--is-primary --control-set-size -1 --new-hosts 10.20.30.43
`,
Expand Down Expand Up @@ -208,15 +208,17 @@ func (c *CmdAddSubcluster) Run(vcc vclusterops.ClusterCommands) error {
}

if len(options.NewHosts) > 0 {
fmt.Printf("Adding hosts %v to subcluster %s\n",
options.NewHosts, options.SCName)
vlog.DisplayColorInfo("Adding hosts %v to subcluster %s", options.NewHosts, options.SCName)

options.VAddNodeOptions.DatabaseOptions = c.addSubclusterOptions.DatabaseOptions
options.VAddNodeOptions.SCName = c.addSubclusterOptions.SCName

vdb, err := vcc.VAddNode(&options.VAddNodeOptions)
if err != nil {
vcc.LogError(err, "failed to add nodes into the new subcluster")
const msg = "Failed to add nodes into the new subcluster"
vcc.LogError(err, msg)
fmt.Printf("%s\nHint: subcluster %q is successfully created, you should use add_node to add nodes\n",
msg, options.VAddNodeOptions.SCName)
return err
}
// update db info in the config file
Expand Down
2 changes: 1 addition & 1 deletion commands/cmd_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type CmdBase struct {
argv []string
parser *pflag.FlagSet

// for some commands like list_allnodes, we want to allow the output to be written
// for some commands like list_all_nodes, we want to allow the output to be written
// to a file instead of being displayed in stdout. This is the file the output will
// be written to
output string
Expand Down
18 changes: 14 additions & 4 deletions commands/cmd_config_recover.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ func makeCmdConfigRecover() *cobra.Command {
`This subcommand is used to recover the content of the config file.
You must provide all the hosts that participate in the database.
db-name and password are required fields in case of running db. In case the password
is wrong or not provided, config info is recovered from the catalog editor.
For accurate sandbox information recovery, the database needs to be running.
If there is an existing file at the provided config file location, the recover function
will not create a new config file unless you explicitly specify --overwrite.
Expand All @@ -55,15 +58,15 @@ Examples:
# Recover the config file to the default location
vcluster manage_config recover --db-name test_db \
--hosts 10.20.30.41,10.20.30.42,10.20.30.43 \
--catalog-path /data --depot-path /data
--catalog-path /data --depot-path /data --password ""
# Recover the config file to /tmp/vertica_cluster.yaml
vcluster manage_config recover --db-name test_db \
--hosts 10.20.30.41,10.20.30.42,10.20.30.43 \
--catalog-path /data --depot-path /data \
--config /tmp/vertica_cluster.yaml
--config /tmp/vertica_cluster.yaml --password ""
`,
[]string{dbNameFlag, hostsFlag, catalogPathFlag, depotPathFlag, ipv6Flag, configFlag},
[]string{dbNameFlag, hostsFlag, catalogPathFlag, depotPathFlag, ipv6Flag, configFlag, passwordFlag},
)

// require db-name, hosts, catalog-path, and data-path
Expand All @@ -83,6 +86,12 @@ func (c *CmdConfigRecover) setLocalFlags(cmd *cobra.Command) {
false,
"overwrite the existing config file",
)
cmd.Flags().BoolVar(
&c.recoverConfigOptions.AfterRevive,
"after-revive",
false,
"whether recover config file right after reviving a database",
)
}

func (c *CmdConfigRecover) Parse(inputArgv []string, logger vlog.Printer) error {
Expand All @@ -100,7 +109,7 @@ func (c *CmdConfigRecover) validateParse(logger vlog.Printer) error {
return err
}

return nil
return c.setDBPassword(&c.recoverConfigOptions.DatabaseOptions)
}

func (c *CmdConfigRecover) Run(vcc vclusterops.ClusterCommands) error {
Expand All @@ -110,6 +119,7 @@ func (c *CmdConfigRecover) Run(vcc vclusterops.ClusterCommands) error {
return err
}
// write db info to vcluster config file
vdb.FirstStartAfterRevive = c.recoverConfigOptions.AfterRevive
err = writeConfig(&vdb)
if err != nil {
return fmt.Errorf("fail to write config file, details: %s", err)
Expand Down
4 changes: 3 additions & 1 deletion commands/cmd_create_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
package commands

import (
"fmt"

"github.com/spf13/cobra"
"github.com/vertica/vcluster/vclusterops"
"github.com/vertica/vcluster/vclusterops/util"
Expand Down Expand Up @@ -268,7 +270,7 @@ func (c *CmdCreateDB) Run(vcc vclusterops.ClusterCommands) error {
// write db info to vcluster config file
err := writeConfig(&vdb)
if err != nil {
vcc.PrintWarning("fail to write config file, details: %s", err)
fmt.Printf("Warning: Fail to write config file, details: %s\n", err)
}
vcc.PrintInfo("Created a database with name [%s]", vdb.Name)
return nil
Expand Down
4 changes: 2 additions & 2 deletions commands/cmd_list_all_nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ whether they are up or down.
To provide its status, each host must run the spread daemon.
You must provide the --hosts option one or more hosts as a comma-separated
list. list_allnodes returns the first response it receives from any host.
list. list_all_nodes returns the first response it receives from any host.
The --db-name and --catalog-path options are required only when vcluster cannot
obtain node information from a running database and the config file is not
Expand All @@ -59,7 +59,7 @@ provided.
Examples:
# List the status of nodes with config file where password authentication is
# used to access the database
vcluster list_allnodes --password testpassword \
vcluster list_all_nodes --password testpassword \
--config /opt/vertica/config/vertica_cluster.yaml
`,
[]string{dbNameFlag, hostsFlag, passwordFlag, ipv6Flag, catalogPathFlag, configFlag, outputFileFlag},
Expand Down
2 changes: 1 addition & 1 deletion commands/cmd_re_ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ The database must be down to change the IP addresses with re_ip. If
the database is up, you must run restart_node after re_ip for the
IP changes to take effect.
The file specified by the re_ip-file option must be a JSON file in the
The file specified by the re-ip-file option must be a JSON file in the
following format:
[
{"from_address": "10.20.30.40", "to_address": "10.20.30.41"},
Expand Down
4 changes: 2 additions & 2 deletions commands/cmd_remove_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ You cannot remove nodes from a sandboxed subcluster in an Eon Mode database.
Examples:
# Remove multiple nodes from the existing database with config file
vcluster db_remove_node --db-name test_db \
vcluster remove_node --db-name test_db \
--remove 10.20.30.40,10.20.30.42 \
--config /opt/vertica/config/vertica_cluster.yaml
# Remove a single node from the existing database with user input
vcluster db_remove_node --db-name test_db --remove 10.20.30.42 \
vcluster remove_node --db-name test_db --remove 10.20.30.42 \
--hosts 10.20.30.40 --data-path /data
`,
[]string{dbNameFlag, configFlag, hostsFlag, ipv6Flag, catalogPathFlag, dataPathFlag, depotPathFlag, passwordFlag},
Expand Down
8 changes: 4 additions & 4 deletions commands/cmd_remove_subcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ subcluster.
Examples:
# Remove a subcluster with config file
vcluster db_remove_subcluster --subcluster sc1 \
vcluster remove_subcluster --subcluster sc1 \
--config /opt/vertica/config/vertica_cluster.yaml
# Remove a subcluster with user input
vcluster db_remove_subcluster --db-name test_db \
vcluster remove_subcluster --db-name test_db \
--hosts 10.20.30.40,10.20.30.41,10.20.30.42 --subcluster sc1 \
--data-path /data --depot-path /data
`,
Expand All @@ -77,7 +77,7 @@ Examples:
// setLocalFlags will set the local flags the command has
func (c *CmdRemoveSubcluster) setLocalFlags(cmd *cobra.Command) {
cmd.Flags().StringVar(
&c.removeScOptions.SubclusterToRemove,
&c.removeScOptions.SCName,
subclusterFlag,
"",
"Name of subcluster to be removed",
Expand Down Expand Up @@ -139,7 +139,7 @@ func (c *CmdRemoveSubcluster) Run(vcc vclusterops.ClusterCommands) error {
vcc.PrintWarning("fail to write config file, details: %s", err)
}
vcc.PrintInfo("Successfully removed subcluster %s from database %s",
options.SubclusterToRemove, options.DBName)
options.SCName, options.DBName)

return nil
}
Expand Down
1 change: 1 addition & 0 deletions commands/cmd_revive_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ func (c *CmdReviveDB) Run(vcc vclusterops.ClusterCommands) error {
}

// write db info to vcluster config file
vdb.FirstStartAfterRevive = true
err = writeConfig(vdb)
if err != nil {
vcc.PrintWarning("fail to write config file, details: %s", err)
Expand Down
6 changes: 6 additions & 0 deletions commands/cmd_scrutinize.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ func (c *CmdScrutinize) setLocalFlags(cmd *cobra.Command) {
"Include information describing all UDX functions, "+
"which can be expensive to gather on Eon",
)
cmd.Flags().BoolVar(
&c.sOptions.SkipCollectLibs,
"skip-collect-libraries",
false,
"Skip gathering linked and catalog shared libraries",
)
}

func (c *CmdScrutinize) Parse(inputArgv []string, logger vlog.Printer) error {
Expand Down
15 changes: 12 additions & 3 deletions commands/cmd_start_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ type CmdStartDB struct {
CmdBase
startDBOptions *vclusterops.VStartDatabaseOptions

Force bool // force cleanup to start the database
Force bool // Force cleanup to start the database
AllowFallbackKeygen bool // Generate spread encryption key from Vertica. Use under support guidance only
IgnoreClusterLease bool // ignore the cluster lease in communal storage
IgnoreClusterLease bool // Ignore the cluster lease in communal storage
Unsafe bool // Start database unsafely, skipping recovery.
Fast bool // Attempt fast startup database
}
Expand Down Expand Up @@ -88,6 +88,8 @@ func (c *CmdStartDB) setLocalFlags(cmd *cobra.Command) {
util.DefaultTimeoutSeconds,
"The timeout (in seconds) to wait for polling node state operation",
)
// Update description of hosts flag locally for a detailed hint
cmd.Flags().Lookup(hostsFlag).Usage = "Comma-separated list of hosts in database. This is used to start sandboxed hosts"
}

// setHiddenFlags will set the hidden flags the command has.
Expand Down Expand Up @@ -165,6 +167,12 @@ func (c *CmdStartDB) Run(vcc vclusterops.ClusterCommands) error {
vcc.V(1).Info("Called method Run()")

options := c.startDBOptions
dbConfig, readConfigErr := readConfig()
if readConfigErr == nil {
options.FirstStartAfterRevive = dbConfig.FirstStartAfterRevive
} else {
vcc.PrintWarning("fail to read config file", "error", readConfigErr)
}

vdb, err := vcc.VStartDatabase(options)
if err != nil {
Expand All @@ -175,8 +183,9 @@ func (c *CmdStartDB) Run(vcc vclusterops.ClusterCommands) error {
vcc.PrintInfo("Successfully start the database %s", options.DBName)

// for Eon database, update config file to fill nodes' subcluster information
if options.IsEon {
if readConfigErr == nil && options.IsEon {
// write db info to vcluster config file
vdb.FirstStartAfterRevive = false
err := writeConfig(vdb)
if err != nil {
vcc.PrintWarning("fail to update config file, details: %s", err)
Expand Down
2 changes: 1 addition & 1 deletion commands/cmd_start_replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (c *CmdStartReplication) setLocalFlags(cmd *cobra.Command) {
"The target database that we will replicate to",
)
cmd.Flags().StringVar(
&c.startRepOptions.Sandbox,
&c.startRepOptions.SandboxName,
sandboxFlag,
"",
"The source sandbox that we will replicate from",
Expand Down
4 changes: 2 additions & 2 deletions commands/cmd_start_subcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Examples:
// setLocalFlags will set the local flags the command has
func (c *CmdStartSubcluster) setLocalFlags(cmd *cobra.Command) {
cmd.Flags().StringVar(
&c.startScOptions.SubclusterToStart,
&c.startScOptions.SCName,
subclusterFlag,
"",
"Name of subcluster to start",
Expand Down Expand Up @@ -131,7 +131,7 @@ func (c *CmdStartSubcluster) Run(vcc vclusterops.ClusterCommands) error {
}

vcc.PrintInfo("Successfully started subcluster %s for database %s",
options.SubclusterToStart, options.DBName)
options.SCName, options.DBName)

return nil
}
Expand Down
6 changes: 3 additions & 3 deletions commands/cmd_stop_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (c *CmdStopDB) setLocalFlags(cmd *cobra.Command) {
" Set this to 0 for Eon database, if you want to forcibly stop the database."),
)
cmd.Flags().StringVar(
&c.stopDBOptions.Sandbox,
&c.stopDBOptions.SandboxName,
sandboxFlag,
"",
"Name of the sandbox to stop",
Expand Down Expand Up @@ -152,8 +152,8 @@ func (c *CmdStopDB) Run(vcc vclusterops.ClusterCommands) error {
return err
}
msg := fmt.Sprintf("Stopped a database with name %s", options.DBName)
if options.Sandbox != "" {
sandboxMsg := fmt.Sprintf(" on sandbox %s", options.Sandbox)
if options.SandboxName != "" {
sandboxMsg := fmt.Sprintf(" on sandbox %s", options.SandboxName)
vcc.PrintInfo(msg + sandboxMsg)
return nil
}
Expand Down
Loading

0 comments on commit 4d33ccd

Please sign in to comment.