Skip to content

Commit

Permalink
[BACKPORT 2024.2][PLAT-16442][YBA CLI]Change error message in gflags …
Browse files Browse the repository at this point in the history
…upgrade cmd

Summary:
We show Universe, Operation: Upgrade GFlags - 400 Bad Request: No changes in gflags (modify specificGflags in cluster)
even when cluster is not present. Adding a better error message would help users debug faster

Original commit: 99210dc / D41119

Test Plan:
```
yba universe upgrade gflags set -n dkumar-cli-1 -o pretty --specific-gflags '[
    {
        "SpecificGFlags": {
            "inheritFromPrimary": false,
            "perAZ": {},
            "perProcessFlags": {
                "MASTER": {
                    "callhome_enabled": "false",
                    "max_log_size": "512",
                    "log_max_seconds_to_retain": "86450"
                },
                "TSERVER": {
                    "callhome_enabled": "false",
                    "max_log_size": "512",
                    "log_max_seconds_to_retain": "86450"
                }
            }
        },
        "ClusterType": "PRIMARY",
        "ClusterUUID": "adec578a-5e8d-4b1c-b830-ec7df3ef4084"
    }
]'
? Are you sure you want to upgrade Gflags universe: dkumar-cli-1 Yes
Cluster adec578a-5e8d-4b1c-b830-ec7df3ef4084 (PRIMARY) not found in universe
```

Reviewers: skurapati

Reviewed By: skurapati

Subscribers: yugaware

Differential Revision: https://phorge.dev.yugabyte.com/D41120
  • Loading branch information
Deepti-yb committed Jan 9, 2025
1 parent f984a8f commit f49e56b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
14 changes: 12 additions & 2 deletions managed/yba-cli/cmd/universe/upgrade/gflags/set_gflagsuniverse.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ var setGflagsUniverseCmd = &cobra.Command{
clusterType := clusters[i].GetClusterType()
clusterUUID := clusters[i].GetUuid()
for _, gflags := range cliSpecificGFlags {
isClusterInRequestBodyWIthValidUUID := false
if strings.Compare(strings.ToUpper(clusterType), strings.ToUpper(gflags.ClusterType)) == 0 {
if strings.Compare(clusterUUID, gflags.ClusterUUID) == 0 {
logrus.Debugf(
Expand All @@ -160,8 +161,17 @@ var setGflagsUniverseCmd = &cobra.Command{
clusterType)
clusterUserIntent.SetSpecificGFlags(specificGFlags[i])
clusters[i].SetUserIntent(clusterUserIntent)
isClusterInRequestBodyWIthValidUUID = true
}
}
if !isClusterInRequestBodyWIthValidUUID {
logrus.Fatal(
formatter.Colorize(
"Cluster "+ gflags.ClusterUUID + " (" + gflags.ClusterType+
")" +" not found in universe\n",
formatter.RedColor,
))
}
}
}

Expand Down Expand Up @@ -213,15 +223,15 @@ func init() {
"[Optional] Specific gflags to be set. "+
"Use the modified output of \"yba universe upgrade gflags get\" command "+
"as the flag value. Quote the string with single quotes. %s",
formatter.Colorize("Provider either specific-gflags or specific-gflags-file-path",
formatter.Colorize("Provide either specific-gflags or specific-gflags-file-path",
formatter.GreenColor)))

setGflagsUniverseCmd.Flags().String("specific-gflags-file-path", "",
fmt.Sprintf(
"[Optional] Path to modified json output file of"+
" \"yba universe upgrade gflags get\" command. %s",
formatter.Colorize(
"Provider either specific-gflags or specific-gflags-file-path",
"Provide either specific-gflags or specific-gflags-file-path",
formatter.GreenColor),
))

Expand Down
4 changes: 2 additions & 2 deletions managed/yba-cli/cmd/user/create_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func init() {
fmt.Sprintf(
"[Optional] The role of the user. "+
formatter.Colorize(
"Provider either role or role-resource-definition.",
"Provide either role or role-resource-definition.",
formatter.GreenColor)+
" Allowed values (case sensitive): "+
"ConnectOnly, ReadOnly, BackupAdmin, Admin, SuperAdmin. %s"+
Expand All @@ -166,7 +166,7 @@ func init() {
createUserCmd.Flags().StringArray("role-resource-definition", []string{},
"[Optional] Role resource bindings for the user. "+
formatter.Colorize(
"Provider either role or role-resource-definition.",
"Provide either role or role-resource-definition.",
formatter.GreenColor)+
" Provide the following double colon (::) separated fields as key-value pairs:"+
"\"role-uuid=<role-uuid>::allow-all=<true/false>::resource-type=<resource-type>"+
Expand Down
4 changes: 2 additions & 2 deletions managed/yba-cli/docs/yba_universe_upgrade_gflags_set.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ yba universe upgrade gflags set -n <universe-name> \
### Options

```
--specific-gflags string [Optional] Specific gflags to be set. Use the modified output of "yba universe upgrade gflags get" command as the flag value. Quote the string with single quotes. Provider either specific-gflags or specific-gflags-file-path
--specific-gflags-file-path string [Optional] Path to modified json output file of "yba universe upgrade gflags get" command. Provider either specific-gflags or specific-gflags-file-path
--specific-gflags string [Optional] Specific gflags to be set. Use the modified output of "yba universe upgrade gflags get" command as the flag value. Quote the string with single quotes. Provide either specific-gflags or specific-gflags-file-path
--specific-gflags-file-path string [Optional] Path to modified json output file of "yba universe upgrade gflags get" command. Provide either specific-gflags or specific-gflags-file-path
--upgrade-option string [Optional] Upgrade Options, defaults to Rolling. Allowed values (case sensitive): Rolling, Non-Rolling (involves DB downtime), Non-Restart (default "Rolling")
--delay-between-master-servers int32 [Optional] Upgrade delay between Master servers (in miliseconds). (default 18000)
--delay-between-tservers int32 [Optional] Upgrade delay between Tservers (in miliseconds). (default 18000)
Expand Down
4 changes: 2 additions & 2 deletions managed/yba-cli/docs/yba_user_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ yba user create --email <email> --password <password> --role <role>
--email string [Required] The email of the user to be created. (default "e")
--password string [Required] Password for the user. Password must contain at least 8 characters and at least 1 digit , 1 capital , 1 lowercase and 1 of the !@#$^&* (special) characters. Use single quotes ('') to provide values with special characters.
--timezone string [Optional] The timezone of the user.
--role string [Optional] The role of the user. Provider either role or role-resource-definition. Allowed values (case sensitive): ConnectOnly, ReadOnly, BackupAdmin, Admin, SuperAdmin. Use only when "yb.rbac.use_new_authz" runtime configuration is set to false. Use role-resource-definition otherwise.
--role-resource-definition stringArray [Optional] Role resource bindings for the user. Provider either role or role-resource-definition. Provide the following double colon (::) separated fields as key-value pairs:"role-uuid=<role-uuid>::allow-all=<true/false>::resource-type=<resource-type>::resource-uuid=<resource-uuid1>,<resource-uuid2>,<resource-uuid3>". Role UUID is a required value. Allowed values for resource type are universe, role, user, other. If resource UUID list is empty, default for allow all is true. If the role given is a system role, resource type, allow all and resource UUID must be empty. Add multiple resource types for each role UUID using separate --role-resource-definition flags. Each binding needs to be added using a separate --role-resource-definition flag. Example: --role-resource-definition role-uuid=<role-uuid1>::resource-type=<resource-type1>::resource-uuid=<resource-uuid1>,<resource-uuid2>,<resource-uuid3> --role-resource-definition role-uuid=<role-uuid2>::resource-type=<resource-type1>::resource-uuid=<resource-uuid1>,<resource-uuid2>,<resource-uuid3> --role-resource-definition role-uuid=<role-uuid2>::resource-type=<resource-type2>::resource-uuid=<resource-uuid1>,<resource-uuid2>,<resource-uuid3>
--role string [Optional] The role of the user. Provide either role or role-resource-definition. Allowed values (case sensitive): ConnectOnly, ReadOnly, BackupAdmin, Admin, SuperAdmin. Use only when "yb.rbac.use_new_authz" runtime configuration is set to false. Use role-resource-definition otherwise.
--role-resource-definition stringArray [Optional] Role resource bindings for the user. Provide either role or role-resource-definition. Provide the following double colon (::) separated fields as key-value pairs:"role-uuid=<role-uuid>::allow-all=<true/false>::resource-type=<resource-type>::resource-uuid=<resource-uuid1>,<resource-uuid2>,<resource-uuid3>". Role UUID is a required value. Allowed values for resource type are universe, role, user, other. If resource UUID list is empty, default for allow all is true. If the role given is a system role, resource type, allow all and resource UUID must be empty. Add multiple resource types for each role UUID using separate --role-resource-definition flags. Each binding needs to be added using a separate --role-resource-definition flag. Example: --role-resource-definition role-uuid=<role-uuid1>::resource-type=<resource-type1>::resource-uuid=<resource-uuid1>,<resource-uuid2>,<resource-uuid3> --role-resource-definition role-uuid=<role-uuid2>::resource-type=<resource-type1>::resource-uuid=<resource-uuid1>,<resource-uuid2>,<resource-uuid3> --role-resource-definition role-uuid=<role-uuid2>::resource-type=<resource-type2>::resource-uuid=<resource-uuid1>,<resource-uuid2>,<resource-uuid3>
-h, --help help for create
```

Expand Down

0 comments on commit f49e56b

Please sign in to comment.