From c1901cb1051aa1e9f408e47930654bc250bb698f Mon Sep 17 00:00:00 2001 From: Matt Spilchen Date: Thu, 26 Oct 2023 15:44:34 -0400 Subject: [PATCH] Sync from server repo (174b36d11c) --- vclusterops/add_node.go | 18 +++--- vclusterops/add_subcluster.go | 22 +++---- vclusterops/cluster_config.go | 2 +- vclusterops/cluster_op.go | 16 ++--- vclusterops/cluster_op_engine.go | 6 +- vclusterops/cluster_op_engine_context.go | 4 +- vclusterops/cluster_op_engine_test.go | 4 +- vclusterops/coordinator_database.go | 24 ++++---- vclusterops/create_db.go | 28 ++++----- vclusterops/drop_db.go | 14 ++--- vclusterops/fetch_node_state.go | 12 ++-- vclusterops/helpers.go | 6 +- vclusterops/http_adapter.go | 2 +- vclusterops/http_request.go | 4 +- vclusterops/http_request_dispatcher.go | 6 +- vclusterops/https_add_subcluster_op.go | 6 +- ...unning.go => https_check_db_running_op.go} | 8 +-- vclusterops/https_check_node_state_op.go | 8 +-- vclusterops/https_check_subcluster_op.go | 6 +- vclusterops/https_create_cluster_depot_op.go | 4 +- vclusterops/https_create_node_op.go | 4 +- vclusterops/https_create_nodes_depot_op.go | 4 +- vclusterops/https_drop_node_op.go | 6 +- vclusterops/https_drop_subcluster_op.go | 6 +- vclusterops/https_find_subcluster_op.go | 6 +- vclusterops/https_get_cluster_info_op.go | 6 +- vclusterops/https_get_nodes_info_op.go | 6 +- vclusterops/https_get_up_nodes_op.go | 6 +- vclusterops/https_install_packages_op.go | 4 +- vclusterops/https_mark_design_ksafe_op.go | 4 +- vclusterops/https_mark_nodes_ephemeral_op.go | 6 +- vclusterops/https_poll_node_state_op.go | 6 +- vclusterops/https_poll_node_state_op_test.go | 4 +- .../https_poll_subscription_state_op.go | 6 +- vclusterops/https_re_ip_op.go | 6 +- vclusterops/https_rebalance_cluster_op.go | 8 +-- .../https_rebalance_subcluster_shards_op.go | 6 +- vclusterops/https_reload_spread_op.go | 4 +- vclusterops/https_spread_remove_node_op.go | 4 +- vclusterops/https_startup_command_op.go | 6 +- vclusterops/https_stop_db_op.go | 4 +- vclusterops/https_sync_catalog_op.go | 4 +- vclusterops/nma_bootstrap_catalog_op.go | 4 +- vclusterops/nma_delete_dir_op.go | 4 +- vclusterops/nma_download_config.go | 4 +- vclusterops/nma_download_file_op.go | 4 +- vclusterops/nma_get_nodes_info_op.go | 4 +- vclusterops/nma_health_op.go | 4 +- vclusterops/nma_load_remote_catalog_op.go | 4 +- vclusterops/nma_network_profile_op.go | 4 +- vclusterops/nma_prepare_directories_op.go | 4 +- vclusterops/nma_re_ip_op.go | 4 +- vclusterops/nma_read_catalog_editor_op.go | 4 +- vclusterops/nma_spread_security_op.go | 4 +- vclusterops/nma_start_node_op.go | 4 +- vclusterops/nma_upload_config.go | 4 +- vclusterops/nma_vertica_version_op.go | 4 +- vclusterops/re_ip.go | 12 ++-- vclusterops/re_ip_test.go | 8 +-- vclusterops/remove_node.go | 20 +++---- vclusterops/remove_subcluster.go | 14 ++--- vclusterops/restart_node.go | 16 ++--- vclusterops/revive_db.go | 14 ++--- vclusterops/start_db.go | 26 ++++----- vclusterops/stop_db.go | 24 ++++---- vclusterops/vcluster_database_options.go | 58 +++++++++---------- 66 files changed, 284 insertions(+), 284 deletions(-) rename vclusterops/{https_check_db_running.go => https_check_db_running_op.go} (98%) diff --git a/vclusterops/add_node.go b/vclusterops/add_node.go index bbca681..4c2a588 100644 --- a/vclusterops/add_node.go +++ b/vclusterops/add_node.go @@ -47,13 +47,13 @@ type VAddNodeOptions struct { func VAddNodeOptionsFactory() VAddNodeOptions { opt := VAddNodeOptions{} // set default values to the params - opt.SetDefaultValues() + opt.setDefaultValues() return opt } -func (o *VAddNodeOptions) SetDefaultValues() { - o.DatabaseOptions.SetDefaultValues() +func (o *VAddNodeOptions) setDefaultValues() { + o.DatabaseOptions.setDefaultValues() o.SCName = new(string) o.SkipRebalanceShards = new(bool) @@ -81,7 +81,7 @@ func (o *VAddNodeOptions) validateExtraOptions() error { func (o *VAddNodeOptions) validateParseOptions(log vlog.Printer) error { // batch 1: validate required parameters - err := o.ValidateBaseOptions("db_add_node", log) + err := o.validateBaseOptions("db_add_node", log) if err != nil { return err } @@ -129,7 +129,7 @@ func (vcc *VClusterCommands) VAddNode(options *VAddNodeOptions) (VCoordinationDa } // get hosts from config file and options. - hosts, err := options.GetHosts(options.Config) + hosts, err := options.getHosts(options.Config) if err != nil { return vdb, err } @@ -190,8 +190,8 @@ func (vcc *VClusterCommands) VAddNode(options *VAddNodeOptions) (VCoordinationDa } certs := HTTPSCerts{key: options.Key, cert: options.Cert, caCert: options.CaCert} - clusterOpEngine := MakeClusterOpEngine(instructions, &certs) - if runError := clusterOpEngine.Run(vcc.Log); runError != nil { + clusterOpEngine := makeClusterOpEngine(instructions, &certs) + if runError := clusterOpEngine.run(vcc.Log); runError != nil { return vdb, fmt.Errorf("fail to complete add node operation, %w", runError) } return vdb, nil @@ -299,8 +299,8 @@ func (vcc *VClusterCommands) trimNodesInCatalog(vdb *VCoordinationDatabase, } certs := HTTPSCerts{key: options.Key, cert: options.Cert, caCert: options.CaCert} - clusterOpEngine := MakeClusterOpEngine(instructions, &certs) - err := clusterOpEngine.Run(vcc.Log) + clusterOpEngine := makeClusterOpEngine(instructions, &certs) + err := clusterOpEngine.run(vcc.Log) if err != nil { vcc.Log.Error(err, "fail to trim nodes from catalog, %v") return err diff --git a/vclusterops/add_subcluster.go b/vclusterops/add_subcluster.go index 6a50844..d9a6fd0 100644 --- a/vclusterops/add_subcluster.go +++ b/vclusterops/add_subcluster.go @@ -55,13 +55,13 @@ type VAddSubclusterInfo struct { func VAddSubclusterOptionsFactory() VAddSubclusterOptions { opt := VAddSubclusterOptions{} // set default values to the params - opt.SetDefaultValues() + opt.setDefaultValues() return opt } -func (options *VAddSubclusterOptions) SetDefaultValues() { - options.DatabaseOptions.SetDefaultValues() +func (options *VAddSubclusterOptions) setDefaultValues() { + options.DatabaseOptions.setDefaultValues() options.SCName = new(string) options.IsPrimary = new(bool) @@ -71,7 +71,7 @@ func (options *VAddSubclusterOptions) SetDefaultValues() { } func (options *VAddSubclusterOptions) validateRequiredOptions(log vlog.Printer) error { - err := options.ValidateBaseOptions("db_add_subcluster", log) + err := options.validateBaseOptions("db_add_subcluster", log) if err != nil { return err } @@ -83,7 +83,7 @@ func (options *VAddSubclusterOptions) validateRequiredOptions(log vlog.Printer) } func (options *VAddSubclusterOptions) validateEonOptions(config *ClusterConfig) error { - isEon, err := options.IsEonMode(config) + isEon, err := options.isEonMode(config) if err != nil { return err } @@ -169,7 +169,7 @@ func (options *VAddSubclusterOptions) analyzeOptions() (err error) { return nil } -func (options *VAddSubclusterOptions) ValidateAnalyzeOptions(config *ClusterConfig, vcc *VClusterCommands) error { +func (options *VAddSubclusterOptions) validateAnalyzeOptions(config *ClusterConfig, vcc *VClusterCommands) error { if err := options.validateParseOptions(config, vcc); err != nil { return err } @@ -184,7 +184,7 @@ func (vcc *VClusterCommands) VAddSubcluster(options *VAddSubclusterOptions) erro * - Give the instructions to the VClusterOpEngine to run */ - err := options.ValidateAnalyzeOptions(options.Config, vcc) + err := options.validateAnalyzeOptions(options.Config, vcc) if err != nil { return err } @@ -199,7 +199,7 @@ func (vcc *VClusterCommands) VAddSubcluster(options *VAddSubclusterOptions) erro ControlSetSize: *options.ControlSetSize, CloneSC: *options.CloneSC, } - addSubclusterInfo.DBName, addSubclusterInfo.Hosts, err = options.GetNameAndHosts(options.Config) + addSubclusterInfo.DBName, addSubclusterInfo.Hosts, err = options.getNameAndHosts(options.Config) if err != nil { return err } @@ -211,10 +211,10 @@ func (vcc *VClusterCommands) VAddSubcluster(options *VAddSubclusterOptions) erro // Create a VClusterOpEngine, and add certs to the engine certs := HTTPSCerts{key: options.Key, cert: options.Cert, caCert: options.CaCert} - clusterOpEngine := MakeClusterOpEngine(instructions, &certs) + clusterOpEngine := makeClusterOpEngine(instructions, &certs) // Give the instructions to the VClusterOpEngine to run - runError := clusterOpEngine.Run(vcc.Log) + runError := clusterOpEngine.run(vcc.Log) if runError != nil { return fmt.Errorf("fail to add subcluster %s, %w", addSubclusterInfo.SCName, runError) } @@ -241,7 +241,7 @@ func (vcc *VClusterCommands) produceAddSubclusterInstructions(addSubclusterInfo usePassword := false if addSubclusterInfo.Password != nil { usePassword = true - err := options.ValidateUserName(vcc.Log) + err := options.validateUserName(vcc.Log) if err != nil { return instructions, err } diff --git a/vclusterops/cluster_config.go b/vclusterops/cluster_config.go index 189193c..8bc9295 100644 --- a/vclusterops/cluster_config.go +++ b/vclusterops/cluster_config.go @@ -138,7 +138,7 @@ func (c *ClusterConfig) GetPathPrefix(dbName string) (catalogPrefix string, dbConfig.Nodes[0].DepotPath, nil } -func (c *DatabaseConfig) GetHosts() []string { +func (c *DatabaseConfig) getHosts() []string { var hostList []string for _, vnode := range c.Nodes { diff --git a/vclusterops/cluster_op.go b/vclusterops/cluster_op.go index bb12728..70b5ea8 100644 --- a/vclusterops/cluster_op.go +++ b/vclusterops/cluster_op.go @@ -95,18 +95,18 @@ const respSuccStatusCode = 0 // 3. The local node has not yet joined the cluster; the HTTP server will accept connections once the node joins the cluster. // HTTPCheckDBRunningOp in create_db need to check all scenarios to see any HTTP running // For HTTPSPollNodeStateOp in start_db, it requires only handling the first and second scenarios -func (hostResult *HostHTTPResult) IsUnauthorizedRequest() bool { +func (hostResult *HostHTTPResult) isUnauthorizedRequest() bool { return hostResult.statusCode == UnauthorizedCode } -// IsSuccess returns true if status code is 200 -func (hostResult *HostHTTPResult) IsSuccess() bool { +// isSuccess returns true if status code is 200 +func (hostResult *HostHTTPResult) isSuccess() bool { return hostResult.statusCode == SuccessCode } // check only password and certificate for start_db -func (hostResult *HostHTTPResult) IsPasswordAndCertificateError(log vlog.Printer) bool { - if !hostResult.IsUnauthorizedRequest() { +func (hostResult *HostHTTPResult) isPasswordAndCertificateError(log vlog.Printer) bool { + if !hostResult.isUnauthorizedRequest() { return false } resultString := fmt.Sprintf("%v", hostResult) @@ -119,12 +119,12 @@ func (hostResult *HostHTTPResult) IsPasswordAndCertificateError(log vlog.Printer return false } -func (hostResult *HostHTTPResult) IsInternalError() bool { +func (hostResult *HostHTTPResult) isInternalError() bool { return hostResult.statusCode == InternalErrorCode } -func (hostResult *HostHTTPResult) IsHTTPRunning() bool { - if hostResult.isPassing() || hostResult.IsUnauthorizedRequest() || hostResult.IsInternalError() { +func (hostResult *HostHTTPResult) isHTTPRunning() bool { + if hostResult.isPassing() || hostResult.isUnauthorizedRequest() || hostResult.isInternalError() { return true } return false diff --git a/vclusterops/cluster_op_engine.go b/vclusterops/cluster_op_engine.go index 22db09d..1611cee 100644 --- a/vclusterops/cluster_op_engine.go +++ b/vclusterops/cluster_op_engine.go @@ -27,7 +27,7 @@ type VClusterOpEngine struct { execContext *OpEngineExecContext } -func MakeClusterOpEngine(instructions []ClusterOp, certs *HTTPSCerts) VClusterOpEngine { +func makeClusterOpEngine(instructions []ClusterOp, certs *HTTPSCerts) VClusterOpEngine { newClusterOpEngine := VClusterOpEngine{} newClusterOpEngine.instructions = instructions newClusterOpEngine.certs = certs @@ -38,8 +38,8 @@ func (opEngine *VClusterOpEngine) shouldGetCertsFromOptions() bool { return (opEngine.certs.key != "" && opEngine.certs.cert != "" && opEngine.certs.caCert != "") } -func (opEngine *VClusterOpEngine) Run(log vlog.Printer) error { - execContext := MakeOpEngineExecContext(log) +func (opEngine *VClusterOpEngine) run(log vlog.Printer) error { + execContext := makeOpEngineExecContext(log) opEngine.execContext = &execContext findCertsInOptions := opEngine.shouldGetCertsFromOptions() diff --git a/vclusterops/cluster_op_engine_context.go b/vclusterops/cluster_op_engine_context.go index 82c8028..ef01323 100644 --- a/vclusterops/cluster_op_engine_context.go +++ b/vclusterops/cluster_op_engine_context.go @@ -29,9 +29,9 @@ type OpEngineExecContext struct { dbInfo string // store the db info that retrieved from communal storage } -func MakeOpEngineExecContext(log vlog.Printer) OpEngineExecContext { +func makeOpEngineExecContext(log vlog.Printer) OpEngineExecContext { newOpEngineExecContext := OpEngineExecContext{} - newOpEngineExecContext.dispatcher = MakeHTTPRequestDispatcher(log) + newOpEngineExecContext.dispatcher = makeHTTPRequestDispatcher(log) return newOpEngineExecContext } diff --git a/vclusterops/cluster_op_engine_test.go b/vclusterops/cluster_op_engine_test.go index d871909..8222751 100644 --- a/vclusterops/cluster_op_engine_test.go +++ b/vclusterops/cluster_op_engine_test.go @@ -74,8 +74,8 @@ func TestSkipExecuteOp(t *testing.T) { opWithSkipDisabled := makeMockOp(false) instructions := []ClusterOp{&opWithSkipDisabled, &opWithSkipEnabled} certs := HTTPSCerts{key: "key", cert: "cert", caCert: "ca-cert"} - opEngn := MakeClusterOpEngine(instructions, &certs) - err := opEngn.Run(vlog.Printer{}) + opEngn := makeClusterOpEngine(instructions, &certs) + err := opEngn.run(vlog.Printer{}) assert.Equal(t, nil, err) assert.True(t, opWithSkipDisabled.calledPrepare) assert.True(t, opWithSkipDisabled.calledExecute) diff --git a/vclusterops/coordinator_database.go b/vclusterops/coordinator_database.go index 4f961ac..3b19d5c 100644 --- a/vclusterops/coordinator_database.go +++ b/vclusterops/coordinator_database.go @@ -72,9 +72,9 @@ func MakeVCoordinationDatabase() VCoordinationDatabase { return VCoordinationDatabase{} } -func (vdb *VCoordinationDatabase) SetFromCreateDBOptions(options *VCreateDatabaseOptions, log vlog.Printer) error { +func (vdb *VCoordinationDatabase) setFromCreateDBOptions(options *VCreateDatabaseOptions, log vlog.Printer) error { // build after validating the options - err := options.ValidateAnalyzeOptions(log) + err := options.validateAnalyzeOptions(log) if err != nil { return err } @@ -103,7 +103,7 @@ func (vdb *VCoordinationDatabase) SetFromCreateDBOptions(options *VCreateDatabas vdb.UseDepot = true } if *options.GetAwsCredentialsFromEnv { - err := vdb.GetAwsCredentialsFromEnv() + err := vdb.getAwsCredentialsFromEnv() if err != nil { return err } @@ -113,7 +113,7 @@ func (vdb *VCoordinationDatabase) SetFromCreateDBOptions(options *VCreateDatabas // section 3: build VCoordinationNode info for _, host := range vdb.HostList { vNode := MakeVCoordinationNode() - err := vNode.SetFromCreateDBOptions(options, host) + err := vNode.setFromCreateDBOptions(options, host) if err != nil { return err } @@ -152,7 +152,7 @@ func (vdb *VCoordinationDatabase) addHosts(hosts []string) error { Address: host, Name: name, } - vNode.SetFromNodeConfig(&nodeConfig, vdb) + vNode.setFromNodeConfig(&nodeConfig, vdb) err := vdb.addNode(&vNode) if err != nil { return err @@ -162,7 +162,7 @@ func (vdb *VCoordinationDatabase) addHosts(hosts []string) error { return nil } -func (vdb *VCoordinationDatabase) SetFromClusterConfig(dbName string, +func (vdb *VCoordinationDatabase) setFromClusterConfig(dbName string, clusterConfig *ClusterConfig) error { // we trust the information in the config file // so we do not perform validation here @@ -190,7 +190,7 @@ func (vdb *VCoordinationDatabase) SetFromClusterConfig(dbName string, vdb.HostNodeMap = makeVHostNodeMap() for _, nodeConfig := range dbConfig.Nodes { vnode := VCoordinationNode{} - vnode.SetFromNodeConfig(nodeConfig, vdb) + vnode.setFromNodeConfig(nodeConfig, vdb) err = vdb.addNode(&vnode) if err != nil { return err @@ -200,10 +200,10 @@ func (vdb *VCoordinationDatabase) SetFromClusterConfig(dbName string, return nil } -// Copy copies the receiver's fields into a new VCoordinationDatabase struct and +// copy copies the receiver's fields into a new VCoordinationDatabase struct and // returns that struct. You can choose to copy only a subset of the receiver's hosts // by passing a slice of hosts to keep. -func (vdb *VCoordinationDatabase) Copy(targetHosts []string) VCoordinationDatabase { +func (vdb *VCoordinationDatabase) copy(targetHosts []string) VCoordinationDatabase { v := VCoordinationDatabase{ Name: vdb.Name, CatalogPrefix: vdb.CatalogPrefix, @@ -316,7 +316,7 @@ func (vdb *VCoordinationDatabase) genCatalogPath(nodeName string) string { } // set aws id key and aws secret key -func (vdb *VCoordinationDatabase) GetAwsCredentialsFromEnv() error { +func (vdb *VCoordinationDatabase) getAwsCredentialsFromEnv() error { awsIDKey := os.Getenv("AWS_ACCESS_KEY_ID") if awsIDKey == "" { return fmt.Errorf("unable to get AWS ID key from environment variable") @@ -371,7 +371,7 @@ func MakeVCoordinationNode() VCoordinationNode { return VCoordinationNode{} } -func (vnode *VCoordinationNode) SetFromCreateDBOptions( +func (vnode *VCoordinationNode) setFromCreateDBOptions( options *VCreateDatabaseOptions, host string, ) error { @@ -407,7 +407,7 @@ func (vnode *VCoordinationNode) SetFromCreateDBOptions( return fmt.Errorf("fail to set up vnode from options: host %s does not exist in options", host) } -func (vnode *VCoordinationNode) SetFromNodeConfig(nodeConfig *NodeConfig, vdb *VCoordinationDatabase) { +func (vnode *VCoordinationNode) setFromNodeConfig(nodeConfig *NodeConfig, vdb *VCoordinationDatabase) { // we trust the information in the config file // so we do not perform validation here vnode.Address = nodeConfig.Address diff --git a/vclusterops/create_db.go b/vclusterops/create_db.go index 04ec7ba..911353f 100644 --- a/vclusterops/create_db.go +++ b/vclusterops/create_db.go @@ -60,12 +60,12 @@ type VCreateDatabaseOptions struct { func VCreateDatabaseOptionsFactory() VCreateDatabaseOptions { opt := VCreateDatabaseOptions{} // set default values to the params - opt.SetDefaultValues() + opt.setDefaultValues() return opt } -func (opt *VCreateDatabaseOptions) SetDefaultValues() { - opt.DatabaseOptions.SetDefaultValues() +func (opt *VCreateDatabaseOptions) setDefaultValues() { + opt.DatabaseOptions.setDefaultValues() // basic db info defaultPolicy := util.DefaultRestartPolicy @@ -106,8 +106,8 @@ func (opt *VCreateDatabaseOptions) SetDefaultValues() { opt.SkipStartupPolling = new(bool) } -func (opt *VCreateDatabaseOptions) CheckNilPointerParams() error { - if err := opt.DatabaseOptions.CheckNilPointerParams(); err != nil { +func (opt *VCreateDatabaseOptions) checkNilPointerParams() error { + if err := opt.DatabaseOptions.checkNilPointerParams(); err != nil { return err } @@ -136,10 +136,10 @@ func (opt *VCreateDatabaseOptions) CheckNilPointerParams() error { return util.ParamNotSetErrorMsg("get-aws-credentials-from-env-vars") } - return opt.CheckExtraNilPointerParams() + return opt.checkExtraNilPointerParams() } -func (opt *VCreateDatabaseOptions) CheckExtraNilPointerParams() error { +func (opt *VCreateDatabaseOptions) checkExtraNilPointerParams() error { // optional params if opt.ForceCleanupOnFailure == nil { return util.ParamNotSetErrorMsg("force-cleanup-on-failure") @@ -315,13 +315,13 @@ func (opt *VCreateDatabaseOptions) validateExtraOptions() error { func (opt *VCreateDatabaseOptions) validateParseOptions(log vlog.Printer) error { // check nil pointers in the required options - err := opt.CheckNilPointerParams() + err := opt.checkNilPointerParams() if err != nil { return err } // validate base options - err = opt.ValidateBaseOptions("create_db", log) + err = opt.validateBaseOptions("create_db", log) if err != nil { return err } @@ -366,7 +366,7 @@ func (opt *VCreateDatabaseOptions) analyzeOptions() error { return nil } -func (opt *VCreateDatabaseOptions) ValidateAnalyzeOptions(log vlog.Printer) error { +func (opt *VCreateDatabaseOptions) validateAnalyzeOptions(log vlog.Printer) error { if err := opt.validateParseOptions(log); err != nil { return err } @@ -383,7 +383,7 @@ func (vcc *VClusterCommands) VCreateDatabase(options *VCreateDatabaseOptions) (V */ // Analyze to produce vdb info, for later create db use and for cache db info vdb := MakeVCoordinationDatabase() - err := vdb.SetFromCreateDBOptions(options, vcc.Log) + err := vdb.setFromCreateDBOptions(options, vcc.Log) if err != nil { return vdb, err } @@ -396,10 +396,10 @@ func (vcc *VClusterCommands) VCreateDatabase(options *VCreateDatabaseOptions) (V // create a VClusterOpEngine, and add certs to the engine certs := HTTPSCerts{key: options.Key, cert: options.Cert, caCert: options.CaCert} - clusterOpEngine := MakeClusterOpEngine(instructions, &certs) + clusterOpEngine := makeClusterOpEngine(instructions, &certs) // Give the instructions to the VClusterOpEngine to run - err = clusterOpEngine.Run(vcc.Log) + err = clusterOpEngine.run(vcc.Log) if err != nil { vcc.Log.Error(err, "fail to create database") return vdb, err @@ -469,7 +469,7 @@ func (vcc *VClusterCommands) produceCreateDBBootstrapInstructions( nmaVerticaVersionOp := makeNMAVerticaVersionOp(vcc.Log, hosts, true) // need username for https operations - err := options.ValidateUserName(vcc.Log) + err := options.validateUserName(vcc.Log) if err != nil { return instructions, err } diff --git a/vclusterops/drop_db.go b/vclusterops/drop_db.go index 62f12c8..10f6334 100644 --- a/vclusterops/drop_db.go +++ b/vclusterops/drop_db.go @@ -32,7 +32,7 @@ type VDropDatabaseOptions struct { func VDropDatabaseOptionsFactory() VDropDatabaseOptions { opt := VDropDatabaseOptions{} // set default values to the params - opt.SetDefaultValues() + opt.setDefaultValues() return opt } @@ -48,7 +48,7 @@ func (options *VDropDatabaseOptions) AnalyzeOptions() error { return nil } -func (options *VDropDatabaseOptions) ValidateAnalyzeOptions() error { +func (options *VDropDatabaseOptions) validateAnalyzeOptions() error { if *options.DBName == "" { return fmt.Errorf("database name must be provided") } @@ -62,7 +62,7 @@ func (vcc *VClusterCommands) VDropDatabase(options *VDropDatabaseOptions) error * - Give the instructions to the VClusterOpEngine to run */ - err := options.ValidateAnalyzeOptions() + err := options.validateAnalyzeOptions() if err != nil { return err } @@ -89,7 +89,7 @@ func (vcc *VClusterCommands) VDropDatabase(options *VDropDatabaseOptions) error if err != nil { return err } - err = vdb.SetFromClusterConfig(*options.DBName, &clusterConfig) + err = vdb.setFromClusterConfig(*options.DBName, &clusterConfig) if err != nil { return err } @@ -102,10 +102,10 @@ func (vcc *VClusterCommands) VDropDatabase(options *VDropDatabaseOptions) error // create a VClusterOpEngine, and add certs to the engine certs := HTTPSCerts{key: options.Key, cert: options.Cert, caCert: options.CaCert} - clusterOpEngine := MakeClusterOpEngine(instructions, &certs) + clusterOpEngine := makeClusterOpEngine(instructions, &certs) // give the instructions to the VClusterOpEngine to run - runError := clusterOpEngine.Run(vcc.Log) + runError := clusterOpEngine.run(vcc.Log) if runError != nil { return fmt.Errorf("fail to drop database: %w", runError) } @@ -136,7 +136,7 @@ func (vcc *VClusterCommands) produceDropDBInstructions(vdb *VCoordinationDatabas usePassword := false if options.Password != nil { usePassword = true - err := options.ValidateUserName(vcc.Log) + err := options.validateUserName(vcc.Log) if err != nil { return instructions, err } diff --git a/vclusterops/fetch_node_state.go b/vclusterops/fetch_node_state.go index 7570fbc..2dcfcb6 100644 --- a/vclusterops/fetch_node_state.go +++ b/vclusterops/fetch_node_state.go @@ -13,7 +13,7 @@ type VFetchNodeStateOptions struct { func VFetchNodeStateOptionsFactory() VFetchNodeStateOptions { opt := VFetchNodeStateOptions{} // set default values to the params - opt.SetDefaultValues() + opt.setDefaultValues() return opt } @@ -40,7 +40,7 @@ func (options *VFetchNodeStateOptions) analyzeOptions() error { return nil } -func (options *VFetchNodeStateOptions) ValidateAnalyzeOptions(vcc *VClusterCommands) error { +func (options *VFetchNodeStateOptions) validateAnalyzeOptions(vcc *VClusterCommands) error { if err := options.validateParseOptions(vcc); err != nil { return err } @@ -55,7 +55,7 @@ func (vcc *VClusterCommands) VFetchNodeState(options *VFetchNodeStateOptions) ([ * - Give the instructions to the VClusterOpEngine to run */ - err := options.ValidateAnalyzeOptions(vcc) + err := options.validateAnalyzeOptions(vcc) if err != nil { return nil, err } @@ -70,10 +70,10 @@ func (vcc *VClusterCommands) VFetchNodeState(options *VFetchNodeStateOptions) ([ // create a VClusterOpEngine, and add certs to the engine certs := HTTPSCerts{key: options.Key, cert: options.Cert, caCert: options.CaCert} - clusterOpEngine := MakeClusterOpEngine(instructions, &certs) + clusterOpEngine := makeClusterOpEngine(instructions, &certs) // Give the instructions to the VClusterOpEngine to run - runError := clusterOpEngine.Run(vcc.Log) + runError := clusterOpEngine.run(vcc.Log) nodeStates := clusterOpEngine.execContext.nodesInfo return nodeStates, runError @@ -91,7 +91,7 @@ func (vcc *VClusterCommands) produceListAllNodesInstructions(options *VFetchNode usePassword := false if options.Password != nil { usePassword = true - err := options.ValidateUserName(vcc.Log) + err := options.validateUserName(vcc.Log) if err != nil { return instructions, err } diff --git a/vclusterops/helpers.go b/vclusterops/helpers.go index b997023..a81291f 100644 --- a/vclusterops/helpers.go +++ b/vclusterops/helpers.go @@ -102,7 +102,7 @@ func getInitiatorHost(primaryUpNodes, hostsToSkip []string) (string, error) { // getVDBFromRunningDB will retrieve db configurations by calling https endpoints of a running db func (vcc *VClusterCommands) getVDBFromRunningDB(vdb *VCoordinationDatabase, options *DatabaseOptions) error { - err := options.SetUsePassword(vcc.Log) + err := options.setUsePassword(vcc.Log) if err != nil { return fmt.Errorf("fail to set userPassword while retrieving database configurations, %w", err) } @@ -123,8 +123,8 @@ func (vcc *VClusterCommands) getVDBFromRunningDB(vdb *VCoordinationDatabase, opt instructions = append(instructions, &httpsGetNodesInfoOp, &httpsGetClusterInfoOp) certs := HTTPSCerts{key: options.Key, cert: options.Cert, caCert: options.CaCert} - clusterOpEngine := MakeClusterOpEngine(instructions, &certs) - err = clusterOpEngine.Run(vcc.Log) + clusterOpEngine := makeClusterOpEngine(instructions, &certs) + err = clusterOpEngine.run(vcc.Log) if err != nil { return fmt.Errorf("fail to retrieve database configurations, %w", err) } diff --git a/vclusterops/http_adapter.go b/vclusterops/http_adapter.go index 3f0ea71..a6b80aa 100644 --- a/vclusterops/http_adapter.go +++ b/vclusterops/http_adapter.go @@ -37,7 +37,7 @@ type HTTPAdapter struct { host string } -func MakeHTTPAdapter(log vlog.Printer) HTTPAdapter { +func makeHTTPAdapter(log vlog.Printer) HTTPAdapter { newHTTPAdapter := HTTPAdapter{} newHTTPAdapter.name = "HTTPAdapter" newHTTPAdapter.log = log.WithName(newHTTPAdapter.name) diff --git a/vclusterops/http_request.go b/vclusterops/http_request.go index 3621107..79116b3 100644 --- a/vclusterops/http_request.go +++ b/vclusterops/http_request.go @@ -37,12 +37,12 @@ type HTTPSCerts struct { caCert string } -func (req *HostHTTPRequest) BuildNMAEndpoint(url string) { +func (req *HostHTTPRequest) buildNMAEndpoint(url string) { req.IsNMACommand = true req.Endpoint = NMACurVersion + url } -func (req *HostHTTPRequest) BuildHTTPSEndpoint(url string) { +func (req *HostHTTPRequest) buildHTTPSEndpoint(url string) { req.IsNMACommand = false req.Endpoint = HTTPCurVersion + url } diff --git a/vclusterops/http_request_dispatcher.go b/vclusterops/http_request_dispatcher.go index 1a20d3c..15c0f9e 100644 --- a/vclusterops/http_request_dispatcher.go +++ b/vclusterops/http_request_dispatcher.go @@ -22,7 +22,7 @@ type HTTPRequestDispatcher struct { pool AdapterPool } -func MakeHTTPRequestDispatcher(log vlog.Printer) HTTPRequestDispatcher { +func makeHTTPRequestDispatcher(log vlog.Printer) HTTPRequestDispatcher { newHTTPRequestDispatcher := HTTPRequestDispatcher{} newHTTPRequestDispatcher.name = "HTTPRequestDispatcher" newHTTPRequestDispatcher.log = log.WithName(newHTTPRequestDispatcher.name) @@ -31,11 +31,11 @@ func MakeHTTPRequestDispatcher(log vlog.Printer) HTTPRequestDispatcher { } // set up the pool connection for each host -func (dispatcher *HTTPRequestDispatcher) Setup(hosts []string) { +func (dispatcher *HTTPRequestDispatcher) setup(hosts []string) { dispatcher.pool = getPoolInstance(dispatcher.log) for _, host := range hosts { - adapter := MakeHTTPAdapter(dispatcher.log) + adapter := makeHTTPAdapter(dispatcher.log) adapter.host = host dispatcher.pool.connections[host] = &adapter } diff --git a/vclusterops/https_add_subcluster_op.go b/vclusterops/https_add_subcluster_op.go index decb5f9..441ee01 100644 --- a/vclusterops/https_add_subcluster_op.go +++ b/vclusterops/https_add_subcluster_op.go @@ -82,7 +82,7 @@ func (op *HTTPSAddSubclusterOp) setupClusterHTTPRequest(hosts []string) error { for _, host := range hosts { httpRequest := HostHTTPRequest{} httpRequest.Method = PostMethod - httpRequest.BuildHTTPSEndpoint("subclusters/" + op.scName) + httpRequest.buildHTTPSEndpoint("subclusters/" + op.scName) if op.useHTTPPassword { httpRequest.Password = op.httpsPassword httpRequest.Username = op.userName @@ -104,7 +104,7 @@ func (op *HTTPSAddSubclusterOp) prepare(execContext *OpEngineExecContext) error if err != nil { return err } - execContext.dispatcher.Setup(hosts) + execContext.dispatcher.setup(hosts) return op.setupClusterHTTPRequest(hosts) } @@ -123,7 +123,7 @@ func (op *HTTPSAddSubclusterOp) processResult(_ *OpEngineExecContext) error { for host, result := range op.clusterHTTPRequest.ResultCollection { op.logResponse(host, result) - if result.IsUnauthorizedRequest() { + if result.isUnauthorizedRequest() { // skip checking response from other nodes because we will get the same error there return result.err } diff --git a/vclusterops/https_check_db_running.go b/vclusterops/https_check_db_running_op.go similarity index 98% rename from vclusterops/https_check_db_running.go rename to vclusterops/https_check_db_running_op.go index 2911a2b..7bfc089 100644 --- a/vclusterops/https_check_db_running.go +++ b/vclusterops/https_check_db_running_op.go @@ -79,7 +79,7 @@ func (op *HTTPCheckRunningDBOp) setupClusterHTTPRequest(hosts []string) error { for _, host := range hosts { httpRequest := HostHTTPRequest{} httpRequest.Method = GetMethod - httpRequest.BuildHTTPSEndpoint("nodes") + httpRequest.buildHTTPSEndpoint("nodes") if op.useHTTPPassword { httpRequest.Password = op.httpsPassword httpRequest.Username = op.userName @@ -95,7 +95,7 @@ func (op *HTTPCheckRunningDBOp) logPrepare() { } func (op *HTTPCheckRunningDBOp) prepare(execContext *OpEngineExecContext) error { - execContext.dispatcher.Setup(op.hosts) + execContext.dispatcher.setup(op.hosts) return op.setupClusterHTTPRequest(op.hosts) } @@ -173,7 +173,7 @@ func (op *HTTPCheckRunningDBOp) processResult(_ *OpEngineExecContext) error { for host, result := range op.clusterHTTPRequest.ResultCollection { resSummaryStr := SuccessResult // VER-87303: it's possible that there's a DB running with a different password - if !result.IsHTTPRunning() { + if !result.isHTTPRunning() { resSummaryStr = FailureResult } op.log.PrintInfo("[%s] result from host %s summary %s, details: %+v.", @@ -182,7 +182,7 @@ func (op *HTTPCheckRunningDBOp) processResult(_ *OpEngineExecContext) error { if !result.isPassing() { allErrs = errors.Join(allErrs, result.err) } - if result.isFailing() && !result.IsHTTPRunning() { + if result.isFailing() && !result.isHTTPRunning() { downHosts[host] = true continue } else if result.isException() { diff --git a/vclusterops/https_check_node_state_op.go b/vclusterops/https_check_node_state_op.go index 7852142..bf05855 100644 --- a/vclusterops/https_check_node_state_op.go +++ b/vclusterops/https_check_node_state_op.go @@ -56,7 +56,7 @@ func (op *HTTPCheckNodeStateOp) setupClusterHTTPRequest(hosts []string) error { for _, host := range hosts { httpRequest := HostHTTPRequest{} httpRequest.Method = GetMethod - httpRequest.BuildHTTPSEndpoint("nodes") + httpRequest.buildHTTPSEndpoint("nodes") if op.useHTTPPassword { httpRequest.Password = op.httpsPassword httpRequest.Username = op.userName @@ -68,7 +68,7 @@ func (op *HTTPCheckNodeStateOp) setupClusterHTTPRequest(hosts []string) error { } func (op *HTTPCheckNodeStateOp) prepare(execContext *OpEngineExecContext) error { - execContext.dispatcher.Setup(op.hosts) + execContext.dispatcher.setup(op.hosts) return op.setupClusterHTTPRequest(op.hosts) } @@ -88,7 +88,7 @@ func (op *HTTPCheckNodeStateOp) processResult(execContext *OpEngineExecContext) for host, result := range op.clusterHTTPRequest.ResultCollection { op.logResponse(host, result) - if result.IsUnauthorizedRequest() { + if result.isUnauthorizedRequest() { op.log.PrintError("[%s] unauthorized request: %s", op.name, result.content) // return here because we assume that // we will get the same error across other nodes @@ -98,7 +98,7 @@ func (op *HTTPCheckNodeStateOp) processResult(execContext *OpEngineExecContext) if !result.isPassing() { // for any error, we continue to the next node - if result.IsInternalError() { + if result.isInternalError() { op.log.PrintError("[%s] internal error of the /nodes endpoint: %s", op.name, result.content) // At internal error originated from the server, so its a // response, just not a successful one. diff --git a/vclusterops/https_check_subcluster_op.go b/vclusterops/https_check_subcluster_op.go index 35b399a..974db5d 100644 --- a/vclusterops/https_check_subcluster_op.go +++ b/vclusterops/https_check_subcluster_op.go @@ -55,7 +55,7 @@ func (op *HTTPSCheckSubclusterOp) setupClusterHTTPRequest(hosts []string) error for _, host := range hosts { httpRequest := HostHTTPRequest{} httpRequest.Method = GetMethod - httpRequest.BuildHTTPSEndpoint("subclusters/" + op.scName) + httpRequest.buildHTTPSEndpoint("subclusters/" + op.scName) if op.useHTTPPassword { httpRequest.Password = op.httpsPassword httpRequest.Username = op.userName @@ -70,7 +70,7 @@ func (op *HTTPSCheckSubclusterOp) prepare(execContext *OpEngineExecContext) erro if len(execContext.upHosts) == 0 { return fmt.Errorf(`[%s] Cannot find any up hosts in OpEngineExecContext`, op.name) } - execContext.dispatcher.Setup(execContext.upHosts) + execContext.dispatcher.setup(execContext.upHosts) return op.setupClusterHTTPRequest(execContext.upHosts) } @@ -96,7 +96,7 @@ func (op *HTTPSCheckSubclusterOp) processResult(_ *OpEngineExecContext) error { for host, result := range op.clusterHTTPRequest.ResultCollection { op.logResponse(host, result) - if result.IsUnauthorizedRequest() { + if result.isUnauthorizedRequest() { // skip checking response from other nodes because we will get the same error there return result.err } diff --git a/vclusterops/https_create_cluster_depot_op.go b/vclusterops/https_create_cluster_depot_op.go index 39034db..4d3b532 100644 --- a/vclusterops/https_create_cluster_depot_op.go +++ b/vclusterops/https_create_cluster_depot_op.go @@ -66,7 +66,7 @@ func (op *HTTPSCreateDepotOp) setupClusterHTTPRequest(hosts []string) error { for _, host := range hosts { httpRequest := HostHTTPRequest{} httpRequest.Method = PostMethod - httpRequest.BuildHTTPSEndpoint("cluster/depot") + httpRequest.buildHTTPSEndpoint("cluster/depot") if op.useHTTPPassword { httpRequest.Password = op.httpsPassword httpRequest.Username = op.userName @@ -79,7 +79,7 @@ func (op *HTTPSCreateDepotOp) setupClusterHTTPRequest(hosts []string) error { } func (op *HTTPSCreateDepotOp) prepare(execContext *OpEngineExecContext) error { - execContext.dispatcher.Setup(op.hosts) + execContext.dispatcher.setup(op.hosts) return op.setupClusterHTTPRequest(op.hosts) } diff --git a/vclusterops/https_create_node_op.go b/vclusterops/https_create_node_op.go index d6ef03a..f7322a6 100644 --- a/vclusterops/https_create_node_op.go +++ b/vclusterops/https_create_node_op.go @@ -56,7 +56,7 @@ func (op *HTTPSCreateNodeOp) setupClusterHTTPRequest(hosts []string) error { httpRequest.Method = PostMethod // note that this will be updated in Prepare() // because the endpoint only accept parameters in query - httpRequest.BuildHTTPSEndpoint("nodes") + httpRequest.buildHTTPSEndpoint("nodes") if op.useHTTPPassword { httpRequest.Password = op.httpsPassword httpRequest.Username = op.userName @@ -85,7 +85,7 @@ func (op *HTTPSCreateNodeOp) prepare(execContext *OpEngineExecContext) error { return err } - execContext.dispatcher.Setup(op.hosts) + execContext.dispatcher.setup(op.hosts) return op.setupClusterHTTPRequest(op.hosts) } diff --git a/vclusterops/https_create_nodes_depot_op.go b/vclusterops/https_create_nodes_depot_op.go index 3760927..92d0a56 100644 --- a/vclusterops/https_create_nodes_depot_op.go +++ b/vclusterops/https_create_nodes_depot_op.go @@ -57,7 +57,7 @@ func (op *HTTPSCreateNodesDepotOp) setupClusterHTTPRequest(hosts []string) error httpRequest := HostHTTPRequest{} httpRequest.Method = PostMethod node := op.HostNodeMap[host] - httpRequest.BuildHTTPSEndpoint("nodes/" + node.Name + "/depot") + httpRequest.buildHTTPSEndpoint("nodes/" + node.Name + "/depot") if op.useHTTPPassword { httpRequest.Password = op.httpsPassword httpRequest.Username = op.userName @@ -73,7 +73,7 @@ func (op *HTTPSCreateNodesDepotOp) setupClusterHTTPRequest(hosts []string) error } func (op *HTTPSCreateNodesDepotOp) prepare(execContext *OpEngineExecContext) error { - execContext.dispatcher.Setup(op.hosts) + execContext.dispatcher.setup(op.hosts) return op.setupClusterHTTPRequest(op.hosts) } diff --git a/vclusterops/https_drop_node_op.go b/vclusterops/https_drop_node_op.go index 2854447..6c45699 100644 --- a/vclusterops/https_drop_node_op.go +++ b/vclusterops/https_drop_node_op.go @@ -60,7 +60,7 @@ func (op *HTTPSDropNodeOp) setupClusterHTTPRequest(hosts []string) error { for _, host := range hosts { httpRequest := HostHTTPRequest{} httpRequest.Method = PostMethod - httpRequest.BuildHTTPSEndpoint("nodes/" + op.targetHost + "/drop") + httpRequest.buildHTTPSEndpoint("nodes/" + op.targetHost + "/drop") if op.useHTTPPassword { httpRequest.Password = op.httpsPassword httpRequest.Username = op.userName @@ -72,7 +72,7 @@ func (op *HTTPSDropNodeOp) setupClusterHTTPRequest(hosts []string) error { } func (op *HTTPSDropNodeOp) prepare(execContext *OpEngineExecContext) error { - execContext.dispatcher.Setup(op.hosts) + execContext.dispatcher.setup(op.hosts) return op.setupClusterHTTPRequest(op.hosts) } @@ -90,7 +90,7 @@ func (op *HTTPSDropNodeOp) processResult(_ *OpEngineExecContext) error { for host, result := range op.clusterHTTPRequest.ResultCollection { op.logResponse(host, result) - if !result.IsSuccess() { + if !result.isSuccess() { allErrs = errors.Join(allErrs, result.err) continue } diff --git a/vclusterops/https_drop_subcluster_op.go b/vclusterops/https_drop_subcluster_op.go index d2cd9f7..bee229e 100644 --- a/vclusterops/https_drop_subcluster_op.go +++ b/vclusterops/https_drop_subcluster_op.go @@ -53,7 +53,7 @@ func (op *httpsDropSubclusterOp) setupClusterHTTPRequest(hosts []string) error { for _, host := range hosts { httpRequest := HostHTTPRequest{} httpRequest.Method = PostMethod - httpRequest.BuildHTTPSEndpoint("subclusters/" + op.scName + "/drop") + httpRequest.buildHTTPSEndpoint("subclusters/" + op.scName + "/drop") if op.useHTTPPassword { httpRequest.Password = op.httpsPassword httpRequest.Username = op.userName @@ -66,7 +66,7 @@ func (op *httpsDropSubclusterOp) setupClusterHTTPRequest(hosts []string) error { } func (op *httpsDropSubclusterOp) prepare(execContext *OpEngineExecContext) error { - execContext.dispatcher.Setup(op.hosts) + execContext.dispatcher.setup(op.hosts) return op.setupClusterHTTPRequest(op.hosts) } @@ -85,7 +85,7 @@ func (op *httpsDropSubclusterOp) processResult(_ *OpEngineExecContext) error { for host, result := range op.clusterHTTPRequest.ResultCollection { op.logResponse(host, result) - if result.IsUnauthorizedRequest() { + if result.isUnauthorizedRequest() { return fmt.Errorf("[%s] wrong password/certificate for https service on host %s", op.name, host) } diff --git a/vclusterops/https_find_subcluster_op.go b/vclusterops/https_find_subcluster_op.go index a4b64bf..d4fffdb 100644 --- a/vclusterops/https_find_subcluster_op.go +++ b/vclusterops/https_find_subcluster_op.go @@ -54,7 +54,7 @@ func (op *HTTPSFindSubclusterOp) setupClusterHTTPRequest(hosts []string) error { for _, host := range hosts { httpRequest := HostHTTPRequest{} httpRequest.Method = GetMethod - httpRequest.BuildHTTPSEndpoint("subclusters") + httpRequest.buildHTTPSEndpoint("subclusters") if op.useHTTPPassword { httpRequest.Password = op.httpsPassword httpRequest.Username = op.userName @@ -66,7 +66,7 @@ func (op *HTTPSFindSubclusterOp) setupClusterHTTPRequest(hosts []string) error { } func (op *HTTPSFindSubclusterOp) prepare(execContext *OpEngineExecContext) error { - execContext.dispatcher.Setup(op.hosts) + execContext.dispatcher.setup(op.hosts) return op.setupClusterHTTPRequest(op.hosts) } @@ -95,7 +95,7 @@ func (op *HTTPSFindSubclusterOp) processResult(execContext *OpEngineExecContext) for host, result := range op.clusterHTTPRequest.ResultCollection { op.logResponse(host, result) - if result.IsUnauthorizedRequest() { + if result.isUnauthorizedRequest() { // skip checking response from other nodes because we will get the same error there return result.err } diff --git a/vclusterops/https_get_cluster_info_op.go b/vclusterops/https_get_cluster_info_op.go index 28b95cf..51c9589 100644 --- a/vclusterops/https_get_cluster_info_op.go +++ b/vclusterops/https_get_cluster_info_op.go @@ -57,7 +57,7 @@ func (op *httpsGetClusterInfoOp) setupClusterHTTPRequest(hosts []string) error { for _, host := range hosts { httpRequest := HostHTTPRequest{} httpRequest.Method = GetMethod - httpRequest.BuildHTTPSEndpoint("cluster") + httpRequest.buildHTTPSEndpoint("cluster") if op.useHTTPPassword { httpRequest.Password = op.httpsPassword httpRequest.Username = op.userName @@ -70,7 +70,7 @@ func (op *httpsGetClusterInfoOp) setupClusterHTTPRequest(hosts []string) error { } func (op *httpsGetClusterInfoOp) prepare(execContext *OpEngineExecContext) error { - execContext.dispatcher.Setup(op.hosts) + execContext.dispatcher.setup(op.hosts) return op.setupClusterHTTPRequest(op.hosts) } @@ -94,7 +94,7 @@ func (op *httpsGetClusterInfoOp) processResult(_ *OpEngineExecContext) error { for host, result := range op.clusterHTTPRequest.ResultCollection { op.logResponse(host, result) - if result.IsUnauthorizedRequest() { + if result.isUnauthorizedRequest() { return fmt.Errorf("[%s] wrong password/certificate for https service on host %s", op.name, host) } diff --git a/vclusterops/https_get_nodes_info_op.go b/vclusterops/https_get_nodes_info_op.go index e678e7a..eb407b1 100644 --- a/vclusterops/https_get_nodes_info_op.go +++ b/vclusterops/https_get_nodes_info_op.go @@ -51,7 +51,7 @@ func (op *httpsGetNodesInfoOp) setupClusterHTTPRequest(hosts []string) error { for _, host := range hosts { httpRequest := HostHTTPRequest{} httpRequest.Method = GetMethod - httpRequest.BuildHTTPSEndpoint("nodes") + httpRequest.buildHTTPSEndpoint("nodes") if op.useHTTPPassword { httpRequest.Password = op.httpsPassword httpRequest.Username = op.userName @@ -64,7 +64,7 @@ func (op *httpsGetNodesInfoOp) setupClusterHTTPRequest(hosts []string) error { } func (op *httpsGetNodesInfoOp) prepare(execContext *OpEngineExecContext) error { - execContext.dispatcher.Setup(op.hosts) + execContext.dispatcher.setup(op.hosts) return op.setupClusterHTTPRequest(op.hosts) } @@ -82,7 +82,7 @@ func (op *httpsGetNodesInfoOp) processResult(_ *OpEngineExecContext) error { for host, result := range op.clusterHTTPRequest.ResultCollection { op.logResponse(host, result) - if result.IsUnauthorizedRequest() { + if result.isUnauthorizedRequest() { return fmt.Errorf("[%s] wrong password/certificate for https service on host %s", op.name, host) } diff --git a/vclusterops/https_get_up_nodes_op.go b/vclusterops/https_get_up_nodes_op.go index 2b68e2e..7217488 100644 --- a/vclusterops/https_get_up_nodes_op.go +++ b/vclusterops/https_get_up_nodes_op.go @@ -55,7 +55,7 @@ func (op *HTTPSGetUpNodesOp) setupClusterHTTPRequest(hosts []string) error { for _, host := range hosts { httpRequest := HostHTTPRequest{} httpRequest.Method = GetMethod - httpRequest.BuildHTTPSEndpoint("nodes") + httpRequest.buildHTTPSEndpoint("nodes") if op.useHTTPPassword { httpRequest.Password = op.httpsPassword httpRequest.Username = op.userName @@ -67,7 +67,7 @@ func (op *HTTPSGetUpNodesOp) setupClusterHTTPRequest(hosts []string) error { } func (op *HTTPSGetUpNodesOp) prepare(execContext *OpEngineExecContext) error { - execContext.dispatcher.Setup(op.hosts) + execContext.dispatcher.setup(op.hosts) return op.setupClusterHTTPRequest(op.hosts) } @@ -122,7 +122,7 @@ func (op *HTTPSGetUpNodesOp) processResult(execContext *OpEngineExecContext) err // We assume all the hosts are in the same db cluster // If any of the hosts reject the request, other hosts will reject the request too // Do not try other hosts when we see a http failure - if result.isFailing() && result.IsHTTPRunning() { + if result.isFailing() && result.isHTTPRunning() { exceptionHosts = append(exceptionHosts, host) continue } diff --git a/vclusterops/https_install_packages_op.go b/vclusterops/https_install_packages_op.go index 5e085dd..c263a39 100644 --- a/vclusterops/https_install_packages_op.go +++ b/vclusterops/https_install_packages_op.go @@ -50,7 +50,7 @@ func (op *HTTPSInstallPackagesOp) setupClusterHTTPRequest(hosts []string) error for _, host := range hosts { httpRequest := HostHTTPRequest{} httpRequest.Method = PostMethod - httpRequest.BuildHTTPSEndpoint("packages") + httpRequest.buildHTTPSEndpoint("packages") if op.useHTTPPassword { httpRequest.Password = op.httpsPassword httpRequest.Username = op.userName @@ -62,7 +62,7 @@ func (op *HTTPSInstallPackagesOp) setupClusterHTTPRequest(hosts []string) error } func (op *HTTPSInstallPackagesOp) prepare(execContext *OpEngineExecContext) error { - execContext.dispatcher.Setup(op.hosts) + execContext.dispatcher.setup(op.hosts) return op.setupClusterHTTPRequest(op.hosts) } diff --git a/vclusterops/https_mark_design_ksafe_op.go b/vclusterops/https_mark_design_ksafe_op.go index b744993..12ffd66 100644 --- a/vclusterops/https_mark_design_ksafe_op.go +++ b/vclusterops/https_mark_design_ksafe_op.go @@ -68,7 +68,7 @@ func (op *HTTPSMarkDesignKSafeOp) setupClusterHTTPRequest(hosts []string) error for _, host := range hosts { httpRequest := HostHTTPRequest{} httpRequest.Method = PutMethod - httpRequest.BuildHTTPSEndpoint("cluster/k-safety") + httpRequest.buildHTTPSEndpoint("cluster/k-safety") if op.useHTTPPassword { httpRequest.Password = op.httpsPassword httpRequest.Username = op.userName @@ -81,7 +81,7 @@ func (op *HTTPSMarkDesignKSafeOp) setupClusterHTTPRequest(hosts []string) error } func (op *HTTPSMarkDesignKSafeOp) prepare(execContext *OpEngineExecContext) error { - execContext.dispatcher.Setup(op.hosts) + execContext.dispatcher.setup(op.hosts) return op.setupClusterHTTPRequest(op.hosts) } diff --git a/vclusterops/https_mark_nodes_ephemeral_op.go b/vclusterops/https_mark_nodes_ephemeral_op.go index 3b69e06..56f56ae 100644 --- a/vclusterops/https_mark_nodes_ephemeral_op.go +++ b/vclusterops/https_mark_nodes_ephemeral_op.go @@ -52,7 +52,7 @@ func (op *HTTPSMarkEphemeralNodeOp) setupClusterHTTPRequest(hosts []string) erro for _, host := range hosts { httpRequest := HostHTTPRequest{} httpRequest.Method = PostMethod - httpRequest.BuildHTTPSEndpoint("nodes/" + op.targetNodeName + "/ephemeral") + httpRequest.buildHTTPSEndpoint("nodes/" + op.targetNodeName + "/ephemeral") if op.useHTTPPassword { httpRequest.Password = op.httpsPassword httpRequest.Username = op.userName @@ -63,7 +63,7 @@ func (op *HTTPSMarkEphemeralNodeOp) setupClusterHTTPRequest(hosts []string) erro } func (op *HTTPSMarkEphemeralNodeOp) prepare(execContext *OpEngineExecContext) error { - execContext.dispatcher.Setup(op.hosts) + execContext.dispatcher.setup(op.hosts) return op.setupClusterHTTPRequest(op.hosts) } @@ -81,7 +81,7 @@ func (op *HTTPSMarkEphemeralNodeOp) processResult(_ *OpEngineExecContext) error for host, result := range op.clusterHTTPRequest.ResultCollection { op.logResponse(host, result) - if !result.IsSuccess() { + if !result.isSuccess() { allErrs = errors.Join(allErrs, result.err) continue } diff --git a/vclusterops/https_poll_node_state_op.go b/vclusterops/https_poll_node_state_op.go index 53c86d7..57fc696 100644 --- a/vclusterops/https_poll_node_state_op.go +++ b/vclusterops/https_poll_node_state_op.go @@ -116,7 +116,7 @@ func (op *HTTPSPollNodeStateOp) setupClusterHTTPRequest(hosts []string) error { httpRequest := HostHTTPRequest{} httpRequest.Method = GetMethod httpRequest.Timeout = httpRequestTimeoutSeconds - httpRequest.BuildHTTPSEndpoint("nodes/" + host) + httpRequest.buildHTTPSEndpoint("nodes/" + host) if op.useHTTPPassword { httpRequest.Password = op.httpsPassword httpRequest.Username = op.userName @@ -129,7 +129,7 @@ func (op *HTTPSPollNodeStateOp) setupClusterHTTPRequest(hosts []string) error { } func (op *HTTPSPollNodeStateOp) prepare(execContext *OpEngineExecContext) error { - execContext.dispatcher.Setup(op.hosts) + execContext.dispatcher.setup(op.hosts) return op.setupClusterHTTPRequest(op.hosts) } @@ -185,7 +185,7 @@ func (op *HTTPSPollNodeStateOp) shouldStopPolling() (bool, error) { // We don't need to wait until timeout to determine if all nodes are up or not. // If we find the wrong password for the HTTPS service on any hosts, we should fail immediately. // We also need to let user know to wait until all nodes are up - if result.IsPasswordAndCertificateError(op.log) { + if result.isPasswordAndCertificateError(op.log) { switch op.cmdType { case StartDBCmd, RestartNodeCmd: op.log.PrintError("[%s] The credentials are incorrect. 'Catalog Sync' will not be executed.", diff --git a/vclusterops/https_poll_node_state_op_test.go b/vclusterops/https_poll_node_state_op_test.go index 203cd64..d52b1fe 100644 --- a/vclusterops/https_poll_node_state_op_test.go +++ b/vclusterops/https_poll_node_state_op_test.go @@ -34,7 +34,7 @@ func TestTimeoutCase(t *testing.T) { instructions = append(instructions, &httpsPollNodeStateOp) certs := HTTPSCerts{} - clusterOpEngine := MakeClusterOpEngine(instructions, &certs) - err = clusterOpEngine.Run(vlog.Printer{}) + clusterOpEngine := makeClusterOpEngine(instructions, &certs) + err = clusterOpEngine.run(vlog.Printer{}) assert.ErrorContains(t, err, "[HTTPSPollNodeStateOp] cannot connect to host 192.0.2.1, please check if the host is still alive") } diff --git a/vclusterops/https_poll_subscription_state_op.go b/vclusterops/https_poll_subscription_state_op.go index e59c34b..ef92926 100644 --- a/vclusterops/https_poll_subscription_state_op.go +++ b/vclusterops/https_poll_subscription_state_op.go @@ -56,7 +56,7 @@ func (op *httpsPollSubscriptionStateOp) setupClusterHTTPRequest(hosts []string) httpRequest := HostHTTPRequest{} httpRequest.Method = GetMethod httpRequest.Timeout = httpRequestTimeoutSeconds - httpRequest.BuildHTTPSEndpoint("subscriptions") + httpRequest.buildHTTPSEndpoint("subscriptions") if op.useHTTPPassword { httpRequest.Password = op.httpsPassword httpRequest.Username = op.userName @@ -69,7 +69,7 @@ func (op *httpsPollSubscriptionStateOp) setupClusterHTTPRequest(hosts []string) } func (op *httpsPollSubscriptionStateOp) prepare(execContext *OpEngineExecContext) error { - execContext.dispatcher.Setup(op.hosts) + execContext.dispatcher.setup(op.hosts) return op.setupClusterHTTPRequest(op.hosts) } @@ -129,7 +129,7 @@ func (op *httpsPollSubscriptionStateOp) shouldStopPolling() (bool, error) { for host, result := range op.clusterHTTPRequest.ResultCollection { op.logResponse(host, result) - if result.IsPasswordAndCertificateError(op.log) { + if result.isPasswordAndCertificateError(op.log) { return true, fmt.Errorf("[%s] wrong password/certificate for https service on host %s", op.name, host) } diff --git a/vclusterops/https_re_ip_op.go b/vclusterops/https_re_ip_op.go index 47e2fdd..590233c 100644 --- a/vclusterops/https_re_ip_op.go +++ b/vclusterops/https_re_ip_op.go @@ -60,7 +60,7 @@ func (op *httpsReIPOp) setupClusterHTTPRequest(hosts []string) error { if !ok { return fmt.Errorf("[%s] cannot find node information for address %s", op.name, host) } - httpRequest.BuildHTTPSEndpoint("nodes/" + nodesInfo.NodeName + "/ip") + httpRequest.buildHTTPSEndpoint("nodes/" + nodesInfo.NodeName + "/ip") httpRequest.QueryParams = make(map[string]string) httpRequest.QueryParams["host"] = nodesInfo.TargetAddress httpRequest.QueryParams["control-host"] = nodesInfo.TargetControlAddress @@ -97,7 +97,7 @@ func (op *httpsReIPOp) prepare(execContext *OpEngineExecContext) error { // use up hosts to execute the HTTP re-IP endpoint op.upHosts = execContext.upHosts - execContext.dispatcher.Setup(op.upHosts) + execContext.dispatcher.setup(op.upHosts) return op.setupClusterHTTPRequest(op.nodeNamesList) } @@ -114,7 +114,7 @@ func (op *httpsReIPOp) processResult(_ *OpEngineExecContext) error { for host, result := range op.clusterHTTPRequest.ResultCollection { op.logResponse(host, result) - if result.IsUnauthorizedRequest() { + if result.isUnauthorizedRequest() { return fmt.Errorf("[%s] wrong password/certificate for https service on host %s", op.name, host) } diff --git a/vclusterops/https_rebalance_cluster_op.go b/vclusterops/https_rebalance_cluster_op.go index eb7e8a7..fe558e4 100644 --- a/vclusterops/https_rebalance_cluster_op.go +++ b/vclusterops/https_rebalance_cluster_op.go @@ -53,7 +53,7 @@ func (op *HTTPSRebalanceClusterOp) setupClusterHTTPRequest(hosts []string) error for _, host := range hosts { httpRequest := HostHTTPRequest{} httpRequest.Method = PostMethod - httpRequest.BuildHTTPSEndpoint("cluster/rebalance") + httpRequest.buildHTTPSEndpoint("cluster/rebalance") if op.useHTTPPassword { httpRequest.Password = op.httpsPassword httpRequest.Username = op.userName @@ -64,7 +64,7 @@ func (op *HTTPSRebalanceClusterOp) setupClusterHTTPRequest(hosts []string) error } func (op *HTTPSRebalanceClusterOp) prepare(execContext *OpEngineExecContext) error { - execContext.dispatcher.Setup(op.hosts) + execContext.dispatcher.setup(op.hosts) return op.setupClusterHTTPRequest(op.hosts) } @@ -82,11 +82,11 @@ func (op *HTTPSRebalanceClusterOp) processResult(_ *OpEngineExecContext) error { for host, result := range op.clusterHTTPRequest.ResultCollection { op.logResponse(host, result) - if result.IsUnauthorizedRequest() { + if result.isUnauthorizedRequest() { // skip checking response from other nodes because we will get the same error there return result.err } - if !result.IsSuccess() { + if !result.isSuccess() { allErrs = errors.Join(allErrs, result.err) // try processing other hosts' responses when the current host has some server errors continue diff --git a/vclusterops/https_rebalance_subcluster_shards_op.go b/vclusterops/https_rebalance_subcluster_shards_op.go index e53b679..2e07fb5 100644 --- a/vclusterops/https_rebalance_subcluster_shards_op.go +++ b/vclusterops/https_rebalance_subcluster_shards_op.go @@ -56,7 +56,7 @@ func (op *HTTPSRebalanceSubclusterShardsOp) setupClusterHTTPRequest(hosts []stri for _, host := range hosts { httpRequest := HostHTTPRequest{} httpRequest.Method = PostMethod - httpRequest.BuildHTTPSEndpoint("subclusters/" + op.scName + "/rebalance") + httpRequest.buildHTTPSEndpoint("subclusters/" + op.scName + "/rebalance") if op.useHTTPPassword { httpRequest.Password = op.httpsPassword httpRequest.Username = op.userName @@ -76,7 +76,7 @@ func (op *HTTPSRebalanceSubclusterShardsOp) prepare(execContext *OpEngineExecCon op.scName = execContext.defaultSCName } - execContext.dispatcher.Setup(op.hosts) + execContext.dispatcher.setup(op.hosts) return op.setupClusterHTTPRequest(op.hosts) } @@ -95,7 +95,7 @@ func (op *HTTPSRebalanceSubclusterShardsOp) processResult(_ *OpEngineExecContext for host, result := range op.clusterHTTPRequest.ResultCollection { op.logResponse(host, result) - if result.IsUnauthorizedRequest() { + if result.isUnauthorizedRequest() { // skip checking response from other nodes because we will get the same error there return result.err } diff --git a/vclusterops/https_reload_spread_op.go b/vclusterops/https_reload_spread_op.go index b036317..5524cd0 100644 --- a/vclusterops/https_reload_spread_op.go +++ b/vclusterops/https_reload_spread_op.go @@ -55,7 +55,7 @@ func (op *HTTPSReloadSpreadOp) setupClusterHTTPRequest(hosts []string) error { for _, host := range hosts { httpRequest := HostHTTPRequest{} httpRequest.Method = PostMethod - httpRequest.BuildHTTPSEndpoint("config/spread/reload") + httpRequest.buildHTTPSEndpoint("config/spread/reload") if op.useHTTPPassword { httpRequest.Password = op.httpsPassword httpRequest.Username = op.userName @@ -71,7 +71,7 @@ func (op *HTTPSReloadSpreadOp) prepare(execContext *OpEngineExecContext) error { if len(op.hosts) == 0 { op.hosts = execContext.upHosts } - execContext.dispatcher.Setup(op.hosts) + execContext.dispatcher.setup(op.hosts) return op.setupClusterHTTPRequest(op.hosts) } diff --git a/vclusterops/https_spread_remove_node_op.go b/vclusterops/https_spread_remove_node_op.go index 1193122..b3ad346 100644 --- a/vclusterops/https_spread_remove_node_op.go +++ b/vclusterops/https_spread_remove_node_op.go @@ -56,7 +56,7 @@ func (op *HTTPSSpreadRemoveNodeOp) setupClusterHTTPRequest(hosts []string) error for _, host := range hosts { httpRequest := HostHTTPRequest{} httpRequest.Method = PostMethod - httpRequest.BuildHTTPSEndpoint("config/spread/remove") + httpRequest.buildHTTPSEndpoint("config/spread/remove") if op.useHTTPPassword { httpRequest.Password = op.httpsPassword httpRequest.Username = op.userName @@ -68,7 +68,7 @@ func (op *HTTPSSpreadRemoveNodeOp) setupClusterHTTPRequest(hosts []string) error } func (op *HTTPSSpreadRemoveNodeOp) prepare(execContext *OpEngineExecContext) error { - execContext.dispatcher.Setup(op.hosts) + execContext.dispatcher.setup(op.hosts) return op.setupClusterHTTPRequest(op.hosts) } diff --git a/vclusterops/https_startup_command_op.go b/vclusterops/https_startup_command_op.go index 0598955..a965276 100644 --- a/vclusterops/https_startup_command_op.go +++ b/vclusterops/https_startup_command_op.go @@ -55,7 +55,7 @@ func (op *httpsStartUpCommandOp) setupClusterHTTPRequest(hosts []string) error { httpRequest := HostHTTPRequest{} httpRequest.Method = GetMethod - httpRequest.BuildHTTPSEndpoint("startup/commands") + httpRequest.buildHTTPSEndpoint("startup/commands") if op.useHTTPPassword { httpRequest.Password = op.httpsPassword @@ -78,7 +78,7 @@ func (op *httpsStartUpCommandOp) prepare(execContext *OpEngineExecContext) error } } op.hosts = primaryUpHosts - execContext.dispatcher.Setup(op.hosts) + execContext.dispatcher.setup(op.hosts) return op.setupClusterHTTPRequest(op.hosts) } @@ -96,7 +96,7 @@ func (op *httpsStartUpCommandOp) processResult(execContext *OpEngineExecContext) for host, result := range op.clusterHTTPRequest.ResultCollection { op.logResponse(host, result) - if result.IsUnauthorizedRequest() { + if result.isUnauthorizedRequest() { return fmt.Errorf("[%s] wrong password/certificate for https service on host %s", op.name, host) } diff --git a/vclusterops/https_stop_db_op.go b/vclusterops/https_stop_db_op.go index 7735af2..a28dd1c 100644 --- a/vclusterops/https_stop_db_op.go +++ b/vclusterops/https_stop_db_op.go @@ -59,7 +59,7 @@ func (op *HTTPSStopDBOp) setupClusterHTTPRequest(hosts []string) error { for _, host := range hosts { httpRequest := HostHTTPRequest{} httpRequest.Method = PostMethod - httpRequest.BuildHTTPSEndpoint("cluster/shutdown") + httpRequest.buildHTTPSEndpoint("cluster/shutdown") if op.useHTTPPassword { httpRequest.Password = op.httpsPassword httpRequest.Username = op.userName @@ -77,7 +77,7 @@ func (op *HTTPSStopDBOp) prepare(execContext *OpEngineExecContext) error { } // use first up host to execute https post request hosts := []string{execContext.upHosts[0]} - execContext.dispatcher.Setup(hosts) + execContext.dispatcher.setup(hosts) return op.setupClusterHTTPRequest(hosts) } diff --git a/vclusterops/https_sync_catalog_op.go b/vclusterops/https_sync_catalog_op.go index d2c31d0..2321e62 100644 --- a/vclusterops/https_sync_catalog_op.go +++ b/vclusterops/https_sync_catalog_op.go @@ -56,7 +56,7 @@ func (op *HTTPSSyncCatalogOp) setupClusterHTTPRequest(hosts []string) error { for _, host := range hosts { httpRequest := HostHTTPRequest{} httpRequest.Method = PostMethod - httpRequest.BuildHTTPSEndpoint("cluster/catalog/sync") + httpRequest.buildHTTPSEndpoint("cluster/catalog/sync") httpRequest.QueryParams = make(map[string]string) httpRequest.QueryParams["retry-count"] = strconv.Itoa(util.DefaultRetryCount) if op.useHTTPPassword { @@ -78,7 +78,7 @@ func (op *HTTPSSyncCatalogOp) prepare(execContext *OpEngineExecContext) error { // use first up host to execute https post request op.hosts = []string{execContext.upHosts[0]} } - execContext.dispatcher.Setup(op.hosts) + execContext.dispatcher.setup(op.hosts) return op.setupClusterHTTPRequest(op.hosts) } diff --git a/vclusterops/nma_bootstrap_catalog_op.go b/vclusterops/nma_bootstrap_catalog_op.go index 8db29ab..0dbb3ea 100644 --- a/vclusterops/nma_bootstrap_catalog_op.go +++ b/vclusterops/nma_bootstrap_catalog_op.go @@ -152,7 +152,7 @@ func (op *NMABootstrapCatalogOp) setupClusterHTTPRequest(hosts []string) error { for _, host := range hosts { httpRequest := HostHTTPRequest{} httpRequest.Method = PostMethod - httpRequest.BuildNMAEndpoint("catalog/bootstrap") + httpRequest.buildNMAEndpoint("catalog/bootstrap") httpRequest.RequestData = op.marshaledRequestBodyMap[host] op.clusterHTTPRequest.RequestCollection[host] = httpRequest } @@ -166,7 +166,7 @@ func (op *NMABootstrapCatalogOp) prepare(execContext *OpEngineExecContext) error return err } - execContext.dispatcher.Setup(op.hosts) + execContext.dispatcher.setup(op.hosts) return op.setupClusterHTTPRequest(op.hosts) } diff --git a/vclusterops/nma_delete_dir_op.go b/vclusterops/nma_delete_dir_op.go index f99b4d4..160b781 100644 --- a/vclusterops/nma_delete_dir_op.go +++ b/vclusterops/nma_delete_dir_op.go @@ -81,7 +81,7 @@ func (op *NMADeleteDirectoriesOp) setupClusterHTTPRequest(hosts []string) error for _, host := range hosts { httpRequest := HostHTTPRequest{} httpRequest.Method = PostMethod - httpRequest.BuildNMAEndpoint("directories/delete") + httpRequest.buildNMAEndpoint("directories/delete") httpRequest.RequestData = op.hostRequestBodyMap[host] op.clusterHTTPRequest.RequestCollection[host] = httpRequest } @@ -90,7 +90,7 @@ func (op *NMADeleteDirectoriesOp) setupClusterHTTPRequest(hosts []string) error } func (op *NMADeleteDirectoriesOp) prepare(execContext *OpEngineExecContext) error { - execContext.dispatcher.Setup(op.hosts) + execContext.dispatcher.setup(op.hosts) return op.setupClusterHTTPRequest(op.hosts) } diff --git a/vclusterops/nma_download_config.go b/vclusterops/nma_download_config.go index 386e578..eda5ce7 100644 --- a/vclusterops/nma_download_config.go +++ b/vclusterops/nma_download_config.go @@ -54,7 +54,7 @@ func (op *NMADownloadConfigOp) setupClusterHTTPRequest(hosts []string) error { for _, host := range hosts { httpRequest := HostHTTPRequest{} httpRequest.Method = GetMethod - httpRequest.BuildNMAEndpoint(op.endpoint) + httpRequest.buildNMAEndpoint(op.endpoint) catalogPath, ok := op.catalogPathMap[host] if !ok { @@ -112,7 +112,7 @@ func (op *NMADownloadConfigOp) prepare(execContext *OpEngineExecContext) error { op.hosts = primaryUpHosts } - execContext.dispatcher.Setup(op.hosts) + execContext.dispatcher.setup(op.hosts) return op.setupClusterHTTPRequest(op.hosts) } diff --git a/vclusterops/nma_download_file_op.go b/vclusterops/nma_download_file_op.go index 7b6d093..977fd40 100644 --- a/vclusterops/nma_download_file_op.go +++ b/vclusterops/nma_download_file_op.go @@ -131,7 +131,7 @@ func (op *NMADownloadFileOp) setupClusterHTTPRequest(hosts []string) error { for _, host := range hosts { httpRequest := HostHTTPRequest{} httpRequest.Method = PostMethod - httpRequest.BuildNMAEndpoint("vertica/download-file") + httpRequest.buildNMAEndpoint("vertica/download-file") httpRequest.RequestData = op.hostRequestBodyMap[host] op.clusterHTTPRequest.RequestCollection[host] = httpRequest @@ -141,7 +141,7 @@ func (op *NMADownloadFileOp) setupClusterHTTPRequest(hosts []string) error { } func (op *NMADownloadFileOp) prepare(execContext *OpEngineExecContext) error { - execContext.dispatcher.Setup(op.hosts) + execContext.dispatcher.setup(op.hosts) return op.setupClusterHTTPRequest(op.hosts) } diff --git a/vclusterops/nma_get_nodes_info_op.go b/vclusterops/nma_get_nodes_info_op.go index fe5dded..266198a 100644 --- a/vclusterops/nma_get_nodes_info_op.go +++ b/vclusterops/nma_get_nodes_info_op.go @@ -48,7 +48,7 @@ func (op *nmaGetNodesInfoOp) setupClusterHTTPRequest(hosts []string) error { for _, host := range hosts { httpRequest := HostHTTPRequest{} httpRequest.Method = GetMethod - httpRequest.BuildNMAEndpoint("nodes") + httpRequest.buildNMAEndpoint("nodes") httpRequest.QueryParams = map[string]string{"db_name": op.dbName, "catalog_prefix": op.catalogPrefix} op.clusterHTTPRequest.RequestCollection[host] = httpRequest } @@ -57,7 +57,7 @@ func (op *nmaGetNodesInfoOp) setupClusterHTTPRequest(hosts []string) error { } func (op *nmaGetNodesInfoOp) prepare(execContext *OpEngineExecContext) error { - execContext.dispatcher.Setup(op.hosts) + execContext.dispatcher.setup(op.hosts) return op.setupClusterHTTPRequest(op.hosts) } diff --git a/vclusterops/nma_health_op.go b/vclusterops/nma_health_op.go index 0e7c4cd..f3568b4 100644 --- a/vclusterops/nma_health_op.go +++ b/vclusterops/nma_health_op.go @@ -38,7 +38,7 @@ func (op *NMAHealthOp) setupClusterHTTPRequest(hosts []string) error { for _, host := range hosts { httpRequest := HostHTTPRequest{} httpRequest.Method = GetMethod - httpRequest.BuildNMAEndpoint("health") + httpRequest.buildNMAEndpoint("health") op.clusterHTTPRequest.RequestCollection[host] = httpRequest } @@ -46,7 +46,7 @@ func (op *NMAHealthOp) setupClusterHTTPRequest(hosts []string) error { } func (op *NMAHealthOp) prepare(execContext *OpEngineExecContext) error { - execContext.dispatcher.Setup(op.hosts) + execContext.dispatcher.setup(op.hosts) return op.setupClusterHTTPRequest(op.hosts) } diff --git a/vclusterops/nma_load_remote_catalog_op.go b/vclusterops/nma_load_remote_catalog_op.go index 7875528..a3cfeb7 100644 --- a/vclusterops/nma_load_remote_catalog_op.go +++ b/vclusterops/nma_load_remote_catalog_op.go @@ -114,7 +114,7 @@ func (op *nmaLoadRemoteCatalogOp) setupClusterHTTPRequest(hosts []string) error for _, host := range hosts { httpRequest := HostHTTPRequest{} httpRequest.Method = PostMethod - httpRequest.BuildNMAEndpoint("catalog/revive") + httpRequest.buildNMAEndpoint("catalog/revive") httpRequest.RequestData = op.hostRequestBodyMap[host] httpRequest.Timeout = int(op.timeout) @@ -130,7 +130,7 @@ func (op *nmaLoadRemoteCatalogOp) prepare(execContext *OpEngineExecContext) erro return err } - execContext.dispatcher.Setup(op.hosts) + execContext.dispatcher.setup(op.hosts) return op.setupClusterHTTPRequest(op.hosts) } diff --git a/vclusterops/nma_network_profile_op.go b/vclusterops/nma_network_profile_op.go index b0219d2..f7863c8 100644 --- a/vclusterops/nma_network_profile_op.go +++ b/vclusterops/nma_network_profile_op.go @@ -39,7 +39,7 @@ func (op *NMANetworkProfileOp) setupClusterHTTPRequest(hosts []string) error { for _, host := range hosts { httpRequest := HostHTTPRequest{} httpRequest.Method = GetMethod - httpRequest.BuildNMAEndpoint("network-profiles") + httpRequest.buildNMAEndpoint("network-profiles") httpRequest.QueryParams = map[string]string{"broadcast-hint": host} op.clusterHTTPRequest.RequestCollection[host] = httpRequest @@ -49,7 +49,7 @@ func (op *NMANetworkProfileOp) setupClusterHTTPRequest(hosts []string) error { } func (op *NMANetworkProfileOp) prepare(execContext *OpEngineExecContext) error { - execContext.dispatcher.Setup(op.hosts) + execContext.dispatcher.setup(op.hosts) return op.setupClusterHTTPRequest(op.hosts) } diff --git a/vclusterops/nma_prepare_directories_op.go b/vclusterops/nma_prepare_directories_op.go index 012cc4c..87879eb 100644 --- a/vclusterops/nma_prepare_directories_op.go +++ b/vclusterops/nma_prepare_directories_op.go @@ -88,7 +88,7 @@ func (op *NMAPrepareDirectoriesOp) setupClusterHTTPRequest(hosts []string) error for _, host := range hosts { httpRequest := HostHTTPRequest{} httpRequest.Method = PostMethod - httpRequest.BuildNMAEndpoint("directories/prepare") + httpRequest.buildNMAEndpoint("directories/prepare") httpRequest.RequestData = op.hostRequestBodyMap[host] op.clusterHTTPRequest.RequestCollection[host] = httpRequest } @@ -97,7 +97,7 @@ func (op *NMAPrepareDirectoriesOp) setupClusterHTTPRequest(hosts []string) error } func (op *NMAPrepareDirectoriesOp) prepare(execContext *OpEngineExecContext) error { - execContext.dispatcher.Setup(op.hosts) + execContext.dispatcher.setup(op.hosts) return op.setupClusterHTTPRequest(op.hosts) } diff --git a/vclusterops/nma_re_ip_op.go b/vclusterops/nma_re_ip_op.go index bcd0bc1..9860beb 100644 --- a/vclusterops/nma_re_ip_op.go +++ b/vclusterops/nma_re_ip_op.go @@ -78,7 +78,7 @@ func (op *NMAReIPOp) setupClusterHTTPRequest(hosts []string) error { for _, host := range hosts { httpRequest := HostHTTPRequest{} httpRequest.Method = PutMethod - httpRequest.BuildNMAEndpoint("catalog/re-ip") + httpRequest.buildNMAEndpoint("catalog/re-ip") httpRequest.RequestData = op.hostRequestBodyMap[host] op.clusterHTTPRequest.RequestCollection[host] = httpRequest @@ -170,7 +170,7 @@ func (op *NMAReIPOp) prepare(execContext *OpEngineExecContext) error { return err } - execContext.dispatcher.Setup(op.hosts) + execContext.dispatcher.setup(op.hosts) return op.setupClusterHTTPRequest(op.hosts) } diff --git a/vclusterops/nma_read_catalog_editor_op.go b/vclusterops/nma_read_catalog_editor_op.go index 8561b36..9045dd1 100644 --- a/vclusterops/nma_read_catalog_editor_op.go +++ b/vclusterops/nma_read_catalog_editor_op.go @@ -55,7 +55,7 @@ func (op *NMAReadCatalogEditorOp) setupClusterHTTPRequest(hosts []string) error for _, host := range hosts { httpRequest := HostHTTPRequest{} httpRequest.Method = GetMethod - httpRequest.BuildNMAEndpoint("catalog/database") + httpRequest.buildNMAEndpoint("catalog/database") catalogPath, ok := op.catalogPathMap[host] if !ok { @@ -92,7 +92,7 @@ func (op *NMAReadCatalogEditorOp) prepare(execContext *OpEngineExecContext) erro } } - execContext.dispatcher.Setup(op.hosts) + execContext.dispatcher.setup(op.hosts) return op.setupClusterHTTPRequest(op.hosts) } diff --git a/vclusterops/nma_spread_security_op.go b/vclusterops/nma_spread_security_op.go index 7cb7c67..8a4fb19 100644 --- a/vclusterops/nma_spread_security_op.go +++ b/vclusterops/nma_spread_security_op.go @@ -92,7 +92,7 @@ func (op *nmaSpreadSecurityOp) setupClusterHTTPRequest(hostRequestBodyMap map[st for host, requestBody := range hostRequestBodyMap { httpRequest := HostHTTPRequest{} httpRequest.Method = PostMethod - httpRequest.BuildNMAEndpoint("catalog/spread-security") + httpRequest.buildNMAEndpoint("catalog/spread-security") httpRequest.RequestData = requestBody op.clusterHTTPRequest.RequestCollection[host] = httpRequest } @@ -108,7 +108,7 @@ func (op *nmaSpreadSecurityOp) prepare(execContext *OpEngineExecContext) error { if err != nil { return err } - execContext.dispatcher.Setup(op.hosts) + execContext.dispatcher.setup(op.hosts) return op.setupClusterHTTPRequest(hostRequestBodyMap) } diff --git a/vclusterops/nma_start_node_op.go b/vclusterops/nma_start_node_op.go index c9adde7..8221f55 100644 --- a/vclusterops/nma_start_node_op.go +++ b/vclusterops/nma_start_node_op.go @@ -101,7 +101,7 @@ func (op *nmaStartNodeOp) setupClusterHTTPRequest(hosts []string) error { for _, host := range hosts { httpRequest := HostHTTPRequest{} httpRequest.Method = PostMethod - httpRequest.BuildNMAEndpoint("nodes/start") + httpRequest.buildNMAEndpoint("nodes/start") httpRequest.RequestData = op.hostRequestBodyMap[host] op.clusterHTTPRequest.RequestCollection[host] = httpRequest } @@ -115,7 +115,7 @@ func (op *nmaStartNodeOp) prepare(execContext *OpEngineExecContext) error { return err } - execContext.dispatcher.Setup(op.hosts) + execContext.dispatcher.setup(op.hosts) return op.setupClusterHTTPRequest(op.hosts) } diff --git a/vclusterops/nma_upload_config.go b/vclusterops/nma_upload_config.go index 34bf4c0..971fe80 100644 --- a/vclusterops/nma_upload_config.go +++ b/vclusterops/nma_upload_config.go @@ -94,7 +94,7 @@ func (op *NMAUploadConfigOp) setupClusterHTTPRequest(hosts []string) error { for _, host := range hosts { httpRequest := HostHTTPRequest{} httpRequest.Method = PostMethod - httpRequest.BuildNMAEndpoint(op.endpoint) + httpRequest.buildNMAEndpoint(op.endpoint) httpRequest.RequestData = op.hostRequestBodyMap[host] op.clusterHTTPRequest.RequestCollection[host] = httpRequest } @@ -147,7 +147,7 @@ func (op *NMAUploadConfigOp) prepare(execContext *OpEngineExecContext) error { if err != nil { return err } - execContext.dispatcher.Setup(op.hosts) + execContext.dispatcher.setup(op.hosts) return op.setupClusterHTTPRequest(op.hosts) } diff --git a/vclusterops/nma_vertica_version_op.go b/vclusterops/nma_vertica_version_op.go index 2fbedde..1ac868a 100644 --- a/vclusterops/nma_vertica_version_op.go +++ b/vclusterops/nma_vertica_version_op.go @@ -45,7 +45,7 @@ func (op *NMAVerticaVersionOp) setupClusterHTTPRequest(hosts []string) error { for _, host := range hosts { httpRequest := HostHTTPRequest{} httpRequest.Method = GetMethod - httpRequest.BuildNMAEndpoint("vertica/version") + httpRequest.buildNMAEndpoint("vertica/version") op.clusterHTTPRequest.RequestCollection[host] = httpRequest } @@ -53,7 +53,7 @@ func (op *NMAVerticaVersionOp) setupClusterHTTPRequest(hosts []string) error { } func (op *NMAVerticaVersionOp) prepare(execContext *OpEngineExecContext) error { - execContext.dispatcher.Setup(op.hosts) + execContext.dispatcher.setup(op.hosts) return op.setupClusterHTTPRequest(op.hosts) } diff --git a/vclusterops/re_ip.go b/vclusterops/re_ip.go index 8708f05..54a0a09 100644 --- a/vclusterops/re_ip.go +++ b/vclusterops/re_ip.go @@ -34,7 +34,7 @@ type VReIPOptions struct { func VReIPFactory() VReIPOptions { opt := VReIPOptions{} // set default values to the params - opt.SetDefaultValues() + opt.setDefaultValues() return opt } @@ -49,7 +49,7 @@ func (opt *VReIPOptions) validateParseOptions(log vlog.Printer) error { return util.ValidateCommunalStorageLocation(*opt.CommunalStorageLocation) } - return opt.ValidateBaseOptions("re_ip", log) + return opt.validateBaseOptions("re_ip", log) } func (opt *VReIPOptions) analyzeOptions() error { @@ -62,7 +62,7 @@ func (opt *VReIPOptions) analyzeOptions() error { return nil } -func (opt *VReIPOptions) ValidateAnalyzeOptions(log vlog.Printer) error { +func (opt *VReIPOptions) validateAnalyzeOptions(log vlog.Printer) error { if err := opt.validateParseOptions(log); err != nil { return err } @@ -115,7 +115,7 @@ func (vcc *VClusterCommands) VReIP(options *VReIPOptions) error { * - Give the instructions to the VClusterOpEngine to run */ - err := options.ValidateAnalyzeOptions(vcc.Log) + err := options.validateAnalyzeOptions(vcc.Log) if err != nil { return err } @@ -146,10 +146,10 @@ func (vcc *VClusterCommands) VReIP(options *VReIPOptions) error { // create a VClusterOpEngine, and add certs to the engine certs := HTTPSCerts{key: options.Key, cert: options.Cert, caCert: options.CaCert} - clusterOpEngine := MakeClusterOpEngine(instructions, &certs) + clusterOpEngine := makeClusterOpEngine(instructions, &certs) // give the instructions to the VClusterOpEngine to run - runError := clusterOpEngine.Run(vcc.Log) + runError := clusterOpEngine.run(vcc.Log) if runError != nil { return fmt.Errorf("fail to re-ip: %w", runError) } diff --git a/vclusterops/re_ip_test.go b/vclusterops/re_ip_test.go index 4066a21..c0f61b0 100644 --- a/vclusterops/re_ip_test.go +++ b/vclusterops/re_ip_test.go @@ -26,23 +26,23 @@ import ( func TestReIPOptions(t *testing.T) { opt := VReIPFactory() - err := opt.ValidateAnalyzeOptions(vlog.Printer{}) + err := opt.validateAnalyzeOptions(vlog.Printer{}) assert.Error(t, err) *opt.DBName = "test_db" opt.RawHosts = []string{"192.168.1.101", "192.168.1.102"} - err = opt.ValidateAnalyzeOptions(vlog.Printer{}) + err = opt.validateAnalyzeOptions(vlog.Printer{}) assert.ErrorContains(t, err, "must specify an absolute catalog path") *opt.CatalogPrefix = "/data" - err = opt.ValidateAnalyzeOptions(vlog.Printer{}) + err = opt.validateAnalyzeOptions(vlog.Printer{}) assert.ErrorContains(t, err, "the re-ip list is not provided") var info ReIPInfo info.NodeAddress = "192.168.1.102" info.TargetAddress = "192.168.1.103" opt.ReIPList = append(opt.ReIPList, info) - err = opt.ValidateAnalyzeOptions(vlog.Printer{}) + err = opt.validateAnalyzeOptions(vlog.Printer{}) assert.NoError(t, err) } diff --git a/vclusterops/remove_node.go b/vclusterops/remove_node.go index 51a4597..4b1328c 100644 --- a/vclusterops/remove_node.go +++ b/vclusterops/remove_node.go @@ -38,13 +38,13 @@ type VRemoveNodeOptions struct { func VRemoveNodeOptionsFactory() VRemoveNodeOptions { opt := VRemoveNodeOptions{} // set default values to the params - opt.SetDefaultValues() + opt.setDefaultValues() return opt } -func (o *VRemoveNodeOptions) SetDefaultValues() { - o.DatabaseOptions.SetDefaultValues() +func (o *VRemoveNodeOptions) setDefaultValues() { + o.DatabaseOptions.setDefaultValues() o.ForceDelete = new(bool) *o.ForceDelete = true @@ -65,7 +65,7 @@ func (o *VRemoveNodeOptions) ParseHostToRemoveList(hosts string) error { } func (o *VRemoveNodeOptions) validateRequiredOptions(log vlog.Printer) error { - err := o.ValidateBaseOptions("db_remove_node", log) + err := o.validateBaseOptions("db_remove_node", log) if err != nil { return err } @@ -116,7 +116,7 @@ func (o *VRemoveNodeOptions) validateAnalyzeOptions(log vlog.Printer) error { if err != nil { return err } - return o.SetUsePassword(log) + return o.setUsePassword(log) } func (vcc *VClusterCommands) VRemoveNode(options *VRemoveNodeOptions) (VCoordinationDatabase, error) { @@ -129,7 +129,7 @@ func (vcc *VClusterCommands) VRemoveNode(options *VRemoveNodeOptions) (VCoordina } // get db name and hosts from config file and options. - dbName, hosts, err := options.GetNameAndHosts(options.Config) + dbName, hosts, err := options.getNameAndHosts(options.Config) if err != nil { return vdb, err } @@ -169,14 +169,14 @@ func (vcc *VClusterCommands) VRemoveNode(options *VRemoveNodeOptions) (VCoordina } certs := HTTPSCerts{key: options.Key, cert: options.Cert, caCert: options.CaCert} - clusterOpEngine := MakeClusterOpEngine(instructions, &certs) - if runError := clusterOpEngine.Run(vcc.Log); runError != nil { + clusterOpEngine := makeClusterOpEngine(instructions, &certs) + if runError := clusterOpEngine.run(vcc.Log); runError != nil { return vdb, fmt.Errorf("fail to complete remove node operation, %w", runError) } remainingHosts := util.SliceDiff(vdb.HostList, options.HostsToRemove) // we return a vdb that contains only the remaining hosts - return vdb.Copy(remainingHosts), nil + return vdb.copy(remainingHosts), nil } // checkRemoveNodeRequirements validates the following remove_node requirements: @@ -266,7 +266,7 @@ func (vcc *VClusterCommands) produceRemoveNodeInstructions(vdb *VCoordinationDat // this is a copy of the original that only // contains the hosts to remove. - v := vdb.Copy(options.HostsToRemove) + v := vdb.copy(options.HostsToRemove) if vdb.IsEon { // we pass the set of subclusters of the nodes to remove. err = vcc.produceRebalanceSubclusterShardsOps(&instructions, initiatorHost, v.getSCNames(), diff --git a/vclusterops/remove_subcluster.go b/vclusterops/remove_subcluster.go index 65b3a8c..c856f21 100644 --- a/vclusterops/remove_subcluster.go +++ b/vclusterops/remove_subcluster.go @@ -41,13 +41,13 @@ func VRemoveScOptionsFactory() VRemoveScOptions { } func (o *VRemoveScOptions) setDefaultValues() { - o.DatabaseOptions.SetDefaultValues() + o.DatabaseOptions.setDefaultValues() o.SubclusterToRemove = new(string) o.ForceDelete = new(bool) } func (o *VRemoveScOptions) validateRequiredOptions(log vlog.Printer) error { - err := o.ValidateBaseOptions("db_remove_subcluster", log) + err := o.validateBaseOptions("db_remove_subcluster", log) if err != nil { return err } @@ -101,7 +101,7 @@ func (o *VRemoveScOptions) validateAnalyzeOptions(log vlog.Printer) error { if err != nil { return err } - return o.SetUsePassword(log) + return o.setUsePassword(log) } /* @@ -212,8 +212,8 @@ func (vcc *VClusterCommands) removeScPreCheck(vdb *VCoordinationDatabase, option ) certs := HTTPSCerts{key: options.Key, cert: options.Cert, caCert: options.CaCert} - clusterOpEngine := MakeClusterOpEngine(instructions, &certs) - err = clusterOpEngine.Run(vcc.Log) + clusterOpEngine := makeClusterOpEngine(instructions, &certs) + err = clusterOpEngine.run(vcc.Log) if err != nil { // VER-88585 will improve this rfc error flow if strings.Contains(err.Error(), "does not exist in the database") { @@ -262,8 +262,8 @@ func (vcc *VClusterCommands) dropSubcluster(vdb *VCoordinationDatabase, options instructions = append(instructions, &httpsDropScOp) certs := HTTPSCerts{key: options.Key, cert: options.Cert, caCert: options.CaCert} - clusterOpEngine := MakeClusterOpEngine(instructions, &certs) - err = clusterOpEngine.Run(vcc.Log) + clusterOpEngine := makeClusterOpEngine(instructions, &certs) + err = clusterOpEngine.run(vcc.Log) if err != nil { vcc.Log.Error(err, "fail to drop subcluster, details: %v", dropScErrMsg) return err diff --git a/vclusterops/restart_node.go b/vclusterops/restart_node.go index f4dbc68..c1334f1 100644 --- a/vclusterops/restart_node.go +++ b/vclusterops/restart_node.go @@ -52,11 +52,11 @@ func VRestartNodesOptionsFactory() VRestartNodesOptions { } func (options *VRestartNodesOptions) setDefaultValues() { - options.DatabaseOptions.SetDefaultValues() + options.DatabaseOptions.setDefaultValues() } func (options *VRestartNodesOptions) validateRequiredOptions(log vlog.Printer) error { - err := options.ValidateBaseOptions("restart_node", log) + err := options.validateBaseOptions("restart_node", log) if err != nil { return err } @@ -102,7 +102,7 @@ func (options *VRestartNodesOptions) ParseNodesList(nodeListStr string) error { return nil } -func (options *VRestartNodesOptions) ValidateAnalyzeOptions(log vlog.Printer) error { +func (options *VRestartNodesOptions) validateAnalyzeOptions(log vlog.Printer) error { if err := options.validateParseOptions(log); err != nil { return err } @@ -120,13 +120,13 @@ func (vcc *VClusterCommands) VRestartNodes(options *VRestartNodesOptions) error */ // validate and analyze options - err := options.ValidateAnalyzeOptions(vcc.Log) + err := options.validateAnalyzeOptions(vcc.Log) if err != nil { return err } // get db name and hosts from config file and options - dbName, hosts, err := options.GetNameAndHosts(options.Config) + dbName, hosts, err := options.getNameAndHosts(options.Config) if err != nil { return err } @@ -181,10 +181,10 @@ func (vcc *VClusterCommands) VRestartNodes(options *VRestartNodesOptions) error // create a VClusterOpEngine, and add certs to the engine certs := HTTPSCerts{key: options.Key, cert: options.Cert, caCert: options.CaCert} - clusterOpEngine := MakeClusterOpEngine(instructions, &certs) + clusterOpEngine := makeClusterOpEngine(instructions, &certs) // Give the instructions to the VClusterOpEngine to run - err = clusterOpEngine.Run(vcc.Log) + err = clusterOpEngine.run(vcc.Log) if err != nil { return fmt.Errorf("fail to restart node, %w", err) } @@ -217,7 +217,7 @@ func (vcc *VClusterCommands) produceRestartNodesInstructions(restartNodeInfo *VR // require to have the same vertica version nmaVerticaVersionOp := makeNMAVerticaVersionOp(vcc.Log, options.Hosts, true) // need username for https operations - err := options.SetUsePassword(vcc.Log) + err := options.setUsePassword(vcc.Log) if err != nil { return instructions, err } diff --git a/vclusterops/revive_db.go b/vclusterops/revive_db.go index f07c440..8ffe4d0 100644 --- a/vclusterops/revive_db.go +++ b/vclusterops/revive_db.go @@ -42,7 +42,7 @@ func VReviveDBOptionsFactory() VReviveDatabaseOptions { } func (options *VReviveDatabaseOptions) setDefaultValues() { - options.DatabaseOptions.SetDefaultValues() + options.DatabaseOptions.setDefaultValues() // set default values for revive db options options.LoadCatalogTimeout = new(uint) @@ -92,7 +92,7 @@ func (options *VReviveDatabaseOptions) analyzeOptions() (err error) { return nil } -func (options *VReviveDatabaseOptions) ValidateAnalyzeOptions() error { +func (options *VReviveDatabaseOptions) validateAnalyzeOptions() error { if err := options.validateParseOptions(); err != nil { return err } @@ -108,7 +108,7 @@ func (vcc *VClusterCommands) VReviveDatabase(options *VReviveDatabaseOptions) (d */ // validate and analyze options - err = options.ValidateAnalyzeOptions() + err = options.validateAnalyzeOptions() if err != nil { return dbInfo, err } @@ -124,8 +124,8 @@ func (vcc *VClusterCommands) VReviveDatabase(options *VReviveDatabaseOptions) (d // generate clusterOpEngine certs certs := HTTPSCerts{key: options.Key, cert: options.Cert, caCert: options.CaCert} // feed the pre-revive db instructions to the VClusterOpEngine - clusterOpEngine := MakeClusterOpEngine(preReviveDBInstructions, &certs) - err = clusterOpEngine.Run(vcc.Log) + clusterOpEngine := makeClusterOpEngine(preReviveDBInstructions, &certs) + err = clusterOpEngine.run(vcc.Log) if err != nil { return dbInfo, fmt.Errorf("fail to collect the information of database in revive_db %w", err) } @@ -142,8 +142,8 @@ func (vcc *VClusterCommands) VReviveDatabase(options *VReviveDatabaseOptions) (d } // feed revive db instructions to the VClusterOpEngine - clusterOpEngine = MakeClusterOpEngine(reviveDBInstructions, &certs) - err = clusterOpEngine.Run(vcc.Log) + clusterOpEngine = makeClusterOpEngine(reviveDBInstructions, &certs) + err = clusterOpEngine.run(vcc.Log) if err != nil { return dbInfo, fmt.Errorf("fail to revive database %w", err) } diff --git a/vclusterops/start_db.go b/vclusterops/start_db.go index 1aae413..2c70c07 100644 --- a/vclusterops/start_db.go +++ b/vclusterops/start_db.go @@ -34,22 +34,22 @@ func VStartDatabaseOptionsFactory() VStartDatabaseOptions { opt := VStartDatabaseOptions{} // set default values to the params - opt.SetDefaultValues() + opt.setDefaultValues() return opt } -func (options *VStartDatabaseOptions) SetDefaultValues() { - options.DatabaseOptions.SetDefaultValues() +func (options *VStartDatabaseOptions) setDefaultValues() { + options.DatabaseOptions.setDefaultValues() } func (options *VStartDatabaseOptions) validateRequiredOptions(log vlog.Printer) error { - err := options.ValidateBaseOptions("start_db", log) + err := options.validateBaseOptions("start_db", log) if err != nil { return err } if *options.HonorUserInput { - err = options.ValidateCatalogPath() + err = options.validateCatalogPath() if err != nil { return err } @@ -88,7 +88,7 @@ func (options *VStartDatabaseOptions) analyzeOptions() (err error) { return nil } -func (options *VStartDatabaseOptions) ValidateAnalyzeOptions(log vlog.Printer) error { +func (options *VStartDatabaseOptions) validateAnalyzeOptions(log vlog.Printer) error { if err := options.validateParseOptions(log); err != nil { return err } @@ -102,20 +102,20 @@ func (vcc *VClusterCommands) VStartDatabase(options *VStartDatabaseOptions) erro * - Give the instructions to the VClusterOpEngine to run */ - err := options.ValidateAnalyzeOptions(vcc.Log) + err := options.validateAnalyzeOptions(vcc.Log) if err != nil { return err } // get db name and hosts from config file and options - dbName, hosts, err := options.GetNameAndHosts(options.Config) + dbName, hosts, err := options.getNameAndHosts(options.Config) if err != nil { return err } options.DBName = &dbName options.Hosts = hosts - options.CatalogPrefix, err = options.GetCatalogPrefix(options.Config) + options.CatalogPrefix, err = options.getCatalogPrefix(options.Config) if err != nil { return err } @@ -127,7 +127,7 @@ func (vcc *VClusterCommands) VStartDatabase(options *VStartDatabaseOptions) erro var pVDB *VCoordinationDatabase // retrieve database information from cluster_config.json for EON databases - isEon, err := options.IsEonMode(options.Config) + isEon, err := options.isEonMode(options.Config) if err != nil { return err } @@ -157,10 +157,10 @@ func (vcc *VClusterCommands) VStartDatabase(options *VStartDatabaseOptions) erro // create a VClusterOpEngine, and add certs to the engine certs := HTTPSCerts{key: options.Key, cert: options.Cert, caCert: options.CaCert} - clusterOpEngine := MakeClusterOpEngine(instructions, &certs) + clusterOpEngine := makeClusterOpEngine(instructions, &certs) // Give the instructions to the VClusterOpEngine to run - runError := clusterOpEngine.Run(vcc.Log) + runError := clusterOpEngine.run(vcc.Log) if runError != nil { return fmt.Errorf("fail to start database: %w", runError) } @@ -188,7 +188,7 @@ func (vcc *VClusterCommands) produceStartDBInstructions(options *VStartDatabaseO // require to have the same vertica version nmaVerticaVersionOp := makeNMAVerticaVersionOp(vcc.Log, options.Hosts, true) // need username for https operations - err := options.SetUsePassword(vcc.Log) + err := options.setUsePassword(vcc.Log) if err != nil { return instructions, err } diff --git a/vclusterops/stop_db.go b/vclusterops/stop_db.go index 53fe56c..79de3f5 100644 --- a/vclusterops/stop_db.go +++ b/vclusterops/stop_db.go @@ -44,20 +44,20 @@ type VStopDatabaseInfo struct { func VStopDatabaseOptionsFactory() VStopDatabaseOptions { opt := VStopDatabaseOptions{} // set default values to the params - opt.SetDefaultValues() + opt.setDefaultValues() return opt } -func (options *VStopDatabaseOptions) SetDefaultValues() { - options.DatabaseOptions.SetDefaultValues() +func (options *VStopDatabaseOptions) setDefaultValues() { + options.DatabaseOptions.setDefaultValues() options.CheckUserConn = new(bool) options.ForceKill = new(bool) } func (options *VStopDatabaseOptions) validateRequiredOptions(log vlog.Printer) error { - err := options.ValidateBaseOptions("stop_db", log) + err := options.validateBaseOptions("stop_db", log) if err != nil { return err } @@ -67,7 +67,7 @@ func (options *VStopDatabaseOptions) validateRequiredOptions(log vlog.Printer) e func (options *VStopDatabaseOptions) validateEonOptions(config *ClusterConfig, log vlog.Printer) error { // if db is enterprise db and we see --drain-seconds, we will ignore it - isEon, err := options.IsEonMode(config) + isEon, err := options.isEonMode(config) if err != nil { return err } @@ -123,7 +123,7 @@ func (options *VStopDatabaseOptions) analyzeOptions() (err error) { return nil } -func (options *VStopDatabaseOptions) ValidateAnalyzeOptions(config *ClusterConfig, log vlog.Printer) error { +func (options *VStopDatabaseOptions) validateAnalyzeOptions(config *ClusterConfig, log vlog.Printer) error { if err := options.validateParseOptions(config, log); err != nil { return err } @@ -137,7 +137,7 @@ func (vcc *VClusterCommands) VStopDatabase(options *VStopDatabaseOptions) error * - Give the instructions to the VClusterOpEngine to run */ - err := options.ValidateAnalyzeOptions(options.Config, vcc.Log) + err := options.validateAnalyzeOptions(options.Config, vcc.Log) if err != nil { return err } @@ -147,12 +147,12 @@ func (vcc *VClusterCommands) VStopDatabase(options *VStopDatabaseOptions) error stopDBInfo.UserName = *options.UserName stopDBInfo.Password = options.Password stopDBInfo.DrainSeconds = options.DrainSeconds - stopDBInfo.DBName, stopDBInfo.Hosts, err = options.GetNameAndHosts(options.Config) + stopDBInfo.DBName, stopDBInfo.Hosts, err = options.getNameAndHosts(options.Config) if err != nil { return err } - stopDBInfo.IsEon, err = options.IsEonMode(options.Config) + stopDBInfo.IsEon, err = options.isEonMode(options.Config) if err != nil { return err } @@ -164,10 +164,10 @@ func (vcc *VClusterCommands) VStopDatabase(options *VStopDatabaseOptions) error // Create a VClusterOpEngine, and add certs to the engine certs := HTTPSCerts{key: options.Key, cert: options.Cert, caCert: options.CaCert} - clusterOpEngine := MakeClusterOpEngine(instructions, &certs) + clusterOpEngine := makeClusterOpEngine(instructions, &certs) // Give the instructions to the VClusterOpEngine to run - runError := clusterOpEngine.Run(vcc.Log) + runError := clusterOpEngine.run(vcc.Log) if runError != nil { return fmt.Errorf("fail to stop database: %w", runError) } @@ -193,7 +193,7 @@ func (vcc *VClusterCommands) produceStopDBInstructions(stopDBInfo *VStopDatabase usePassword := false if stopDBInfo.Password != nil { usePassword = true - err := options.ValidateUserName(vcc.Log) + err := options.validateUserName(vcc.Log) if err != nil { return instructions, err } diff --git a/vclusterops/vcluster_database_options.go b/vclusterops/vcluster_database_options.go index c7d0a7d..2420ee4 100644 --- a/vclusterops/vcluster_database_options.go +++ b/vclusterops/vcluster_database_options.go @@ -72,7 +72,7 @@ const ( commandAddCluster = "db_add_subcluster" ) -func (opt *DatabaseOptions) SetDefaultValues() { +func (opt *DatabaseOptions) setDefaultValues() { opt.DBName = new(string) opt.CatalogPrefix = new(string) opt.DataPrefix = new(string) @@ -85,7 +85,7 @@ func (opt *DatabaseOptions) SetDefaultValues() { opt.ConfigurationParameters = make(map[string]string) } -func (opt *DatabaseOptions) CheckNilPointerParams() error { +func (opt *DatabaseOptions) checkNilPointerParams() error { // basic params if opt.DBName == nil { return util.ParamNotSetErrorMsg("name") @@ -103,7 +103,7 @@ func (opt *DatabaseOptions) CheckNilPointerParams() error { return nil } -func (opt *DatabaseOptions) ValidateBaseOptions(commandName string, log vlog.Printer) error { +func (opt *DatabaseOptions) validateBaseOptions(commandName string, log vlog.Printer) error { // get vcluster commands log.WithName(commandName) // database name @@ -116,19 +116,19 @@ func (opt *DatabaseOptions) ValidateBaseOptions(commandName string, log vlog.Pri } // raw hosts and password - err = opt.ValidateHostsAndPwd(commandName, log) + err = opt.validateHostsAndPwd(commandName, log) if err != nil { return err } // paths - err = opt.ValidatePaths(commandName) + err = opt.validatePaths(commandName) if err != nil { return err } // config directory - err = opt.ValidateConfigDir(commandName) + err = opt.validateConfigDir(commandName) if err != nil { return err } @@ -142,8 +142,8 @@ func (opt *DatabaseOptions) ValidateBaseOptions(commandName string, log vlog.Pri return nil } -// ValidateHostsAndPwd will validate raw hosts and password -func (opt *DatabaseOptions) ValidateHostsAndPwd(commandName string, log vlog.Printer) error { +// validateHostsAndPwd will validate raw hosts and password +func (opt *DatabaseOptions) validateHostsAndPwd(commandName string, log vlog.Printer) error { // when we create db, we need hosts and set password to "" if user did not provide one if commandName == commandCreateDB { // raw hosts @@ -172,7 +172,7 @@ func (opt *DatabaseOptions) ValidateHostsAndPwd(commandName string, log vlog.Pri } // validate catalog, data, and depot paths -func (opt *DatabaseOptions) ValidatePaths(commandName string) error { +func (opt *DatabaseOptions) validatePaths(commandName string) error { // validate for the following commands only // TODO: add other commands into the command list commands := []string{commandCreateDB, commandDropDB} @@ -181,7 +181,7 @@ func (opt *DatabaseOptions) ValidatePaths(commandName string) error { } // catalog prefix path - err := opt.ValidateCatalogPath() + err := opt.validateCatalogPath() if err != nil { return err } @@ -202,13 +202,13 @@ func (opt *DatabaseOptions) ValidatePaths(commandName string) error { return nil } -func (opt *DatabaseOptions) ValidateCatalogPath() error { +func (opt *DatabaseOptions) validateCatalogPath() error { // catalog prefix path return util.ValidateRequiredAbsPath(opt.CatalogPrefix, "catalog path") } // validate config directory -func (opt *DatabaseOptions) ValidateConfigDir(commandName string) error { +func (opt *DatabaseOptions) validateConfigDir(commandName string) error { // validate for the following commands only // TODO: add other commands into the command list commands := []string{commandCreateDB, commandDropDB, commandStopDB, commandStartDB, commandAddCluster} @@ -237,7 +237,7 @@ func (opt *DatabaseOptions) ParseHostList(hosts string) error { return nil } -func (opt *DatabaseOptions) ValidateUserName(log vlog.Printer) error { +func (opt *DatabaseOptions) validateUserName(log vlog.Printer) error { if *opt.UserName == "" { username, err := util.GetCurrentUsername() if err != nil { @@ -250,13 +250,13 @@ func (opt *DatabaseOptions) ValidateUserName(log vlog.Printer) error { return nil } -func (opt *DatabaseOptions) SetUsePassword(log vlog.Printer) error { +func (opt *DatabaseOptions) setUsePassword(log vlog.Printer) error { // when password is specified, // we will use username/password to call https endpoints opt.usePassword = false if opt.Password != nil { opt.usePassword = true - err := opt.ValidateUserName(log) + err := opt.validateUserName(log) if err != nil { return err } @@ -265,8 +265,8 @@ func (opt *DatabaseOptions) SetUsePassword(log vlog.Printer) error { return nil } -// IsEonMode can choose the right eon mode from user input and config file -func (opt *DatabaseOptions) IsEonMode(config *ClusterConfig) (bool, error) { +// isEonMode can choose the right eon mode from user input and config file +func (opt *DatabaseOptions) isEonMode(config *ClusterConfig) (bool, error) { // when config file is not available, we use user input // HonorUserInput must be true at this time, otherwise vcluster has stopped when it cannot find the config file if config == nil { @@ -286,8 +286,8 @@ func (opt *DatabaseOptions) IsEonMode(config *ClusterConfig) (bool, error) { return isEon, nil } -// GetNameAndHosts can choose the right dbName and hosts from user input and config file -func (opt *DatabaseOptions) GetNameAndHosts(config *ClusterConfig) (dbName string, hosts []string, err error) { +// getNameAndHosts can choose the right dbName and hosts from user input and config file +func (opt *DatabaseOptions) getNameAndHosts(config *ClusterConfig) (dbName string, hosts []string, err error) { // when config file is not available, we use user input // HonorUserInput must be true at this time, otherwise vcluster has stopped when it cannot find the config file dbName = *opt.DBName @@ -301,7 +301,7 @@ func (opt *DatabaseOptions) GetNameAndHosts(config *ClusterConfig) (dbName strin return dbName, hosts, cannotFindDBFromConfigErr(dbName) } - hosts = dbConfig.GetHosts() + hosts = dbConfig.getHosts() // if HonorUserInput is set, we choose the user input if *opt.DBName != "" && *opt.HonorUserInput { dbName = *opt.DBName @@ -312,8 +312,8 @@ func (opt *DatabaseOptions) GetNameAndHosts(config *ClusterConfig) (dbName strin return dbName, hosts, nil } -// GetHosts chooses the right hosts from user input and config file -func (opt *DatabaseOptions) GetHosts(config *ClusterConfig) (hosts []string, err error) { +// getHosts chooses the right hosts from user input and config file +func (opt *DatabaseOptions) getHosts(config *ClusterConfig) (hosts []string, err error) { // when config file is not available, we use user input // HonorUserInput must be true at this time, otherwise vcluster has stopped when it cannot find the config file if config == nil { @@ -325,7 +325,7 @@ func (opt *DatabaseOptions) GetHosts(config *ClusterConfig) (hosts []string, err return hosts, cannotFindDBFromConfigErr(*opt.DBName) } - hosts = dbConfig.GetHosts() + hosts = dbConfig.getHosts() // if HonorUserInput is set, we choose the user input if len(opt.Hosts) > 0 && *opt.HonorUserInput { hosts = opt.Hosts @@ -333,8 +333,8 @@ func (opt *DatabaseOptions) GetHosts(config *ClusterConfig) (hosts []string, err return hosts, nil } -// GetCatalogPrefix can choose the right catalog prefix from user input and config file -func (opt *DatabaseOptions) GetCatalogPrefix(clusterConfig *ClusterConfig) (catalogPrefix *string, err error) { +// getCatalogPrefix can choose the right catalog prefix from user input and config file +func (opt *DatabaseOptions) getCatalogPrefix(clusterConfig *ClusterConfig) (catalogPrefix *string, err error) { // when config file is not available, we use user input // HonorUserInput must be true at this time, otherwise vcluster has stopped when it cannot find the config file if clusterConfig == nil { @@ -450,8 +450,8 @@ func (opt *DatabaseOptions) getVDBWhenDBIsDown(vcc *VClusterCommands) (vdb VCoor ) certs := HTTPSCerts{key: opt.Key, cert: opt.Cert, caCert: opt.CaCert} - clusterOpEngine := MakeClusterOpEngine(instructions1, &certs) - err = clusterOpEngine.Run(vcc.Log) + clusterOpEngine := makeClusterOpEngine(instructions1, &certs) + err = clusterOpEngine.run(vcc.Log) if err != nil { vcc.Log.PrintError("fail to retrieve node names from NMA /nodes: %v", err) return vdb, err @@ -468,8 +468,8 @@ func (opt *DatabaseOptions) getVDBWhenDBIsDown(vcc *VClusterCommands) (vdb VCoor } instructions2 = append(instructions2, &nmaDownLoadFileOp) - clusterOpEngine = MakeClusterOpEngine(instructions2, &certs) - err = clusterOpEngine.Run(vcc.Log) + clusterOpEngine = makeClusterOpEngine(instructions2, &certs) + err = clusterOpEngine.run(vcc.Log) if err != nil { vcc.Log.PrintError("fail to retrieve node details from %s: %v", descriptionFileName, err) return vdb, err