diff --git a/cmd/cluster/create_cluster.go b/cmd/cluster/create_cluster.go index 45cfffa7..8ca82824 100644 --- a/cmd/cluster/create_cluster.go +++ b/cmd/cluster/create_cluster.go @@ -42,7 +42,6 @@ var createClusterCmd = &cobra.Command{ logrus.Fatalf(ybmAuthClient.GetApiErrorDetails(err)) } authApi.GetInfo("", "") - asymmetricGeoEnabled := util.IsFeatureFlagEnabled(util.ASYMMETRIC_GEO) clusterName, _ := cmd.Flags().GetString("cluster-name") credentials, _ := cmd.Flags().GetStringToString("credentials") @@ -59,10 +58,8 @@ var createClusterCmd = &cobra.Command{ if changedNodeInfo { nodeConfig, _ := cmd.Flags().GetStringToInt("node-config") numCores, ok := nodeConfig["num-cores"] - if !asymmetricGeoEnabled && !ok { - logrus.Fatalln("Number of cores not specified in node config") - } - if asymmetricGeoEnabled && ok { + + if ok { defaultNumCores = numCores } if diskSizeGb, ok := nodeConfig["disk-size-gb"]; ok { @@ -98,15 +95,15 @@ var createClusterCmd = &cobra.Command{ regionInfoMap["vpc"] = val } case "num-cores": - if asymmetricGeoEnabled && len(strings.TrimSpace(val)) != 0 { + if len(strings.TrimSpace(val)) != 0 { regionInfoMap["num-cores"] = val } case "disk-size-gb": - if asymmetricGeoEnabled && len(strings.TrimSpace(val)) != 0 { + if len(strings.TrimSpace(val)) != 0 { regionInfoMap["disk-size-gb"] = val } case "disk-iops": - if asymmetricGeoEnabled && len(strings.TrimSpace(val)) != 0 { + if len(strings.TrimSpace(val)) != 0 { regionInfoMap["disk-iops"] = val } } @@ -118,13 +115,13 @@ var createClusterCmd = &cobra.Command{ if _, ok := regionInfoMap["num-nodes"]; !ok { logrus.Fatalln("Number of nodes not specified in region info") } - if _, ok := regionInfoMap["num-cores"]; asymmetricGeoEnabled && !ok && defaultNumCores > 0 { + if _, ok := regionInfoMap["num-cores"]; !ok && defaultNumCores > 0 { regionInfoMap["num-cores"] = strconv.Itoa(defaultNumCores) } - if _, ok := regionInfoMap["disk-size-gb"]; asymmetricGeoEnabled && !ok && defaultDiskSizeGb > 0 { + if _, ok := regionInfoMap["disk-size-gb"]; !ok && defaultDiskSizeGb > 0 { regionInfoMap["disk-size-gb"] = strconv.Itoa(defaultDiskSizeGb) } - if _, ok := regionInfoMap["disk-iops"]; asymmetricGeoEnabled && !ok && defaultDiskIops > 0 { + if _, ok := regionInfoMap["disk-iops"]; !ok && defaultDiskIops > 0 { regionInfoMap["disk-iops"] = strconv.Itoa(defaultDiskIops) } @@ -226,16 +223,11 @@ func init() { For AZURE: cloud-provider=AZURE,azu-client-id=,azu-client-secret=,azu-tenant-id=,azu-key-name=,azu-key-vault-uri=. If specified, all parameters for that provider are mandatory.`) - createClusterCmd.Flags().String("fault-tolerance", "", "[OPTIONAL] The fault tolerance domain of the cluster. The possible values are NONE, NODE, ZONE and REGION. Default NONE.") + createClusterCmd.Flags().String("fault-tolerance", "", "[OPTIONAL] Fault tolerance of the cluster. The possible values are NONE, NODE, ZONE, or REGION. Default NONE.") createClusterCmd.Flags().Int32("num-faults-to-tolerate", 0, "[OPTIONAL] The number of domain faults to tolerate for the level specified. The possible values are 0 for NONE, 1 for ZONE and [1-3] for anything else. Defaults to 0 for NONE, 1 otherwise.") - createClusterCmd.Flags().StringToInt("node-config", nil, "[OPTIONAL] Configuration of the cluster nodes. Please provide key value pairs num-cores=,disk-size-gb=,disk-iops= as the value. If specified, num-cores is mandatory, while disk-size-gb and disk-iops are optional.") - if util.IsFeatureFlagEnabled(util.ASYMMETRIC_GEO) { - createClusterCmd.Flags().MarkDeprecated("node-config", "please use --region-info to specify num-cores, disk-size-gb, and disk-iops") - createClusterCmd.Flags().StringArray("region-info", []string{}, `[OPTIONAL] Region information for the cluster. Please provide key value pairs region=,num-nodes=,vpc=,num-cores=,disk-size-gb=,disk-iops= as the value. If specified, region and num-nodes are mandatory, while num-cores, disk-size-gb, disk-iops, and vpc are optional. Information about multiple regions can be specified by using multiple --region-info arguments. Default if not specified is us-west-2 AWS region.`) - } else { - createClusterCmd.Flags().StringArray("region-info", []string{}, `[OPTIONAL] Region information for the cluster. Please provide key value pairs region=,num-nodes=,vpc= as the value. If specified, region and num-nodes are mandatory, vpc is optional. Information about multiple regions can be specified by using multiple --region-info arguments. Default if not specified is us-west-2 AWS region.`) - } - createClusterCmd.Flags().String("preferred-region", "", "[OPTIONAL] The preferred region in a multi region cluster. A preferred region is where all the reads and writes are handled.") - createClusterCmd.Flags().String("default-region", "", "[OPTIONAL] The default region in a geo partitioned cluster. A default region is where all the tables not created within a tablespace reside.") - + createClusterCmd.Flags().StringToInt("node-config", nil, "[OPTIONAL] Number of vCPUs and disk size per node for the cluster, provided as key-value pairs. Arguments are num-cores=,disk-size-gb=,disk-iops= (AWS only). num-cores is required.") + createClusterCmd.Flags().MarkDeprecated("node-config", "Deprecated. Use --region-info to specify num-cores, disk-size-gb, and disk-iops") + createClusterCmd.Flags().StringArray("region-info", []string{}, `Region information for the cluster, provided as key-value pairs. Arguments are region=,num-nodes=,vpc=,num-cores=,disk-size-gb=,disk-iops= (AWS only). region, num-nodes, num-cores, disk-size-gb are required. Specify one --region-info flag for each region in the cluster.`) + createClusterCmd.Flags().String("preferred-region", "", "[OPTIONAL] The preferred region in a multi region cluster. The preferred region handles all read and write requests from clients.") + createClusterCmd.Flags().String("default-region", "", "[OPTIONAL] The primary region in a partition-by-region cluster. The primary region is where all the tables not created in a tablespace reside.") } diff --git a/cmd/cluster/update_cluster.go b/cmd/cluster/update_cluster.go index 2dc1388f..34824cb5 100644 --- a/cmd/cluster/update_cluster.go +++ b/cmd/cluster/update_cluster.go @@ -24,7 +24,6 @@ import ( "github.com/sirupsen/logrus" "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/yugabyte/ybm-cli/cmd/util" ybmAuthClient "github.com/yugabyte/ybm-cli/internal/client" "github.com/yugabyte/ybm-cli/internal/formatter" ybmclient "github.com/yugabyte/yugabytedb-managed-go-client-internal" @@ -37,7 +36,6 @@ var updateClusterCmd = &cobra.Command{ Long: "Update a cluster", Run: func(cmd *cobra.Command, args []string) { - asymmetricGeoEnabled := util.IsFeatureFlagEnabled(util.ASYMMETRIC_GEO) clusterName, _ := cmd.Flags().GetString("cluster-name") authApi, err := ybmAuthClient.NewAuthApiClient() if err != nil { @@ -73,10 +71,8 @@ var updateClusterCmd = &cobra.Command{ if changedNodeInfo { nodeConfig, _ := cmd.Flags().GetStringToInt("node-config") numCores, ok := nodeConfig["num-cores"] - if !asymmetricGeoEnabled && !ok { - logrus.Fatalln("Number of cores not specified in node config") - } - if asymmetricGeoEnabled && ok { + + if ok { defaultNumCores = numCores } if diskSizeGb, ok := nodeConfig["disk-size-gb"]; ok { @@ -112,15 +108,15 @@ var updateClusterCmd = &cobra.Command{ regionInfoMap["vpc"] = val } case "num-cores": - if asymmetricGeoEnabled && len(strings.TrimSpace(val)) != 0 { + if len(strings.TrimSpace(val)) != 0 { regionInfoMap["num-cores"] = val } case "disk-size-gb": - if asymmetricGeoEnabled && len(strings.TrimSpace(val)) != 0 { + if len(strings.TrimSpace(val)) != 0 { regionInfoMap["disk-size-gb"] = val } case "disk-iops": - if asymmetricGeoEnabled && len(strings.TrimSpace(val)) != 0 { + if len(strings.TrimSpace(val)) != 0 { regionInfoMap["disk-iops"] = val } } @@ -132,13 +128,13 @@ var updateClusterCmd = &cobra.Command{ if _, ok := regionInfoMap["num-nodes"]; !ok { logrus.Fatalln("Number of nodes not specified in region info") } - if _, ok := regionInfoMap["num-cores"]; asymmetricGeoEnabled && !ok && defaultNumCores > 0 { + if _, ok := regionInfoMap["num-cores"]; !ok && defaultNumCores > 0 { regionInfoMap["num-cores"] = strconv.Itoa(defaultNumCores) } - if _, ok := regionInfoMap["disk-size-gb"]; asymmetricGeoEnabled && !ok && defaultDiskSizeGb > 0 { + if _, ok := regionInfoMap["disk-size-gb"]; !ok && defaultDiskSizeGb > 0 { regionInfoMap["disk-size-gb"] = strconv.Itoa(defaultDiskSizeGb) } - if _, ok := regionInfoMap["disk-iops"]; asymmetricGeoEnabled && !ok && defaultDiskIops > 0 { + if _, ok := regionInfoMap["disk-iops"]; !ok && defaultDiskIops > 0 { regionInfoMap["disk-iops"] = strconv.Itoa(defaultDiskIops) } @@ -209,15 +205,11 @@ func init() { updateClusterCmd.Flags().String("new-name", "", "[OPTIONAL] The new name to be given to the cluster.") updateClusterCmd.Flags().String("cloud-provider", "", "[OPTIONAL] The cloud provider where database needs to be deployed. AWS, AZURE or GCP.") updateClusterCmd.Flags().String("cluster-type", "", "[OPTIONAL] Cluster replication type. SYNCHRONOUS or GEO_PARTITIONED.") - updateClusterCmd.Flags().StringToInt("node-config", nil, "[OPTIONAL] Configuration of the cluster nodes. Please provide key value pairs num-cores=,disk-size-gb=,disk-iops= as the value. If provided, num-cores is mandatory, while disk-size-gb and disk-iops are optional.") - if util.IsFeatureFlagEnabled(util.ASYMMETRIC_GEO) { - updateClusterCmd.Flags().MarkDeprecated("node-config", "please use --region-info to specify num-cores, disk-size-gb, and disk-iops") - updateClusterCmd.Flags().StringArray("region-info", []string{}, `[OPTIONAL] Region information for the cluster. Please provide key value pairs, region=,num-nodes=,vpc=,num-cores=,disk-size-gb=,disk-iops= as the value. If specified, region and num-nodes are mandatory, while num-cores, disk-size-gb, disk-iops, and vpc are optional.`) - } else { - updateClusterCmd.Flags().StringArray("region-info", []string{}, `[OPTIONAL] Region information for the cluster. Please provide key value pairs, region=,num-nodes=,vpc= as the value. If provided, region and num-nodes are mandatory, vpc is optional.`) - } + updateClusterCmd.Flags().StringToInt("node-config", nil, "[OPTIONAL] Number of vCPUs and disk size per node for the cluster, provided as key-value pairs. Arguments are num-cores=,disk-size-gb=,disk-iops= (AWS only). num-cores is required.") + updateClusterCmd.Flags().MarkDeprecated("node-config", "Deprecated. Use --region-info to specify num-cores, disk-size-gb, and disk-iops.") + updateClusterCmd.Flags().StringArray("region-info", []string{}, `Region information for the cluster, provided as key-value pairs. Arguments are region=,num-nodes=,vpc=,num-cores=,disk-size-gb=,disk-iops= (AWS only). region, num-nodes, num-cores, disk-size-gb are required. Specify one --region-info flag for each region in the cluster.`) updateClusterCmd.Flags().String("cluster-tier", "", "[OPTIONAL] The tier of the cluster. Sandbox or Dedicated.") - updateClusterCmd.Flags().String("fault-tolerance", "", "[OPTIONAL] The fault tolerance domain of the cluster. The possible values are NONE, NODE, ZONE and REGION.") + updateClusterCmd.Flags().String("fault-tolerance", "", "[OPTIONAL] Fault tolerance of the cluster. The possible values are NONE, NODE, ZONE, or REGION. Default NONE.") updateClusterCmd.Flags().String("database-version", "", "[OPTIONAL] The database version of the cluster. Production or Innovation or Preview.") } @@ -295,17 +287,15 @@ func populateFlags(cmd *cobra.Command, originalSpec ybmclient.ClusterSpec, track regionInfo += ",vpc=" + vpcName } - if util.IsFeatureFlagEnabled(util.ASYMMETRIC_GEO) { - if nodeInfo, ok := clusterRegionInfo.GetNodeInfoOk(); ok { - if numCores, ok_ := nodeInfo.GetNumCoresOk(); ok_ { - regionInfo += ",num-cores=" + strconv.Itoa(int(*numCores)) - } - if diskSizeGb, ok_ := nodeInfo.GetDiskSizeGbOk(); ok_ { - regionInfo += ",disk-size-gb=" + strconv.Itoa(int(*diskSizeGb)) - } - if diskIops, ok_ := nodeInfo.GetDiskIopsOk(); ok_ && diskIops != nil { - regionInfo += ",disk-iops=" + strconv.Itoa(int(*diskIops)) - } + if nodeInfo, ok := clusterRegionInfo.GetNodeInfoOk(); ok { + if numCores, ok_ := nodeInfo.GetNumCoresOk(); ok_ { + regionInfo += ",num-cores=" + strconv.Itoa(int(*numCores)) + } + if diskSizeGb, ok_ := nodeInfo.GetDiskSizeGbOk(); ok_ { + regionInfo += ",disk-size-gb=" + strconv.Itoa(int(*diskSizeGb)) + } + if diskIops, ok_ := nodeInfo.GetDiskIopsOk(); ok_ && diskIops != nil { + regionInfo += ",disk-iops=" + strconv.Itoa(int(*diskIops)) } } regionInfoList = append(regionInfoList, regionInfo) diff --git a/cmd/util/feature_flags.go b/cmd/util/feature_flags.go index 84e63985..40726796 100644 --- a/cmd/util/feature_flags.go +++ b/cmd/util/feature_flags.go @@ -32,7 +32,6 @@ const ( AZURE_CIDR_ALLOWED FeatureFlag = "AZURE_CIDR_ALLOWED" ENTERPRISE_SECURITY FeatureFlag = "ENTERPRISE_SECURITY" INCREMENTAL_BACKUP FeatureFlag = "INCREMENTAL_BACKUP" - ASYMMETRIC_GEO FeatureFlag = "ASYMMETRIC_GEO" ) func (f FeatureFlag) String() string { diff --git a/docs/ybm_cluster_create.md b/docs/ybm_cluster_create.md index b4ba79ef..e6b60fe5 100644 --- a/docs/ybm_cluster_create.md +++ b/docs/ybm_cluster_create.md @@ -29,12 +29,11 @@ ybm cluster create [flags] For AZURE: cloud-provider=AZURE,azu-client-id=,azu-client-secret=,azu-tenant-id=,azu-key-name=,azu-key-vault-uri=. If specified, all parameters for that provider are mandatory. - --fault-tolerance string [OPTIONAL] The fault tolerance domain of the cluster. The possible values are NONE, NODE, ZONE and REGION. Default NONE. + --fault-tolerance string [OPTIONAL] Fault tolerance of the cluster. The possible values are NONE, NODE, ZONE, or REGION. Default NONE. --num-faults-to-tolerate int32 [OPTIONAL] The number of domain faults to tolerate for the level specified. The possible values are 0 for NONE, 1 for ZONE and [1-3] for anything else. Defaults to 0 for NONE, 1 otherwise. - --node-config stringToInt [OPTIONAL] Configuration of the cluster nodes. Please provide key value pairs num-cores=,disk-size-gb=,disk-iops= as the value. If specified, num-cores is mandatory, while disk-size-gb and disk-iops are optional. (default []) - --region-info stringArray [OPTIONAL] Region information for the cluster. Please provide key value pairs region=,num-nodes=,vpc= as the value. If specified, region and num-nodes are mandatory, vpc is optional. Information about multiple regions can be specified by using multiple --region-info arguments. Default if not specified is us-west-2 AWS region. - --preferred-region string [OPTIONAL] The preferred region in a multi region cluster. A preferred region is where all the reads and writes are handled. - --default-region string [OPTIONAL] The default region in a geo partitioned cluster. A default region is where all the tables not created within a tablespace reside. + --region-info stringArray Region information for the cluster, provided as key-value pairs. Arguments are region=,num-nodes=,vpc=,num-cores=,disk-size-gb=,disk-iops= (AWS only). region, num-nodes, num-cores, disk-size-gb are required. Specify one --region-info flag for each region in the cluster. + --preferred-region string [OPTIONAL] The preferred region in a multi region cluster. The preferred region handles all read and write requests from clients. + --default-region string [OPTIONAL] The primary region in a partition-by-region cluster. The primary region is where all the tables not created in a tablespace reside. -h, --help help for create ``` diff --git a/docs/ybm_cluster_update.md b/docs/ybm_cluster_update.md index fa56317b..4e061aef 100644 --- a/docs/ybm_cluster_update.md +++ b/docs/ybm_cluster_update.md @@ -18,11 +18,10 @@ ybm cluster update [flags] --cluster-tier string [OPTIONAL] The tier of the cluster. Sandbox or Dedicated. --cluster-type string [OPTIONAL] Cluster replication type. SYNCHRONOUS or GEO_PARTITIONED. --database-version string [OPTIONAL] The database version of the cluster. Production or Innovation or Preview. - --fault-tolerance string [OPTIONAL] The fault tolerance domain of the cluster. The possible values are NONE, NODE, ZONE and REGION. + --fault-tolerance string [OPTIONAL] Fault tolerance of the cluster. The possible values are NONE, NODE, ZONE, or REGION. Default NONE. -h, --help help for update --new-name string [OPTIONAL] The new name to be given to the cluster. - --node-config stringToInt [OPTIONAL] Configuration of the cluster nodes. Please provide key value pairs num-cores=,disk-size-gb=,disk-iops= as the value. If provided, num-cores is mandatory, while disk-size-gb and disk-iops are optional. (default []) - --region-info stringArray [OPTIONAL] Region information for the cluster. Please provide key value pairs, region=,num-nodes=,vpc= as the value. If provided, region and num-nodes are mandatory, vpc is optional. + --region-info stringArray Region information for the cluster, provided as key-value pairs. Arguments are region=,num-nodes=,vpc=,num-cores=,disk-size-gb=,disk-iops= (AWS only). region, num-nodes, num-cores, disk-size-gb are required. Specify one --region-info flag for each region in the cluster. ``` ### Options inherited from parent commands diff --git a/internal/client/client.go b/internal/client/client.go index da4aab14..d36e41f7 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -156,8 +156,6 @@ func (a *AuthApiClient) buildClusterSpec(cmd *cobra.Command, regionInfoList []ma var regionInfoProvided bool var err error - asymmetricGeoEnabled := util.IsFeatureFlagEnabled(util.ASYMMETRIC_GEO) - clusterRegionInfo := []ybmclient.ClusterRegionInfo{} totalNodes := 0 regionNodeInfoMap := map[string]*ybmclient.OptionalClusterNodeInfo{} @@ -195,31 +193,29 @@ func (a *AuthApiClient) buildClusterSpec(cmd *cobra.Command, regionInfoList []ma info.SetIsDefault(false) clusterRegionInfo = append(clusterRegionInfo, info) - if asymmetricGeoEnabled { - regionNodeInfo := ybmclient.NewOptionalClusterNodeInfo(0, 0, 0) - if numCores, ok := regionInfo["num-cores"]; ok { - i, err := strconv.Atoi(numCores) - if err != nil { - logrus.Fatalf("Unable to parse num-cores integer in %s", region) - } - regionNodeInfo.SetNumCores(int32(i)) + regionNodeInfo := ybmclient.NewOptionalClusterNodeInfo(0, 0, 0) + if numCores, ok := regionInfo["num-cores"]; ok { + i, err := strconv.Atoi(numCores) + if err != nil { + logrus.Fatalf("Unable to parse num-cores integer in %s", region) } - if diskSizeGb, ok := regionInfo["disk-size-gb"]; ok { - i, err := strconv.Atoi(diskSizeGb) - if err != nil { - logrus.Fatalf("Unable to parse disk-size-gb integer in %s", region) - } - regionNodeInfo.SetDiskSizeGb(int32(i)) + regionNodeInfo.SetNumCores(int32(i)) + } + if diskSizeGb, ok := regionInfo["disk-size-gb"]; ok { + i, err := strconv.Atoi(diskSizeGb) + if err != nil { + logrus.Fatalf("Unable to parse disk-size-gb integer in %s", region) } - if diskIops, ok := regionInfo["disk-iops"]; ok { - i, err := strconv.Atoi(diskIops) - if err != nil { - logrus.Fatalf("Unable to parse disk-iops integer in %s", region) - } - regionNodeInfo.SetDiskIops(int32(i)) + regionNodeInfo.SetDiskSizeGb(int32(i)) + } + if diskIops, ok := regionInfo["disk-iops"]; ok { + i, err := strconv.Atoi(diskIops) + if err != nil { + logrus.Fatalf("Unable to parse disk-iops integer in %s", region) } - regionNodeInfoMap[region] = regionNodeInfo + regionNodeInfo.SetDiskIops(int32(i)) } + regionNodeInfoMap[region] = regionNodeInfo } // This is to populate region in top level cloud info @@ -309,7 +305,7 @@ func (a *AuthApiClient) buildClusterSpec(cmd *cobra.Command, regionInfoList []ma cloud := string(cloudInfo.GetCode()) tier := string(clusterInfo.GetClusterTier()) - if asymmetricGeoEnabled && regionInfoProvided { + if regionInfoProvided { geoPartitioned := clusterInfo.GetClusterType() == "GEO_PARTITIONED" clusterNodeInfoWithDefaults := *ybmclient.NewClusterNodeInfoWithDefaults() // Create slice of desired regions. @@ -942,8 +938,7 @@ func (a *AuthApiClient) GetSupportedNodeConfigurationsV2(cloud string, tier stri // For geo clusters if FF is enabled, set isMultiRegion = false // For all other clusters, set isMultiRegion = true isMultiRegion := true - asymmetricGeoEnabled := util.IsFeatureFlagEnabled(util.ASYMMETRIC_GEO) - if len(regions) == 1 || cloud == "AZURE" || (geoPartitioned && asymmetricGeoEnabled) { + if len(regions) == 1 || cloud == "AZURE" || (geoPartitioned) { isMultiRegion = false } instanceResp, resp, err := a.ApiClient.ClusterApi.GetSupportedNodeConfigurations(a.ctx).AccountId(a.AccountID).Cloud(cloud).Tier(tier).Regions(regions).IsMultiRegion(isMultiRegion).Execute()