Skip to content

Commit

Permalink
[yugabyte#20046] DocDB: get_auto_flags_config yb-admin command
Browse files Browse the repository at this point in the history
Summary:
`get_auto_flags_config` yb-admin command is added which will return the current AutoFlags config.

Fixes yugabyte#20046
Jira: DB-9009

Test Plan: AdminCliTest.GetAutoFlagsConfig

Reviewers: rahuldesirazu, slingam

Reviewed By: rahuldesirazu, slingam

Subscribers: ybase

Differential Revision: https://phorge.dev.yugabyte.com/D30529
  • Loading branch information
hari90 committed Nov 28, 2023
1 parent 4bb33b7 commit fbb29e8
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/yb/tools/yb-admin-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,14 @@ TEST_F_EX(AdminCliTest, ListTabletDefaultTenTablets, AdminCliListTabletsTest) {
ASSERT_EQ(count, 20);
}

TEST_F(AdminCliTest, GetAutoFlagsConfig) {
BuildAndStart();
auto message = ASSERT_RESULT(CallAdmin("get_auto_flags_config"));
ASSERT_STR_CONTAINS(message, R"#(AutoFlags config:
config_version: 1
promoted_flags {)#");
}

TEST_F(AdminCliTest, PromoteAutoFlags) {
BuildAndStart();
const auto master_address = ToString(cluster_->master()->bound_rpc_addr());
Expand Down
8 changes: 8 additions & 0 deletions src/yb/tools/yb-admin_cli.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1228,6 +1228,13 @@ Status get_wal_retention_secs_action(
return Status::OK();
}

const auto get_auto_flags_config_args = "";
Status get_auto_flags_config_action(
const ClusterAdminCli::CLIArguments& args, ClusterAdminClient* client) {
RETURN_NOT_OK_PREPEND(client->GetAutoFlagsConfig(), "Unable to get AutoFlags config");
return Status::OK();
}

const auto promote_auto_flags_args =
"[<max_flags_class> (default kExternal) [<promote_non_runtime_flags> (default true) [force]]]";
Status promote_auto_flags_action(
Expand Down Expand Up @@ -2231,6 +2238,7 @@ void ClusterAdminCli::RegisterCommandHandlers() {
REGISTER_COMMAND(upgrade_ysql);
REGISTER_COMMAND(set_wal_retention_secs);
REGISTER_COMMAND(get_wal_retention_secs);
REGISTER_COMMAND(get_auto_flags_config);
REGISTER_COMMAND(promote_auto_flags);
REGISTER_COMMAND(rollback_auto_flags);
REGISTER_COMMAND(promote_single_auto_flag);
Expand Down
16 changes: 16 additions & 0 deletions src/yb/tools/yb-admin_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,22 @@ Status ClusterAdminClient::GetWalRetentionSecs(const YBTableName& table_name) {
return Status::OK();
}

Status ClusterAdminClient::GetAutoFlagsConfig() {
master::GetAutoFlagsConfigRequestPB req;
master::GetAutoFlagsConfigResponsePB resp;
rpc::RpcController rpc;
rpc.set_timeout(timeout_);
RETURN_NOT_OK(master_cluster_proxy_->GetAutoFlagsConfig(req, &resp, &rpc));
if (resp.has_error()) {
return StatusFromPB(resp.error().status());
}

std::cout << "AutoFlags config:" << std::endl;
std::cout << resp.config().DebugString() << std::endl;

return Status::OK();
}

Status ClusterAdminClient::PromoteAutoFlags(
const string& max_flag_class, const bool promote_non_runtime_flags, const bool force) {
master::PromoteAutoFlagsRequestPB req;
Expand Down
2 changes: 2 additions & 0 deletions src/yb/tools/yb-admin_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ class ClusterAdminClient {

Status GetWalRetentionSecs(const client::YBTableName& table_name);

Status GetAutoFlagsConfig();

Status PromoteAutoFlags(
const std::string& max_flag_class, const bool promote_non_runtime_flags, const bool force);

Expand Down

0 comments on commit fbb29e8

Please sign in to comment.