Skip to content

Commit

Permalink
[PLAT-16425] Option to show experimental GFlags with list_flags API
Browse files Browse the repository at this point in the history
Summary: Add an option to show experimental GFlags with the list_flags API

Test Plan:
Ran list_gflags with and without the new showExperimental flags set to true and false

curl "http://10.150.1.8:9000/api/v1/metadata/version/2.20.7.0-b58/list_gflags?server=TSERVER&showExperimental=false"  --header 'X-AUTH-YW-API-TOKEN:3.a9190fe6-1067-409f-95cf-dbd96893c9c9.4c51b7de-7f45-46a1-b77f-e63ec1466a9a' | jq | grep -i experimental

No Experimental gflags shown

curl "http://10.150.1.8:9000/api/v1/metadata/version/2.20.7.0-b58/list_gflags?server=TSERVER&showExperimental=true"  --header 'X-AUTH-YW-API-TO
KEN:3.a9190fe6-1067-409f-95cf-dbd96893c9c9.4c51b7de-7f45-46a1-b77f-e63ec1466a9a' | jq | grep -i experimental
    "tags": "experimental"
    "tags": "experimental"
    "tags": "experimental,runtime"
    "tags": "experimental,runtime"
    "tags": "experimental,runtime"
    "tags": "experimental"
    "tags": "experimental,runtime"

Reviewers: daniel, vbansal, sneelakantan, #yba-api-review

Reviewed By: daniel, sneelakantan, #yba-api-review

Subscribers: yugaware

Differential Revision: https://phorge.dev.yugabyte.com/D41306
  • Loading branch information
Nikhil Bhatia committed Jan 17, 2025
1 parent d65a7c6 commit 3f14d3a
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,16 @@ public class GFlagsValidationUiOnlyController extends AuthenticatedController {
responseContainer = "List")
@YbaApi(visibility = YbaApi.YbaApiVisibility.PREVIEW, sinceYBAVersion = "2.20.9.0")
@AuthzPath
public Result listGFlags(String version, String gflag, String serverType, Boolean mostUsedGFlags)
public Result listGFlags(
String version,
String gflag,
String serverType,
Boolean mostUsedGFlags,
Boolean showExperimental)
throws IOException {
return PlatformResults.withData(
gflagsValidationHandler.listGFlags(version, gflag, serverType, mostUsedGFlags));
gflagsValidationHandler.listGFlags(
version, gflag, serverType, mostUsedGFlags, showExperimental));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public class GFlagsValidationHandler {
public static final Set<String> GFLAGS_FILTER_TAGS =
ImmutableSet.of("experimental", "hidden", "auto");

public static final Set<String> GFLAGS_FILTER_TAGS_ALLOW_EXPERIMENTAL =
ImmutableSet.of("hidden", "auto");

public static final Set<Pattern> GFLAGS_FILTER_PATTERN =
ImmutableSet.of(
Pattern.compile("^.*_test.*$", CASE_INSENSITIVE),
Expand All @@ -68,12 +71,17 @@ public class GFlagsValidationHandler {
.build();

public List<GFlagDetails> listGFlags(
String version, String gflag, String serverType, Boolean mostUsedGFlags) throws IOException {
String version,
String gflag,
String serverType,
Boolean mostUsedGFlags,
Boolean showExperimental)
throws IOException {
validateServerType(serverType);
validateVersionFormat(version);
List<GFlagDetails> gflagsList =
gflagsValidation.extractGFlags(version, serverType, mostUsedGFlags);
gflagsList = filterGFlagsList(gflagsList);
gflagsList = filterGFlagsList(gflagsList, showExperimental);
if (StringUtils.isEmpty(gflag)) {
return gflagsList;
}
Expand Down Expand Up @@ -266,7 +274,8 @@ private void validateServerType(String serverType) throws PlatformServiceExcepti
}
}

private List<GFlagDetails> filterGFlagsList(List<GFlagDetails> gflagsList) {
private List<GFlagDetails> filterGFlagsList(
List<GFlagDetails> gflagsList, Boolean showExperimental) {
return gflagsList.stream()
.filter(
flag ->
Expand All @@ -275,7 +284,9 @@ private List<GFlagDetails> filterGFlagsList(List<GFlagDetails> gflagsList) {
regexMatcher ->
!StringUtils.isEmpty(flag.name)
&& regexMatcher.matcher(flag.name).find())
&& !GFLAGS_FILTER_TAGS.stream()
&& !(showExperimental
? GFLAGS_FILTER_TAGS_ALLOW_EXPERIMENTAL.stream()
: GFLAGS_FILTER_TAGS.stream())
.anyMatch(
tags -> !StringUtils.isEmpty(flag.tags) && flag.tags.contains(tags))
&& !GFlagsUtil.GFLAGS_FORBIDDEN_TO_OVERRIDE.contains(flag.name))
Expand Down
6 changes: 6 additions & 0 deletions managed/src/main/resources/swagger-strict.json
Original file line number Diff line number Diff line change
Expand Up @@ -30776,6 +30776,12 @@
"name" : "mostUsedGFlags",
"required" : false,
"type" : "boolean"
}, {
"default" : false,
"in" : "query",
"name" : "showExperimental",
"required" : false,
"type" : "boolean"
} ],
"responses" : {
"200" : {
Expand Down
6 changes: 6 additions & 0 deletions managed/src/main/resources/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -32629,6 +32629,12 @@
"name" : "mostUsedGFlags",
"required" : false,
"type" : "boolean"
}, {
"default" : false,
"in" : "query",
"name" : "showExperimental",
"required" : false,
"type" : "boolean"
} ],
"responses" : {
"200" : {
Expand Down
2 changes: 1 addition & 1 deletion managed/src/main/resources/v1.routes
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ GET /customers/:cUUID/universes/:uniUUID/support_bundle/:sbUUID/download c
DELETE /customers/:cUUID/universes/:uniUUID/support_bundle/:sbUUID com.yugabyte.yw.controllers.SupportBundleController.delete(cUUID: java.util.UUID, uniUUID: java.util.UUID, sbUUID: java.util.UUID, request: Request)

# GFlags Validation API
GET /metadata/version/:version/list_gflags com.yugabyte.yw.controllers.GFlagsValidationUiOnlyController.listGFlags(version: String, name: String ?= "", server: String ?= "", mostUsedGFlags: java.lang.Boolean ?= false)
GET /metadata/version/:version/list_gflags com.yugabyte.yw.controllers.GFlagsValidationUiOnlyController.listGFlags(version: String, name: String ?= "", server: String ?= "", mostUsedGFlags: java.lang.Boolean ?= false, showExperimental: java.lang.Boolean ?= false)
POST /metadata/version/:version/validate_gflags com.yugabyte.yw.controllers.GFlagsValidationUiOnlyController.validateGFlags(version: String, request: Request)
GET /metadata/version/:version/gflag com.yugabyte.yw.controllers.GFlagsValidationUiOnlyController.getGFlagMetadata(version: String, name: String ?= "", server: String ?= "")

Expand Down

0 comments on commit 3f14d3a

Please sign in to comment.