Skip to content

Commit

Permalink
Sync from server repo (9e6d6f6f46f)
Browse files Browse the repository at this point in the history
  • Loading branch information
ctran committed May 13, 2024
1 parent 520dab9 commit 9b9e623
Show file tree
Hide file tree
Showing 34 changed files with 96 additions and 66 deletions.
15 changes: 0 additions & 15 deletions .vscode/launch.json

This file was deleted.

2 changes: 1 addition & 1 deletion commands/cmd_add_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Examples:
--data-path /data --hosts 10.20.30.40 \
--node-names v_test_db_node0001,v_test_db_node0002
`,
[]string{dbNameFlag, configFlag, hostsFlag, dataPathFlag, depotPathFlag,
[]string{dbNameFlag, configFlag, hostsFlag, ipv6Flag, dataPathFlag, depotPathFlag,
passwordFlag},
)

Expand Down
2 changes: 1 addition & 1 deletion commands/cmd_add_subcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Examples:
--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
`,
[]string{dbNameFlag, configFlag, hostsFlag, eonModeFlag, passwordFlag,
[]string{dbNameFlag, configFlag, hostsFlag, ipv6Flag, eonModeFlag, passwordFlag,
dataPathFlag, depotPathFlag},
)

Expand Down
2 changes: 1 addition & 1 deletion commands/cmd_drop_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Examples:
vcluster drop_db --db-name test_db \
--config /opt/vertica/config/vertica_cluster.yaml
`,
[]string{dbNameFlag, configFlag, hostsFlag, catalogPathFlag, dataPathFlag, depotPathFlag},
[]string{dbNameFlag, configFlag, hostsFlag, ipv6Flag, catalogPathFlag, dataPathFlag, depotPathFlag},
)

// local flags
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 @@ -63,7 +63,7 @@ Examples:
vcluster install_packages --db-name test_db --force-reinstall \
--config /opt/vertica/config/vertica_cluster.yaml
`,
[]string{dbNameFlag, configFlag, hostsFlag, passwordFlag, outputFileFlag},
[]string{dbNameFlag, configFlag, hostsFlag, ipv6Flag, passwordFlag, outputFileFlag},
)

// local flags
Expand Down
5 changes: 4 additions & 1 deletion commands/cmd_list_all_nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Examples:
vcluster list_allnodes --password testpassword \
--config /opt/vertica/config/vertica_cluster.yaml
`,
[]string{dbNameFlag, hostsFlag, passwordFlag, catalogPathFlag, configFlag, outputFileFlag},
[]string{dbNameFlag, hostsFlag, passwordFlag, ipv6Flag, catalogPathFlag, configFlag, outputFileFlag},
)

return cmd
Expand All @@ -77,6 +77,9 @@ func (c *CmdListAllNodes) Parse(inputArgv []string, logger vlog.Printer) error {
// reset the value of those options to nil
c.ResetUserInputOptions(&c.fetchNodeStateOptions.DatabaseOptions)

// Set GetVersion to true so that the CLI can retrieve versions for down nodes
// by invoking two additional operations: NMAHealth and NMA readCatalogEditor
c.fetchNodeStateOptions.GetVersion = true
return c.validateParse(logger)
}

Expand Down
6 changes: 4 additions & 2 deletions commands/cmd_re_ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Examples:
vcluster re_ip --db-name test_db --re-ip-file /data/re_ip_map.json \
--config /opt/vertica/config/vertica_cluster.yaml
`,
[]string{dbNameFlag, hostsFlag, catalogPathFlag, configParamFlag, configFlag},
[]string{dbNameFlag, hostsFlag, ipv6Flag, catalogPathFlag, configParamFlag, configFlag},
)

// local flags
Expand All @@ -93,7 +93,9 @@ func (c *CmdReIP) setLocalFlags(cmd *cobra.Command) {
func (c *CmdReIP) Parse(inputArgv []string, logger vlog.Printer) error {
c.argv = inputArgv
logger.LogArgParse(&c.argv)

// Set CheckDBRunning to true so that CLI can check running db for Re_IP
// Re-IP should only be used for down DB, checking if db is running
c.reIPOptions.CheckDBRunning = true
return c.validateParse(logger)
}

Expand Down
2 changes: 1 addition & 1 deletion commands/cmd_remove_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Examples:
vcluster db_remove_node --db-name test_db --remove 10.20.30.42 \
--hosts 10.20.30.40 --data-path /data
`,
[]string{dbNameFlag, configFlag, hostsFlag, catalogPathFlag, dataPathFlag, depotPathFlag, passwordFlag},
[]string{dbNameFlag, configFlag, hostsFlag, ipv6Flag, catalogPathFlag, dataPathFlag, depotPathFlag, passwordFlag},
)

// local flags
Expand Down
2 changes: 1 addition & 1 deletion commands/cmd_remove_subcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Examples:
--hosts 10.20.30.40,10.20.30.41,10.20.30.42 --subcluster sc1 \
--data-path /data --depot-path /data
`,
[]string{dbNameFlag, configFlag, hostsFlag, eonModeFlag, dataPathFlag, depotPathFlag, passwordFlag},
[]string{dbNameFlag, configFlag, hostsFlag, ipv6Flag, eonModeFlag, dataPathFlag, depotPathFlag, passwordFlag},
)

// local flags
Expand Down
2 changes: 1 addition & 1 deletion commands/cmd_restart_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Examples:
--restart v_test_db_node0003=10.20.30.42,v_test_db_node0004=10.20.30.43 \
--password testpassword --config /opt/vertica/config/vertica_cluster.yaml
`,
[]string{dbNameFlag, hostsFlag, configFlag, passwordFlag},
[]string{dbNameFlag, hostsFlag, ipv6Flag, configFlag, passwordFlag},
)

// local flags
Expand Down
2 changes: 1 addition & 1 deletion commands/cmd_revive_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Examples:
--ignore-cluster-lease --restore-point-archive db --restore-point-index 1
`,
[]string{dbNameFlag, hostsFlag, communalStorageLocationFlag, configFlag, outputFileFlag, configParamFlag},
[]string{dbNameFlag, hostsFlag, ipv6Flag, communalStorageLocationFlag, configFlag, outputFileFlag, configParamFlag},
)

// local flags
Expand Down
2 changes: 1 addition & 1 deletion commands/cmd_sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Examples:
vcluster sandbox_subcluster --subcluster sc1 --sandbox sand \
--hosts 10.20.30.40,10.20.30.41,10.20.30.42 --db-name test_db
`,
[]string{dbNameFlag, configFlag, hostsFlag, passwordFlag},
[]string{dbNameFlag, configFlag, hostsFlag, ipv6Flag, passwordFlag},
)

// local flags
Expand Down
2 changes: 1 addition & 1 deletion commands/cmd_scrutinize.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Examples:
vcluster scrutinize --db-name test_db --db-user dbadmin \
--password testpassword --config /opt/vertica/config/vertica_cluster.yaml
`,
[]string{dbNameFlag, hostsFlag, configFlag, catalogPathFlag, passwordFlag},
[]string{dbNameFlag, hostsFlag, ipv6Flag, configFlag, catalogPathFlag, passwordFlag},
)

// local flags
Expand Down
2 changes: 1 addition & 1 deletion commands/cmd_show_restore_points.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Examples:
--start-timestamp 2024-03-04 08:32:33.277569 \
--end-timestamp 2024-03-04 08:32:34.176391
`,
[]string{dbNameFlag, configFlag, passwordFlag, hostsFlag,
[]string{dbNameFlag, configFlag, passwordFlag, hostsFlag, ipv6Flag,
communalStorageLocationFlag, configParamFlag},
)

Expand Down
2 changes: 1 addition & 1 deletion commands/cmd_start_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Examples:
vcluster start_db --password testpassword \
--config /opt/vertica/config/vertica_cluster.yaml
`,
[]string{dbNameFlag, hostsFlag, communalStorageLocationFlag,
[]string{dbNameFlag, hostsFlag, communalStorageLocationFlag, ipv6Flag,
configFlag, catalogPathFlag, passwordFlag, eonModeFlag, configParamFlag},
)

Expand Down
2 changes: 1 addition & 1 deletion commands/cmd_start_subcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Examples:
vcluster start_subcluster --db-name test_db \
--hosts 10.20.30.40,10.20.30.41,10.20.30.42 --subcluster sc1
`,
[]string{dbNameFlag, configFlag, hostsFlag, eonModeFlag, passwordFlag},
[]string{dbNameFlag, configFlag, hostsFlag, ipv6Flag, eonModeFlag, passwordFlag},
)

// local flags
Expand Down
2 changes: 1 addition & 1 deletion commands/cmd_stop_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Examples:
vcluster stop_node --db-name test_db --stop-hosts 10.20.30.40,10.20.30.41 \
--hosts 10.20.30.40,10.20.30.41,10.20.30.42
`,
[]string{dbNameFlag, hostsFlag, configFlag, passwordFlag},
[]string{dbNameFlag, hostsFlag, ipv6Flag, configFlag, passwordFlag},
)

// local flags
Expand Down
2 changes: 1 addition & 1 deletion commands/cmd_unsandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Examples:
vcluster unsandbox_subcluster --subcluster sc1 \
--hosts 10.20.30.40,10.20.30.41,10.20.30.42 --db-name test_db
`,
[]string{dbNameFlag, configFlag, passwordFlag, hostsFlag},
[]string{dbNameFlag, configFlag, ipv6Flag, passwordFlag, hostsFlag},
)

// local flags
Expand Down
12 changes: 7 additions & 5 deletions vclusterops/adapter_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,22 @@ type adapterPool struct {
}

var (
poolInstance *adapterPool
poolInstance adapterPool
once sync.Once
)

// return a singleton instance of the AdapterPool
func getPoolInstance(logger vlog.Printer) *adapterPool {
// return a new instance of an adapterPool. The adapterPool cannot be shared
// between Go routines. Otherwise, they will clobber each other state causing
// HTTP request errors. It is the callers responsibility to ensure it doesn't
// get shared.
func getPoolInstance(logger vlog.Printer) adapterPool {
/* if once.Do(f) is called multiple times,
* only the first call will invoke f,
* even if f has a different value in each invocation.
* Reference: https://pkg.go.dev/sync#Once
*/
once.Do(func() {
pool := makeAdapterPool(logger)
poolInstance = &pool
poolInstance = makeAdapterPool(logger)
})

return poolInstance
Expand Down
2 changes: 1 addition & 1 deletion vclusterops/cluster_op.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ func (op *opBase) loadCertsIfNeeded(certs *httpsCerts, findCertsInOptions bool)

// this step is executed after Prepare() so all http requests should be set up
if len(op.clusterHTTPRequest.RequestCollection) == 0 {
return fmt.Errorf("[%s] has not set up a http request", op.name)
return fmt.Errorf("[%s] clusterHTTPRequest.RequestCollection is empty", op.name)
}

if certs == nil {
Expand Down
5 changes: 3 additions & 2 deletions vclusterops/coordinator_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,9 @@ type VCoordinationNode struct {
// empty string if it is not an eon db
Subcluster string
// empty string if it is not in a sandbox
Sandbox string
Version string
Sandbox string
Version string
IsControlNode bool
}

func makeVCoordinationNode() VCoordinationNode {
Expand Down
12 changes: 10 additions & 2 deletions vclusterops/fetch_node_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import (

type VFetchNodeStateOptions struct {
DatabaseOptions
// retrieve the version for down nodes by invoking two additional
// operations: NMAHealth and NMA readCatalogEditor. This is useful
// when we cannot get the version for down nodes from a running database
GetVersion bool
}

func VFetchNodeStateOptionsFactory() VFetchNodeStateOptions {
Expand Down Expand Up @@ -183,9 +187,13 @@ func (vcc VClusterCommands) produceListAllNodesInstructions(
return instructions, err
}

if options.GetVersion {
instructions = append(instructions,
&nmaHealthOp,
&nmaReadVerticaVersionOp)
}

instructions = append(instructions,
&nmaHealthOp,
&nmaReadVerticaVersionOp,
&httpsCheckNodeStateOp,
)

Expand Down
1 change: 1 addition & 0 deletions vclusterops/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ type nodeStateInfo struct {
Name string `json:"name"`
Sandbox string `json:"sandbox_name"`
Version string `json:"build_info"`
IsControlNode bool `json:"is_control_node"`
}

func (node *nodeStateInfo) asNodeInfo() (n NodeInfo, err error) {
Expand Down
2 changes: 1 addition & 1 deletion vclusterops/http_request_dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

type requestDispatcher struct {
opBase
pool *adapterPool
pool adapterPool
}

func makeHTTPRequestDispatcher(logger vlog.Printer) requestDispatcher {
Expand Down
1 change: 1 addition & 0 deletions vclusterops/https_get_nodes_info_op.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ func (op *httpsGetNodesInfoOp) processResult(_ *opEngineExecContext) error {
vNode.State = node.State
vNode.Subcluster = node.Subcluster
vNode.Sandbox = node.Sandbox
vNode.IsControlNode = node.IsControlNode
if node.IsPrimary && node.State == util.NodeUpState {
op.vdb.PrimaryUpNodes = append(op.vdb.PrimaryUpNodes, node.Address)
}
Expand Down
4 changes: 2 additions & 2 deletions vclusterops/https_poll_node_state_op.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
// Timeout set to 30 seconds for each GET /v1/nodes/{node} call.
// 30 seconds is long enough for normal http request.
// If this timeout is reached, it might imply that the target IP is unreachable
const defaultHTTPRequestTimeoutSeconds = 30
const defaultHTTPSRequestTimeoutSeconds = 30
const (
StartDBCmd CmdType = iota
StartNodeCmd
Expand Down Expand Up @@ -67,7 +67,7 @@ func makeHTTPSPollNodeStateOpHelper(hosts []string,
op.description = fmt.Sprintf("Wait for %d node(s) to come up", len(hosts))
op.hosts = hosts
op.useHTTPPassword = useHTTPPassword
op.httpRequestTimeout = defaultHTTPRequestTimeoutSeconds
op.httpRequestTimeout = defaultHTTPSRequestTimeoutSeconds
op.checkDown = false // setting default to poll nodes UP
err := util.ValidateUsernameAndPassword(op.name, useHTTPPassword, userName)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion vclusterops/https_poll_subcluster_node_state_op.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (op *httpsPollSubclusterNodeStateOp) setupClusterHTTPRequest(hosts []string
for _, host := range hosts {
httpRequest := hostHTTPRequest{}
httpRequest.Method = GetMethod
httpRequest.Timeout = defaultHTTPRequestTimeoutSeconds
httpRequest.Timeout = defaultHTTPSRequestTimeoutSeconds
httpRequest.buildHTTPSEndpoint("nodes/" + host)
if op.useHTTPPassword {
httpRequest.Password = op.httpsPassword
Expand Down
2 changes: 1 addition & 1 deletion vclusterops/https_poll_subscription_state_op.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (op *httpsPollSubscriptionStateOp) setupClusterHTTPRequest(hosts []string)
for _, host := range hosts {
httpRequest := hostHTTPRequest{}
httpRequest.Method = GetMethod
httpRequest.Timeout = defaultHTTPRequestTimeoutSeconds
httpRequest.Timeout = defaultHTTPSRequestTimeoutSeconds
httpRequest.buildHTTPSEndpoint("subscriptions")
if op.useHTTPPassword {
httpRequest.Password = op.httpsPassword
Expand Down
6 changes: 5 additions & 1 deletion vclusterops/https_update_node_state_op.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ type httpsUpdateNodeStateOp struct {
opBase
opHTTPSBase
vdb *VCoordinationDatabase
// The timeout for each http request. Requests will be repeated if timeout hasn't been exceeded.
httpRequestTimeout int
}

func makeHTTPSUpdateNodeStateOp(vdb *VCoordinationDatabase,
Expand All @@ -35,9 +37,9 @@ func makeHTTPSUpdateNodeStateOp(vdb *VCoordinationDatabase,
op := httpsUpdateNodeStateOp{}
op.name = "HTTPSUpdateNodeStateOp"
op.description = "Update node state from running database"
op.hosts = vdb.HostList
op.vdb = vdb
op.useHTTPPassword = useHTTPPassword
op.httpRequestTimeout = defaultHTTPSRequestTimeoutSeconds

err := util.ValidateUsernameAndPassword(op.name, useHTTPPassword, userName)
if err != nil {
Expand All @@ -53,6 +55,7 @@ func (op *httpsUpdateNodeStateOp) setupClusterHTTPRequest(hosts []string) error
for _, host := range hosts {
httpRequest := hostHTTPRequest{}
httpRequest.Method = GetMethod
httpRequest.Timeout = op.httpRequestTimeout
httpRequest.buildHTTPSEndpoint("nodes/" + host)
if op.useHTTPPassword {
httpRequest.Password = op.httpsPassword
Expand All @@ -65,6 +68,7 @@ func (op *httpsUpdateNodeStateOp) setupClusterHTTPRequest(hosts []string) error
}

func (op *httpsUpdateNodeStateOp) prepare(execContext *opEngineExecContext) error {
op.hosts = op.vdb.HostList
execContext.dispatcher.setup(op.hosts)

return op.setupClusterHTTPRequest(op.hosts)
Expand Down
Loading

0 comments on commit 9b9e623

Please sign in to comment.