Skip to content

Commit

Permalink
Sync from server repo (a3a61ad6bba)
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Spilchen committed Apr 15, 2024
1 parent 969c321 commit 5b41e6f
Show file tree
Hide file tree
Showing 56 changed files with 473 additions and 659 deletions.
14 changes: 7 additions & 7 deletions commands/cluster_command_launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func Execute() {
func initVcc(cmd *cobra.Command) vclusterops.VClusterCommands {
// setup logs
logger := vlog.Printer{ForCli: true}
logger.SetupOrDie(*dbOptions.LogPath)
logger.SetupOrDie(dbOptions.LogPath)

vcc := vclusterops.VClusterCommands{
VClusterCommandsLogger: vclusterops.VClusterCommandsLogger{
Expand All @@ -230,25 +230,25 @@ func initVcc(cmd *cobra.Command) vclusterops.VClusterCommands {
func setDBOptionsUsingViper(flag string) error {
switch flag {
case dbNameFlag:
*dbOptions.DBName = viper.GetString(dbNameKey)
dbOptions.DBName = viper.GetString(dbNameKey)
case hostsFlag:
dbOptions.RawHosts = viper.GetStringSlice(hostsKey)
case catalogPathFlag:
*dbOptions.CatalogPrefix = viper.GetString(catalogPathKey)
dbOptions.CatalogPrefix = viper.GetString(catalogPathKey)
case depotPathFlag:
*dbOptions.DepotPrefix = viper.GetString(depotPathKey)
dbOptions.DepotPrefix = viper.GetString(depotPathKey)
case dataPathFlag:
*dbOptions.DataPrefix = viper.GetString(dataPathKey)
dbOptions.DataPrefix = viper.GetString(dataPathKey)
case communalStorageLocationFlag:
*dbOptions.CommunalStorageLocation = viper.GetString(communalStorageLocationKey)
dbOptions.CommunalStorageLocation = viper.GetString(communalStorageLocationKey)
case ipv6Flag:
dbOptions.IPv6 = viper.GetBool(ipv6Key)
case eonModeFlag:
dbOptions.IsEon = viper.GetBool(eonModeKey)
case configParamFlag:
dbOptions.ConfigurationParameters = viper.GetStringMapString(configParamKey)
case logPathFlag:
*dbOptions.LogPath = viper.GetString(logPathKey)
dbOptions.LogPath = viper.GetString(logPathKey)
case keyFileFlag:
globals.keyFile = viper.GetString(keyFileKey)
case certFileFlag:
Expand Down
10 changes: 5 additions & 5 deletions commands/cmd_add_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (c *CmdAddNode) setLocalFlags(cmd *cobra.Command) {
"Comma-separated list of host(s) to add to the database",
)
cmd.Flags().BoolVar(
c.addNodeOptions.ForceRemoval,
&c.addNodeOptions.ForceRemoval,
"force-removal",
false,
"Whether to force clean-up of existing directories before adding host(s)",
Expand All @@ -105,14 +105,14 @@ func (c *CmdAddNode) setLocalFlags(cmd *cobra.Command) {
util.GetEonFlagMsg("Skip the subcluster shards rebalancing"),
)
cmd.Flags().StringVar(
c.addNodeOptions.SCName,
&c.addNodeOptions.SCName,
subclusterFlag,
"",
util.GetEonFlagMsg("The Name of subcluster"+
" to which the host(s) must be added. If empty default subcluster is considered"),
)
cmd.Flags().StringVar(
c.addNodeOptions.DepotSize,
&c.addNodeOptions.DepotSize,
"depot-size",
"",
util.GetEonFlagMsg("Size of depot"),
Expand Down Expand Up @@ -179,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)
"must provide all existing node names in %q", c.addNodeOptions.DBName)
}

c.addNodeOptions.ExpectedNodeNames = strings.Split(c.nodeNameListStr, ",")
Expand All @@ -204,7 +204,7 @@ func (c *CmdAddNode) Run(vcc vclusterops.ClusterCommands) error {
vcc.PrintWarning("fail to write config file, details: %s", err)
}

vcc.PrintInfo("Added nodes %v to database %s", c.addNodeOptions.NewHosts, *options.DBName)
vcc.PrintInfo("Added nodes %v to database %s", c.addNodeOptions.NewHosts, options.DBName)
return nil
}

Expand Down
18 changes: 9 additions & 9 deletions commands/cmd_add_subcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,19 @@ Examples:
// setLocalFlags will set the local flags the command has
func (c *CmdAddSubcluster) setLocalFlags(cmd *cobra.Command) {
cmd.Flags().StringVar(
c.addSubclusterOptions.SCName,
&c.addSubclusterOptions.SCName,
subclusterFlag,
"",
"The name of the new subcluster",
)
cmd.Flags().BoolVar(
c.addSubclusterOptions.IsPrimary,
&c.addSubclusterOptions.IsPrimary,
"is-primary",
false,
"The new subcluster will be a primary subcluster",
)
cmd.Flags().IntVar(
c.addSubclusterOptions.ControlSetSize,
&c.addSubclusterOptions.ControlSetSize,
"control-set-size",
vclusterops.ControlSetSizeDefaultValue,
"The number of nodes that will run spread within the subcluster",
Expand All @@ -124,7 +124,7 @@ func (c *CmdAddSubcluster) setLocalFlags(cmd *cobra.Command) {
"Comma-separated list of host(s) to add to the new subcluster",
)
cmd.Flags().BoolVar(
c.addSubclusterOptions.ForceRemoval,
&c.addSubclusterOptions.ForceRemoval,
"force-removal",
false,
"Whether to force clean-up of existing directories before adding host(s)",
Expand All @@ -136,7 +136,7 @@ func (c *CmdAddSubcluster) setLocalFlags(cmd *cobra.Command) {
util.GetEonFlagMsg("Skip the subcluster shards rebalancing"),
)
cmd.Flags().StringVar(
c.addSubclusterOptions.DepotSize,
&c.addSubclusterOptions.DepotSize,
"depot-size",
"",
util.GetEonFlagMsg("Size of depot"),
Expand All @@ -153,7 +153,7 @@ func (c *CmdAddSubcluster) setHiddenFlags(cmd *cobra.Command) {
"",
)
cmd.Flags().StringVar(
c.addSubclusterOptions.CloneSC,
&c.addSubclusterOptions.CloneSC,
"like",
"",
"",
Expand Down Expand Up @@ -209,7 +209,7 @@ 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)
options.NewHosts, options.SCName)

options.VAddNodeOptions.DatabaseOptions = c.addSubclusterOptions.DatabaseOptions
options.VAddNodeOptions.SCName = c.addSubclusterOptions.SCName
Expand All @@ -228,9 +228,9 @@ func (c *CmdAddSubcluster) Run(vcc vclusterops.ClusterCommands) error {

if len(options.NewHosts) > 0 {
vcc.PrintInfo("Added subcluster %s with nodes %v to database %s",
*options.SCName, options.NewHosts, *options.DBName)
options.SCName, options.NewHosts, options.DBName)
} else {
vcc.PrintInfo("Added subcluster %s to database %s", *options.SCName, *options.DBName)
vcc.PrintInfo("Added subcluster %s to database %s", options.SCName, options.DBName)
}
return nil
}
Expand Down
14 changes: 7 additions & 7 deletions commands/cmd_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (c *CmdBase) setCommonFlags(cmd *cobra.Command, flags []string) {
}
// log-path is a flag that all the subcommands need
cmd.Flags().StringVarP(
dbOptions.LogPath,
&dbOptions.LogPath,
logPathFlag,
"l",
logPath,
Expand Down Expand Up @@ -122,7 +122,7 @@ func (c *CmdBase) setCommonFlags(cmd *cobra.Command, flags []string) {
}
if util.StringInArray(dbUserFlag, flags) {
cmd.Flags().StringVar(
dbOptions.UserName,
&dbOptions.UserName,
dbUserFlag,
"",
"The username for connecting to the database",
Expand All @@ -135,7 +135,7 @@ func (c *CmdBase) setCommonFlags(cmd *cobra.Command, flags []string) {
func setConfigFlags(cmd *cobra.Command, flags []string) {
if util.StringInArray(dbNameFlag, flags) {
cmd.Flags().StringVarP(
dbOptions.DBName,
&dbOptions.DBName,
dbNameFlag,
"d",
"",
Expand All @@ -159,30 +159,30 @@ func setConfigFlags(cmd *cobra.Command, flags []string) {
}
if util.StringInArray(catalogPathFlag, flags) {
cmd.Flags().StringVar(
dbOptions.CatalogPrefix,
&dbOptions.CatalogPrefix,
catalogPathFlag,
"",
"Path of catalog directory")
markFlagsDirName(cmd, []string{catalogPathFlag})
}
if util.StringInArray(dataPathFlag, flags) {
cmd.Flags().StringVar(
dbOptions.DataPrefix,
&dbOptions.DataPrefix,
dataPathFlag,
"",
"Path of data directory")
markFlagsDirName(cmd, []string{dataPathFlag})
}
if util.StringInArray(communalStorageLocationFlag, flags) {
cmd.Flags().StringVar(
dbOptions.CommunalStorageLocation,
&dbOptions.CommunalStorageLocation,
communalStorageLocationFlag,
"",
util.GetEonFlagMsg("Location of communal storage"))
}
if util.StringInArray(depotPathFlag, flags) {
cmd.Flags().StringVar(
dbOptions.DepotPrefix,
&dbOptions.DepotPrefix,
depotPathFlag,
"",
util.GetEonFlagMsg("Path to depot directory"))
Expand Down
34 changes: 17 additions & 17 deletions commands/cmd_create_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,92 +121,92 @@ Examples:
// setLocalFlags will set the local flags the command has
func (c *CmdCreateDB) setLocalFlags(cmd *cobra.Command) {
cmd.Flags().StringVar(
c.createDBOptions.LicensePathOnNode,
&c.createDBOptions.LicensePathOnNode,
"license",
"",
"Database license",
)
cmd.Flags().StringVar(
c.createDBOptions.Policy,
&c.createDBOptions.Policy,
"policy",
util.DefaultRestartPolicy,
"Restart policy of the database",
)
cmd.Flags().StringVar(
c.createDBOptions.SQLFile,
&c.createDBOptions.SQLFile,
"sql",
"",
"SQL file to run (as dbadmin) immediately on database creation",
)
markFlagsFileName(cmd, map[string][]string{"sql": {"sql"}})
cmd.Flags().IntVar(
c.createDBOptions.ShardCount,
&c.createDBOptions.ShardCount,
"shard-count",
0,
util.GetEonFlagMsg("Number of shards in the database"),
)
cmd.Flags().StringVar(
c.createDBOptions.DepotSize,
&c.createDBOptions.DepotSize,
"depot-size",
"",
util.GetEonFlagMsg("Size of depot"),
)
cmd.Flags().BoolVar(
c.createDBOptions.GetAwsCredentialsFromEnv,
&c.createDBOptions.GetAwsCredentialsFromEnv,
"get-aws-credentials-from-env-vars",
false,
util.GetEonFlagMsg("Read AWS credentials from environment variables"),
)
cmd.Flags().BoolVar(
c.createDBOptions.P2p,
&c.createDBOptions.P2p,
"point-to-point",
true,
"Configure Spread to use point-to-point communication between all Vertica nodes",
)
cmd.Flags().BoolVar(
c.createDBOptions.Broadcast,
&c.createDBOptions.Broadcast,
"broadcast",
false,
"Configure Spread to use UDP broadcast traffic between nodes on the same subnet",
)
cmd.Flags().IntVar(
c.createDBOptions.LargeCluster,
&c.createDBOptions.LargeCluster,
"large-cluster",
-1,
"Enables a large cluster layout",
)
cmd.Flags().BoolVar(
c.createDBOptions.SpreadLogging,
&c.createDBOptions.SpreadLogging,
"spread-logging",
false,
"Whether enable spread logging",
)
cmd.Flags().IntVar(
c.createDBOptions.SpreadLoggingLevel,
&c.createDBOptions.SpreadLoggingLevel,
"spread-logging-level",
-1,
"Spread logging level",
)
cmd.Flags().BoolVar(
c.createDBOptions.ForceCleanupOnFailure,
&c.createDBOptions.ForceCleanupOnFailure,
"force-cleanup-on-failure",
false,
"Force removal of existing directories on failure of command",
)
cmd.Flags().BoolVar(
c.createDBOptions.ForceRemovalAtCreation,
&c.createDBOptions.ForceRemovalAtCreation,
"force-removal-at-creation",
false,
"Force removal of existing directories before creating the database",
)
cmd.Flags().BoolVar(
c.createDBOptions.SkipPackageInstall,
&c.createDBOptions.SkipPackageInstall,
"skip-package-install",
false,
"Skip the installation of packages from /opt/vertica/packages.",
)
cmd.Flags().IntVar(
c.createDBOptions.TimeoutNodeStartupSeconds,
&c.createDBOptions.TimeoutNodeStartupSeconds,
"startup-timeout",
util.DefaultTimeoutSeconds,
"The timeout to wait for the nodes to start",
Expand All @@ -217,13 +217,13 @@ func (c *CmdCreateDB) setLocalFlags(cmd *cobra.Command) {
// These hidden flags will not be shown in help and usage of the command, and they will be used internally.
func (c *CmdCreateDB) setHiddenFlags(cmd *cobra.Command) {
cmd.Flags().IntVar(
c.createDBOptions.ClientPort,
&c.createDBOptions.ClientPort,
"client-port",
util.DefaultClientPort,
"",
)
cmd.Flags().BoolVar(
c.createDBOptions.SkipStartupPolling,
&c.createDBOptions.SkipStartupPolling,
"skip-startup-polling",
false,
"",
Expand Down
5 changes: 2 additions & 3 deletions commands/cmd_drop_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ func makeCmdDropDB() *cobra.Command {
newCmd := &CmdDropDB{}
opt := vclusterops.VDropDatabaseOptionsFactory()
newCmd.dropDBOptions = &opt
newCmd.dropDBOptions.ForceDelete = new(bool)

// VER-92345 update the long description about the hosts option
cmd := makeBasicCobraCmd(
Expand Down Expand Up @@ -75,7 +74,7 @@ Examples:
// setLocalFlags will set the local flags the command has
func (c *CmdDropDB) setLocalFlags(cmd *cobra.Command) {
cmd.Flags().BoolVar(
c.dropDBOptions.ForceDelete,
&c.dropDBOptions.ForceDelete,
"force-delete",
false,
"Delete local directories like catalog, depot, and data.",
Expand Down Expand Up @@ -107,7 +106,7 @@ func (c *CmdDropDB) Run(vcc vclusterops.ClusterCommands) error {
return err
}

vcc.PrintInfo("Successfully dropped database %s", *c.dropDBOptions.DBName)
vcc.PrintInfo("Successfully dropped database %s", c.dropDBOptions.DBName)
// if the database is successfully dropped, the config file will be removed
// if failed to remove it, we will ask users to manually do it
err = removeConfig(vcc.GetLog())
Expand Down
2 changes: 1 addition & 1 deletion commands/cmd_install_packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Examples:
// setLocalFlags will set the local flags the command has
func (c *CmdInstallPackages) setLocalFlags(cmd *cobra.Command) {
cmd.Flags().BoolVar(
c.installPkgOpts.ForceReinstall,
&c.installPkgOpts.ForceReinstall,
"force-reinstall",
false,
"Install the packages, even if they are already installed.",
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 @@ -82,7 +82,7 @@ func (c *CmdRemoveNode) setLocalFlags(cmd *cobra.Command) {
"Comma-separated list of host(s) to remove from the database",
)
cmd.Flags().BoolVar(
c.removeNodeOptions.ForceDelete,
&c.removeNodeOptions.ForceDelete,
"force-delete",
true,
"Whether to force clean-up of existing directories if they are not empty",
Expand Down Expand Up @@ -148,7 +148,7 @@ func (c *CmdRemoveNode) Run(vcc vclusterops.ClusterCommands) error {
if err != nil {
vcc.PrintWarning("fail to write config file, details: %s", err)
}
vcc.PrintInfo("Successfully removed nodes %v from database %s", c.removeNodeOptions.HostsToRemove, *options.DBName)
vcc.PrintInfo("Successfully removed nodes %v from database %s", c.removeNodeOptions.HostsToRemove, options.DBName)

return nil
}
Expand Down
Loading

0 comments on commit 5b41e6f

Please sign in to comment.