diff --git a/vclusterops/add_node.go b/vclusterops/add_node.go index 14b8a1b..a9ba130 100644 --- a/vclusterops/add_node.go +++ b/vclusterops/add_node.go @@ -203,11 +203,10 @@ func (o *VAddNodeOptions) completeVDBSetting(vdb *VCoordinationDatabase) error { vdb.DataPrefix = *o.DataPrefix vdb.DepotPrefix = *o.DepotPrefix - hostNodeMap := make(map[string]VCoordinationNode) + hostNodeMap := makeVHostNodeMap() // we set depot/data paths manually because there is not yet an https endpoint for // that(VER-88122). This is useful for NMAPrepareDirectoriesOp. - for h := range vdb.HostNodeMap { - vnode := vdb.HostNodeMap[h] + for h, vnode := range vdb.HostNodeMap { dataPath := vdb.genDataPath(vnode.Name) vnode.StorageLocations = append(vnode.StorageLocations, dataPath) if vdb.DepotPrefix != "" { @@ -280,7 +279,7 @@ func produceAddNodeInstructions(vdb *VCoordinationDatabase, if err != nil { return instructions, err } - httpsReloadSpreadOp, err := makeHTTPSReloadSpreadOp(initiatorHost, usePassword, username, password) + httpsReloadSpreadOp, err := makeHTTPSReloadSpreadOpWithInitiator(initiatorHost, usePassword, username, password) if err != nil { return instructions, err } diff --git a/vclusterops/coordinator_database.go b/vclusterops/coordinator_database.go index e54d5ce..adaba0d 100644 --- a/vclusterops/coordinator_database.go +++ b/vclusterops/coordinator_database.go @@ -37,7 +37,7 @@ type VCoordinationDatabase struct { // processed path prefixes CatalogPrefix string DataPrefix string - HostNodeMap map[string]VCoordinationNode + HostNodeMap vHostNodeMap // for convenience HostList []string // expected to be resolved IP addresses @@ -60,6 +60,12 @@ type VCoordinationDatabase struct { PrimaryUpNodes []string } +type vHostNodeMap map[string]*VCoordinationNode + +func makeVHostNodeMap() vHostNodeMap { + return make(vHostNodeMap) +} + func MakeVCoordinationDatabase() VCoordinationDatabase { return VCoordinationDatabase{} } @@ -78,7 +84,7 @@ func (vdb *VCoordinationDatabase) SetFromCreateDBOptions(options *VCreateDatabas vdb.DataPrefix = *options.DataPrefix vdb.HostList = make([]string, len(options.Hosts)) vdb.HostList = options.Hosts - vdb.HostNodeMap = make(map[string]VCoordinationNode) + vdb.HostNodeMap = makeVHostNodeMap() vdb.LicensePathOnNode = *options.LicensePathOnNode vdb.Ipv6 = options.Ipv6.ToBool() @@ -109,7 +115,7 @@ func (vdb *VCoordinationDatabase) SetFromCreateDBOptions(options *VCreateDatabas if err != nil { return err } - vdb.HostNodeMap[host] = vNode + vdb.HostNodeMap[host] = &vNode } return nil @@ -133,7 +139,7 @@ func (vdb *VCoordinationDatabase) addHosts(hosts []string) error { } vNode.SetFromNodeConfig(nodeConfig, vdb) vdb.HostList = append(vdb.HostList, host) - vdb.HostNodeMap[host] = vNode + vdb.HostNodeMap[host] = &vNode } return nil @@ -153,11 +159,11 @@ func (vdb *VCoordinationDatabase) SetFromClusterConfig(clusterConfig *ClusterCon vdb.UseDepot = true } - vdb.HostNodeMap = make(map[string]VCoordinationNode) + vdb.HostNodeMap = makeVHostNodeMap() for _, nodeConfig := range clusterConfig.Nodes { vnode := VCoordinationNode{} vnode.SetFromNodeConfig(nodeConfig, vdb) - vdb.HostNodeMap[vnode.Address] = vnode + vdb.HostNodeMap[vnode.Address] = &vnode } } @@ -196,7 +202,7 @@ func (vdb *VCoordinationDatabase) Copy(targetHosts []string) VCoordinationDataba // copyHostNodeMap copies the receiver's HostNodeMap. You can choose to copy // only a subset of the receiver's hosts by passing a slice of hosts to keep. -func (vdb *VCoordinationDatabase) copyHostNodeMap(targetHosts []string) map[string]VCoordinationNode { +func (vdb *VCoordinationDatabase) copyHostNodeMap(targetHosts []string) vHostNodeMap { if len(targetHosts) == 0 { return util.CopyMap(vdb.HostNodeMap) } @@ -208,8 +214,8 @@ func (vdb *VCoordinationDatabase) copyHostNodeMap(targetHosts []string) map[stri // host ip as value, from HostNodeMap. func (vdb *VCoordinationDatabase) genNodeNameToHostMap() map[string]string { vnodes := make(map[string]string) - for h := range vdb.HostNodeMap { - vnodes[vdb.HostNodeMap[h].Name] = h + for h, vnode := range vdb.HostNodeMap { + vnodes[vnode.Name] = h } return vnodes } @@ -234,8 +240,8 @@ func (vdb *VCoordinationDatabase) SetDBInfoFromClusterConfig(clusterConfig *Clus func (vdb *VCoordinationDatabase) getSCNames() []string { allKeys := make(map[string]bool) scNames := []string{} - for h := range vdb.HostNodeMap { - sc := vdb.HostNodeMap[h].Subcluster + for _, vnode := range vdb.HostNodeMap { + sc := vnode.Subcluster if _, value := allKeys[sc]; !value { allKeys[sc] = true scNames = append(scNames, sc) @@ -251,8 +257,8 @@ func (vdb *VCoordinationDatabase) containNodes(nodes []string) []string { hostSet[n] = struct{}{} } dupHosts := []string{} - for h := range vdb.HostNodeMap { - address := vdb.HostNodeMap[h].Address + for _, vnode := range vdb.HostNodeMap { + address := vnode.Address if _, exist := hostSet[address]; exist { dupHosts = append(dupHosts, address) } @@ -264,8 +270,8 @@ func (vdb *VCoordinationDatabase) containNodes(nodes []string) []string { // hasAtLeastOneDownNode returns true if the current VCoordinationDatabase instance // has at least one down node. func (vdb *VCoordinationDatabase) hasAtLeastOneDownNode() bool { - for host := range vdb.HostNodeMap { - if vdb.HostNodeMap[host].State == util.NodeDownState { + for _, vnode := range vdb.HostNodeMap { + if vnode.State == util.NodeDownState { return true } } diff --git a/vclusterops/create_db.go b/vclusterops/create_db.go index c0c10ed..d163a84 100644 --- a/vclusterops/create_db.go +++ b/vclusterops/create_db.go @@ -529,7 +529,7 @@ func produceBasicCreateDBInstructions(vdb *VCoordinationDatabase, options *VCrea instructions = append(instructions, &httpsCreateNodeOp) } - httpsReloadSpreadOp, err := makeHTTPSReloadSpreadOp(bootstrapHost, true, *options.UserName, options.Password) + httpsReloadSpreadOp, err := makeHTTPSReloadSpreadOpWithInitiator(bootstrapHost, true, *options.UserName, options.Password) if err != nil { return instructions, err } diff --git a/vclusterops/create_db_test.go b/vclusterops/create_db_test.go index e0f9eb3..1299af6 100644 --- a/vclusterops/create_db_test.go +++ b/vclusterops/create_db_test.go @@ -67,11 +67,11 @@ func TestWriteClusterConfig(t *testing.T) { vdb.DataPrefix = defaultPath vdb.DepotPrefix = defaultPath vdb.HostList = []string{"ip_1", "ip_2", "ip_3"} - vdb.HostNodeMap = make(map[string]VCoordinationNode) + vdb.HostNodeMap = makeVHostNodeMap() for i, h := range vdb.HostList { n := VCoordinationNode{} n.Name = fmt.Sprintf("node_name_%d", i+1) - vdb.HostNodeMap[h] = n + vdb.HostNodeMap[h] = &n } vdb.IsEon = true diff --git a/vclusterops/https_create_cluster_depot_op.go b/vclusterops/https_create_cluster_depot_op.go index b2f8a55..5010098 100644 --- a/vclusterops/https_create_cluster_depot_op.go +++ b/vclusterops/https_create_cluster_depot_op.go @@ -40,8 +40,8 @@ func makeHTTPSCreateClusterDepotOp(vdb *VCoordinationDatabase, hosts []string, // store nodeName-depotPath values for later http response verification httpsCreateDepotOp.NodeDepotPaths = make(map[string]string) - for host := range vdb.HostNodeMap { - httpsCreateDepotOp.NodeDepotPaths[vdb.HostNodeMap[host].Name] = vdb.HostNodeMap[host].DepotPath + for _, vnode := range vdb.HostNodeMap { + httpsCreateDepotOp.NodeDepotPaths[vnode.Name] = vnode.DepotPath } // set the query params, "path" is required, "size" is optional diff --git a/vclusterops/https_create_nodes_depot_op.go b/vclusterops/https_create_nodes_depot_op.go index dd5f1db..4c1dee7 100644 --- a/vclusterops/https_create_nodes_depot_op.go +++ b/vclusterops/https_create_nodes_depot_op.go @@ -25,7 +25,7 @@ import ( type HTTPSCreateNodesDepotOp struct { OpBase OpHTTPSBase - HostNodeMap map[string]VCoordinationNode + HostNodeMap vHostNodeMap DepotSize string } diff --git a/vclusterops/https_get_nodes_info_op.go b/vclusterops/https_get_nodes_info_op.go index eceaa5e..24d18d0 100644 --- a/vclusterops/https_get_nodes_info_op.go +++ b/vclusterops/https_get_nodes_info_op.go @@ -99,7 +99,7 @@ func (op *httpsGetNodesInfoOp) processResult(_ *OpEngineExecContext) error { break } // save nodes info to vdb - op.vdb.HostNodeMap = make(map[string]VCoordinationNode) + op.vdb.HostNodeMap = makeVHostNodeMap() for _, node := range nodesStateInfo.NodeList { if node.Database != op.dbName { err = fmt.Errorf(`[%s] database %s is running on host %s, rather than database %s`, op.name, node.Database, host, op.dbName) @@ -117,7 +117,7 @@ func (op *httpsGetNodesInfoOp) processResult(_ *OpEngineExecContext) error { if node.IsPrimary && node.State == util.NodeUpState { op.vdb.PrimaryUpNodes = append(op.vdb.PrimaryUpNodes, node.Address) } - op.vdb.HostNodeMap[node.Address] = vNode + op.vdb.HostNodeMap[node.Address] = &vNode // extract catalog prefix from node's catalog path // catalog prefix is preceding db name dbPath := "/" + node.Database diff --git a/vclusterops/https_reload_spread_op.go b/vclusterops/https_reload_spread_op.go index f1bafd4..f730f24 100644 --- a/vclusterops/https_reload_spread_op.go +++ b/vclusterops/https_reload_spread_op.go @@ -27,11 +27,12 @@ type HTTPSReloadSpreadOp struct { OpHTTPSBase } -func makeHTTPSReloadSpreadOp(hosts []string, useHTTPPassword bool, +func makeHTTPSReloadSpreadOpWithInitiator(initHosts []string, + useHTTPPassword bool, userName string, httpsPassword *string) (HTTPSReloadSpreadOp, error) { httpsReloadSpreadOp := HTTPSReloadSpreadOp{} httpsReloadSpreadOp.name = "HTTPSReloadSpreadOp" - httpsReloadSpreadOp.hosts = hosts + httpsReloadSpreadOp.hosts = initHosts httpsReloadSpreadOp.useHTTPPassword = useHTTPPassword err := util.ValidateUsernameAndPassword(httpsReloadSpreadOp.name, useHTTPPassword, userName) @@ -43,6 +44,11 @@ func makeHTTPSReloadSpreadOp(hosts []string, useHTTPPassword bool, return httpsReloadSpreadOp, nil } +func makeHTTPSReloadSpreadOp(useHTTPPassword bool, + userName string, httpsPassword *string) (HTTPSReloadSpreadOp, error) { + return makeHTTPSReloadSpreadOpWithInitiator(nil, useHTTPPassword, userName, httpsPassword) +} + func (op *HTTPSReloadSpreadOp) setupClusterHTTPRequest(hosts []string) error { op.clusterHTTPRequest = ClusterHTTPRequest{} op.clusterHTTPRequest.RequestCollection = make(map[string]HostHTTPRequest) diff --git a/vclusterops/https_spread_remove_node_op.go b/vclusterops/https_spread_remove_node_op.go index 0c21201..5b08e9d 100644 --- a/vclusterops/https_spread_remove_node_op.go +++ b/vclusterops/https_spread_remove_node_op.go @@ -29,7 +29,7 @@ type HTTPSSpreadRemoveNodeOp struct { } func makeHTTPSSpreadRemoveNodeOp(hostsToRemove []string, initiatorHost []string, useHTTPPassword bool, - userName string, httpsPassword *string, hostNodeMap map[string]VCoordinationNode) (HTTPSSpreadRemoveNodeOp, error) { + userName string, httpsPassword *string, hostNodeMap vHostNodeMap) (HTTPSSpreadRemoveNodeOp, error) { op := HTTPSSpreadRemoveNodeOp{} op.name = "HTTPSSpreadRemoveNodeOp" op.hosts = initiatorHost diff --git a/vclusterops/nma_delete_dir_op.go b/vclusterops/nma_delete_dir_op.go index 0ae05ce..b169fc3 100644 --- a/vclusterops/nma_delete_dir_op.go +++ b/vclusterops/nma_delete_dir_op.go @@ -41,15 +41,15 @@ func (op *NMADeleteDirectoriesOp) buildRequestBody( forceDelete bool, ) error { op.hostRequestBodyMap = make(map[string]string) - for h := range vdb.HostNodeMap { + for h, vnode := range vdb.HostNodeMap { p := deleteDirParams{} // directories - p.Directories = append(p.Directories, vdb.HostNodeMap[h].CatalogPath) - p.Directories = append(p.Directories, vdb.HostNodeMap[h].StorageLocations...) + p.Directories = append(p.Directories, vnode.CatalogPath) + p.Directories = append(p.Directories, vnode.StorageLocations...) if vdb.UseDepot { dbDepotPath := filepath.Join(vdb.DepotPrefix, vdb.Name) - p.Directories = append(p.Directories, vdb.HostNodeMap[h].DepotPath, dbDepotPath) + p.Directories = append(p.Directories, vnode.DepotPath, dbDepotPath) } dbCatalogPath := filepath.Join(vdb.CatalogPrefix, vdb.Name) diff --git a/vclusterops/nma_download_file_op.go b/vclusterops/nma_download_file_op.go index a918aa4..1801c20 100644 --- a/vclusterops/nma_download_file_op.go +++ b/vclusterops/nma_download_file_op.go @@ -190,7 +190,7 @@ func (op *NMADownloadFileOp) processResult(execContext *OpEngineExecContext) err } // save descFileContent in vdb - op.vdb.HostNodeMap = make(map[string]VCoordinationNode) + op.vdb.HostNodeMap = makeVHostNodeMap() for _, node := range descFileContent.NodeList { op.vdb.HostList = append(op.vdb.HostList, node.Address) vNode := MakeVCoordinationNode() @@ -224,7 +224,7 @@ func (op *NMADownloadFileOp) processResult(execContext *OpEngineExecContext) err } } - op.vdb.HostNodeMap[node.Address] = vNode + op.vdb.HostNodeMap[node.Address] = &vNode } return nil } diff --git a/vclusterops/nma_get_nodes_info_op.go b/vclusterops/nma_get_nodes_info_op.go index a2e3cb1..6d6cc58 100644 --- a/vclusterops/nma_get_nodes_info_op.go +++ b/vclusterops/nma_get_nodes_info_op.go @@ -37,7 +37,7 @@ func makeNMAGetNodesInfoOp(hosts []string, op.dbName = dbName op.catalogPrefix = catalogPrefix op.vdb = vdb - op.vdb.HostNodeMap = make(map[string]VCoordinationNode) + op.vdb.HostNodeMap = makeVHostNodeMap() return op } @@ -87,7 +87,7 @@ func (op *nmaGetNodesInfoOp) processResult(_ *OpEngineExecContext) error { return errors.Join(allErrs, err) } vnode.Address = host - op.vdb.HostNodeMap[host] = vnode + op.vdb.HostNodeMap[host] = &vnode } else { allErrs = errors.Join(allErrs, result.err) } diff --git a/vclusterops/nma_load_remote_catalog_op.go b/vclusterops/nma_load_remote_catalog_op.go index 14a704d..b11813a 100644 --- a/vclusterops/nma_load_remote_catalog_op.go +++ b/vclusterops/nma_load_remote_catalog_op.go @@ -57,8 +57,8 @@ func makeNMALoadRemoteCatalogOp(oldHosts []string, communalStorageParameters map op.timeout = timeout op.primaryNodeCount = 0 - for host := range vdb.HostNodeMap { - if vdb.HostNodeMap[host].IsPrimary { + for _, vnode := range vdb.HostNodeMap { + if vnode.IsPrimary { op.primaryNodeCount++ } } diff --git a/vclusterops/nma_prepare_directories_op.go b/vclusterops/nma_prepare_directories_op.go index a0c1459..7213100 100644 --- a/vclusterops/nma_prepare_directories_op.go +++ b/vclusterops/nma_prepare_directories_op.go @@ -41,7 +41,7 @@ type prepareDirectoriesRequestData struct { IgnoreParent bool `json:"ignore_parent"` } -func makeNMAPrepareDirectoriesOp(hostNodeMap map[string]VCoordinationNode, +func makeNMAPrepareDirectoriesOp(hostNodeMap vHostNodeMap, forceCleanup, forRevive bool) (NMAPrepareDirectoriesOp, error) { nmaPrepareDirectoriesOp := NMAPrepareDirectoriesOp{} nmaPrepareDirectoriesOp.name = "NMAPrepareDirectoriesOp" @@ -58,7 +58,7 @@ func makeNMAPrepareDirectoriesOp(hostNodeMap map[string]VCoordinationNode, return nmaPrepareDirectoriesOp, nil } -func (op *NMAPrepareDirectoriesOp) setupRequestBody(hostNodeMap map[string]VCoordinationNode) error { +func (op *NMAPrepareDirectoriesOp) setupRequestBody(hostNodeMap vHostNodeMap) error { op.hostRequestBodyMap = make(map[string]string) for host := range hostNodeMap { diff --git a/vclusterops/remove_node.go b/vclusterops/remove_node.go index 8bfc5e8..2073e56 100644 --- a/vclusterops/remove_node.go +++ b/vclusterops/remove_node.go @@ -217,11 +217,10 @@ func (o *VRemoveNodeOptions) completeVDBSetting(vdb *VCoordinationDatabase) erro } } vdb.DepotPrefix = *o.DepotPrefix - hostNodeMap := make(map[string]VCoordinationNode) + hostNodeMap := makeVHostNodeMap() // we set the depot path manually because there is not yet an https endpoint for // that(VER-88122). This is useful for NMADeleteDirectoriesOp. - for h := range vdb.HostNodeMap { - vnode := vdb.HostNodeMap[h] + for h, vnode := range vdb.HostNodeMap { vnode.DepotPath = vdb.genDepotPath(vnode.Name) hostNodeMap[h] = vnode } @@ -304,7 +303,7 @@ func produceRemoveNodeInstructions(vdb *VCoordinationDatabase, options *VRemoveN if err != nil { return instructions, err } - httpsReloadSpreadOp, err := makeHTTPSReloadSpreadOp(initiatorHost, true, username, password) + httpsReloadSpreadOp, err := makeHTTPSReloadSpreadOpWithInitiator(initiatorHost, true, username, password) if err != nil { return instructions, err } @@ -343,7 +342,7 @@ func produceRebalanceSubclusterShardsOps(instructions *[]ClusterOp, initiatorHos // produces an HTTPSMarkEphemeralNodeOp. func produceMarkEphemeralNodeOps(instructions *[]ClusterOp, targetHosts, hosts []string, useHTTPPassword bool, userName string, httpsPassword *string, - hostNodeMap map[string]VCoordinationNode) error { + hostNodeMap vHostNodeMap) error { for _, host := range targetHosts { httpsMarkEphemeralNodeOp, err := makeHTTPSMarkEphemeralNodeOp(hostNodeMap[host].Name, hosts, useHTTPPassword, userName, httpsPassword) @@ -359,7 +358,7 @@ func produceMarkEphemeralNodeOps(instructions *[]ClusterOp, targetHosts, hosts [ // This is because we must drop node one by one to avoid losing quorum. func produceDropNodeOps(instructions *[]ClusterOp, targetHosts, hosts []string, useHTTPPassword bool, userName string, httpsPassword *string, - hostNodeMap map[string]VCoordinationNode, isEon bool) error { + hostNodeMap vHostNodeMap, isEon bool) error { for _, host := range targetHosts { httpsDropNodeOp, err := makeHTTPSDropNodeOp(hostNodeMap[host].Name, hosts, useHTTPPassword, userName, httpsPassword, isEon) diff --git a/vclusterops/remove_subcluster.go b/vclusterops/remove_subcluster.go index bc9e4af..1b0be63 100644 --- a/vclusterops/remove_subcluster.go +++ b/vclusterops/remove_subcluster.go @@ -230,8 +230,7 @@ func removeScPreCheck(vdb *VCoordinationDatabase, options *VRemoveScOptions) ([] } // get nodes of the to-be-removed subcluster - for h := range vdb.HostNodeMap { - vnode := vdb.HostNodeMap[h] + for h, vnode := range vdb.HostNodeMap { if vnode.Subcluster == *options.SubclusterToRemove { hostsToRemove = append(hostsToRemove, h) } diff --git a/vclusterops/restart_node.go b/vclusterops/restart_node.go index ac30f08..460fff8 100644 --- a/vclusterops/restart_node.go +++ b/vclusterops/restart_node.go @@ -48,7 +48,6 @@ func VRestartNodesOptionsFactory() VRestartNodesOptions { // set default values to the params opt.setDefaultValues() - opt.StatePollingTimeout = util.DefaultTimeoutSeconds return opt } @@ -139,6 +138,11 @@ func (vcc *VClusterCommands) VRestartNodes(options *VRestartNodesOptions) error options.Name = &dbName options.Hosts = hosts + // set default value to StatePollingTimeout + if options.StatePollingTimeout == 0 { + options.StatePollingTimeout = util.DefaultStatePollingTimeout + } + // retrieve database information to execute the command so we do not always rely on some user input vdb := MakeVCoordinationDatabase() err = getVDBFromRunningDB(&vdb, &options.DatabaseOptions) @@ -149,8 +153,8 @@ func (vcc *VClusterCommands) VRestartNodes(options *VRestartNodesOptions) error var hostsNoNeedToReIP []string hostNodeNameMap := make(map[string]string) restartNodeInfo := new(VRestartNodesInfo) - for host := range vdb.HostNodeMap { - hostNodeNameMap[vdb.HostNodeMap[host].Name] = vdb.HostNodeMap[host].Address + for _, vnode := range vdb.HostNodeMap { + hostNodeNameMap[vnode.Name] = vnode.Address } for nodename, newIP := range options.Nodes { oldIP, ok := hostNodeNameMap[nodename] @@ -246,7 +250,7 @@ func produceRestartNodesInstructions(restartNodeInfo *VRestartNodesInfo, options } // host is set to nil value in the reload spread step // we use information from node information to find the up host later - httpsReloadSpreadOp, e := makeHTTPSReloadSpreadOp(nil /*hosts*/, true, *options.UserName, options.Password) + httpsReloadSpreadOp, e := makeHTTPSReloadSpreadOp(true, *options.UserName, options.Password) if e != nil { return instructions, e } diff --git a/vclusterops/revive_db.go b/vclusterops/revive_db.go index e383f64..0512aaf 100644 --- a/vclusterops/revive_db.go +++ b/vclusterops/revive_db.go @@ -223,7 +223,7 @@ func produceReviveDBInstructions(options *VReviveDatabaseOptions, vdb *VCoordina } // create a new HostNodeMap to prepare directories - hostNodeMap := make(map[string]VCoordinationNode) + hostNodeMap := makeVHostNodeMap() // remove user storage locations from storage locations in every node // user storage location will not be force deleted, // and fail to create user storage location will not cause a failure of NMA /directories/prepare call. @@ -288,15 +288,15 @@ func (options *VReviveDatabaseOptions) generateReviveVDB(vdb *VCoordinationDatab ["192.168.1.102", "192.168.1.101", "192.168.1.103"] */ // sort nodes by their names, and then assign new hosts to them - var vNodes []VCoordinationNode - for host := range vdb.HostNodeMap { - vNodes = append(vNodes, vdb.HostNodeMap[host]) + var vNodes []*VCoordinationNode + for _, vnode := range vdb.HostNodeMap { + vNodes = append(vNodes, vnode) } sort.Slice(vNodes, func(i, j int) bool { return vNodes[i].Name < vNodes[j].Name }) - newVDB.HostNodeMap = make(map[string]VCoordinationNode) + newVDB.HostNodeMap = makeVHostNodeMap() if len(newVDB.HostList) != len(vNodes) { return newVDB, oldHosts, fmt.Errorf("the number of new hosts does not match the number of nodes in original database") } diff --git a/vclusterops/start_db.go b/vclusterops/start_db.go index 7cf25df..1e5105f 100644 --- a/vclusterops/start_db.go +++ b/vclusterops/start_db.go @@ -34,7 +34,6 @@ func VStartDatabaseOptionsFactory() VStartDatabaseOptions { // set default values to the params opt.SetDefaultValues() - opt.StatePollingTimeout = util.DefaultTimeoutSeconds return opt } @@ -106,6 +105,11 @@ func (vcc *VClusterCommands) VStartDatabase(options *VStartDatabaseOptions) erro options.Hosts = hosts options.CatalogPrefix = options.GetCatalogPrefix(config) + // set default value to StatePollingTimeout + if options.StatePollingTimeout == 0 { + options.StatePollingTimeout = util.DefaultStatePollingTimeout + } + // produce start_db instructions instructions, err := produceStartDBInstructions(options) if err != nil { diff --git a/vclusterops/util/defaults.go b/vclusterops/util/defaults.go index 4b0ad60..190982b 100644 --- a/vclusterops/util/defaults.go +++ b/vclusterops/util/defaults.go @@ -30,6 +30,7 @@ const ( DefaultRetryCount = 3 DefaultTimeoutSeconds = 300 DefaultLoadCatalogTimeoutSeconds = 3600 + DefaultStatePollingTimeout = 1200 DefaultLargeCluster = -1 MaxLargeCluster = 120 MinDepotSize = 0