Skip to content

Commit

Permalink
[PLAT-14801] add v2 API to list YBC Gflags metadata
Browse files Browse the repository at this point in the history
Summary:
Add the following v2 API
```
GET v2/metadata/list-ybc-gflags

Response:
[
    {
        "name": "cores_dir",
        "meaning": "Path to the cores directory",
        "default_value": "/home/yugabyte/cores",
        "type": "string"
    },
    {
        "name": "max_retries",
        "meaning": "Max number of retries.",
        "default_value": "10",
        "type": "int32"
    },...
]
```
The metadata was fetched from `yb-controller-server --help`

Test Plan: Added UT. Manually tested as well.

Reviewers: #yba-api-review, vkumar, sneelakantan

Reviewed By: #yba-api-review, sneelakantan

Subscribers: yugaware

Differential Revision: https://phorge.dev.yugabyte.com/D37793
  • Loading branch information
asharma-yb committed Sep 9, 2024
1 parent a3f3bfe commit a95dc94
Show file tree
Hide file tree
Showing 11 changed files with 431 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (c) YugaByte, Inc.

package api.v2.controllers;

import api.v2.handlers.BackupAndRestoreHandler;
import api.v2.models.GflagMetadata;
import com.google.inject.Inject;
import java.util.List;
import play.mvc.Http;

public class BackupAndRestoreApiControllerImp extends BackupAndRestoreApiControllerImpInterface {

@Inject BackupAndRestoreHandler backupAndRestoreHandler;

@Override
public List<GflagMetadata> listYbcGflagsMetadata(Http.Request request) throws Exception {
return backupAndRestoreHandler.listYbcGflagsMetadata(request);
}
}
18 changes: 18 additions & 0 deletions managed/src/main/java/api/v2/handlers/BackupAndRestoreHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) YugaByte, Inc.

package api.v2.handlers;

import api.v2.mappers.GflagsMetadataMapper;
import api.v2.models.GflagMetadata;
import com.google.inject.Singleton;
import com.yugabyte.yw.forms.ybc.YbcGflags;
import java.util.List;
import play.mvc.Http;

@Singleton
public class BackupAndRestoreHandler {

public List<GflagMetadata> listYbcGflagsMetadata(Http.Request request) {
return GflagsMetadataMapper.INSTANCE.toGflagMetadataList(YbcGflags.ybcGflagsMetadata.values());
}
}
22 changes: 22 additions & 0 deletions managed/src/main/java/api/v2/mappers/GflagsMetadataMapper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) YugaByte, Inc.

package api.v2.mappers;

import api.v2.models.GflagMetadata;
import com.yugabyte.yw.forms.ybc.YbcGflags.YbcGflagsMetadata;
import java.util.Collection;
import java.util.List;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

@Mapper(config = CentralConfig.class)
public interface GflagsMetadataMapper {
GflagsMetadataMapper INSTANCE = Mappers.getMapper(GflagsMetadataMapper.class);

@Mapping(source = "flagName", target = "name")
@Mapping(source = "defaultValue", target = "_default")
GflagMetadata toGflagMetadata(YbcGflagsMetadata metadata);

List<GflagMetadata> toGflagMetadataList(Collection<YbcGflagsMetadata> metadataList);
}
241 changes: 241 additions & 0 deletions managed/src/main/java/com/yugabyte/yw/forms/ybc/YbcGflags.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

package com.yugabyte.yw.forms.ybc;

import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;

Expand Down Expand Up @@ -57,4 +59,243 @@ public class YbcGflags {
String nfs_dirs;
String checksum_algorithm;
String curlopt_cainfo;

@AllArgsConstructor
public static class YbcGflagsMetadata {
public String flagName;
public String meaning;
public String defaultValue;
public String type;
}

public static Map<String, YbcGflagsMetadata> ybcGflagsMetadata =
Map.ofEntries(
Map.entry(
"cores_dir",
new YbcGflagsMetadata(
"cores_dir", "Path to the cores directory", "/home/yugabyte/cores", "string")),
Map.entry(
"exec_timeout_secs",
new YbcGflagsMetadata(
"exec_timeout_secs",
"Default timeout in seconds for any external command execution",
"86400",
"int32")),
Map.entry(
"k8s",
new YbcGflagsMetadata("k8s", "Is this running in Kubernetes", "false", "bool")),
Map.entry(
"redis_cli",
new YbcGflagsMetadata(
"redis_cli",
"Path to redis-cli",
"/home/yugabyte/tserver/bin/redis-cli",
"string")),
Map.entry(
"rocksdb_rel_path",
new YbcGflagsMetadata(
"rocksdb_rel_path",
"Path to the rocksdb data directory, relative to fs_data_dirs",
"/yb-data/tserver/data/rocksdb/",
"string")),
Map.entry(
"yb_admin",
new YbcGflagsMetadata(
"yb_admin", "Path to yb-admin", "/home/yugabyte/tserver/bin/yb-admin", "string")),
Map.entry(
"yb_ctl",
new YbcGflagsMetadata(
"yb_ctl", "Path to yb-ctl", "/home/yugabyte/tserver/bin/yb-ctl", "string")),
Map.entry(
"yb_master_address",
new YbcGflagsMetadata("yb_master_address", "address of yb-master", "", "string")),
Map.entry(
"yb_master_webserver_port",
new YbcGflagsMetadata(
"yb_master_webserver_port", "yb-master webserver port", "7000", "int32")),
Map.entry(
"yb_tserver_address",
new YbcGflagsMetadata(
"yb_tserver_address", "address of yb-tserver", "127.0.0.1", "string")),
Map.entry(
"yb_tserver_webserver_port",
new YbcGflagsMetadata(
"yb_tserver_webserver_port", "yb-tserver webserver port", "9000", "int32")),
Map.entry(
"ycqlsh",
new YbcGflagsMetadata(
"ycqlsh", "Path to ycqlsh", "/home/yugabyte/tserver/bin/ycqlsh", "string")),
Map.entry(
"ysql_dump",
new YbcGflagsMetadata(
"ysql_dump",
"Path to ysql_dump",
"/home/yugabyte/tserver/postgres/bin/ysql_dump",
"string")),
Map.entry(
"ysql_dumpall",
new YbcGflagsMetadata(
"ysql_dumpall",
"Path to ysql_dumpall",
"/home/yugabyte/tserver/postgres/bin/ysql_dumpall",
"string")),
Map.entry(
"allow_any_nfs_dir",
new YbcGflagsMetadata(
"allow_any_nfs_dir", "Allow use of any directory as nfs dir.", "true", "bool")),
Map.entry(
"ca_bundle_expiry_secs",
new YbcGflagsMetadata(
"ca_bundle_expiry_secs",
"Idle time before a ca-bundle is deleted",
"90000",
"int32")),
Map.entry(
"checksum_algorithm",
new YbcGflagsMetadata(
"checksum_algorithm",
"Checksum algorithm to use. Available options are SHA512, SHA256, XXH3_64,"
+ " XXH3_128",
"XXH3_64",
"string")),
Map.entry(
"curlopt_cainfo",
new YbcGflagsMetadata(
"curlopt_cainfo",
"System certificate bundle, defaults to one of /etc/pki/tls/certs/ca-bundle.crt,"
+ " /etc/ssl/certs/ca-certificates.crt or /etc/ssl/cert.pem depending on OS",
"",
"string")),
Map.entry(
"max_concurrent_downloads",
new YbcGflagsMetadata(
"max_concurrent_downloads",
"Max number of concurrent download tasks",
"2",
"int32")),
Map.entry(
"max_concurrent_uploads",
new YbcGflagsMetadata(
"max_concurrent_uploads", "Max number of concurrent upload tasks", "2", "int32")),
Map.entry(
"max_retries",
new YbcGflagsMetadata("max_retries", "Max number of retries.", "10", "int32")),
Map.entry(
"max_timeout_secs",
new YbcGflagsMetadata(
"max_timeout_secs", "Max timeout between retry.", "60", "int32")),
Map.entry(
"nfs_dirs",
new YbcGflagsMetadata(
"nfs_dirs",
"Comma separated list of nfs dirs that are authorized for use.",
"/nfs,/tmp/nfs",
"string")),
Map.entry(
"object_get_wait_ms",
new YbcGflagsMetadata(
"object_get_wait_ms",
"Time in milliseconds to wait for an object to be available in the pool.",
"200",
"int32")),
Map.entry(
"ops_num_threads",
new YbcGflagsMetadata(
"ops_num_threads",
"Number of threads to use for upload/download operations",
"0",
"int32")),
Map.entry(
"per_download_num_objects",
new YbcGflagsMetadata(
"per_download_num_objects",
"Number of objects in pool for each download operation",
"0",
"int32")),
Map.entry(
"per_upload_num_objects",
new YbcGflagsMetadata(
"per_upload_num_objects",
"Number of objects in pool for each upload operation",
"0",
"int32")),
Map.entry(
"rw_num_threads",
new YbcGflagsMetadata(
"rw_num_threads",
"Number of threads to use for read/write operations",
"0",
"int32")),
Map.entry(
"only_bind",
new YbcGflagsMetadata("only_bind", "Do only bind and exit", "false", "bool")),
Map.entry(
"disable_splitting_freq_secs",
new YbcGflagsMetadata(
"disable_splitting_freq_secs",
"Frequency at which to keep disabling tablet splitting while backup/restore is in"
+ " progress",
"60",
"int32")),
Map.entry(
"disable_splitting_ms",
new YbcGflagsMetadata(
"disable_splitting_ms",
"How long to disable tablet splitting for",
"120000",
"int32")),
Map.entry(
"num_api_threads",
new YbcGflagsMetadata(
"num_api_threads", "Number of threads to use for yb api", "0", "int32")),
Map.entry(
"use_yb_api",
new YbcGflagsMetadata(
"use_yb_api", "Use the yb api (if true) else use yb_admin", "true", "bool")),
Map.entry(
"yb_api_idle_check_secs",
new YbcGflagsMetadata(
"yb_api_idle_check_secs",
"Time between checks for idle yb_api connections",
"360",
"int32")),
Map.entry(
"yb_api_max_idle_secs",
new YbcGflagsMetadata(
"yb_api_max_idle_secs",
"Max idle time before the yb_api connection is removed",
"300",
"int32")),
Map.entry(
"yb_api_timeout_secs",
new YbcGflagsMetadata("yb_api_timeout_secs", "Timeout for Yb APIs", "600", "int32")),
Map.entry(
"yb_task_timeout_secs",
new YbcGflagsMetadata(
"yb_task_timeout_secs",
"Timeout for async tasks (such as snapshot create) launched on YB",
"7200",
"int32")),
Map.entry(
"log_filename",
new YbcGflagsMetadata(
"log_filename",
"Prefix of log filename - full path is"
+ " <log_dir>/<log_filename>.[INFO|WARN|ERROR|FATAL]",
"",
"string")),
Map.entry(
"hardware_concurrency",
new YbcGflagsMetadata(
"hardware_concurrency", "Number of cores to use", "2", "int32")),
Map.entry(
"tmp_dir",
new YbcGflagsMetadata("tmp_dir", "dir to use for tmp files", "/tmp", "string")),
Map.entry(
"ysqlsh",
new YbcGflagsMetadata(
"ysqlsh",
"Path to ysqlsh",
"/home/yugabyte/tserver/postgres/bin/ysqlsh",
"string")));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
description: OK
content:
application/json:
schema:
type: array
items:
$ref: "../schemas/GflagMetadata.yaml"
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
title: GflagMetadata
description: Metadata for Gflags of YB Controller.
type: object
properties:
name:
description: The name of the flag.
type: string
meaning:
description: A brief description of what the flag does.
type: string
default:
description: The default value of the flag.
type: string
type:
description: The data type of the flag.
type: string
2 changes: 2 additions & 0 deletions managed/src/main/resources/openapi/openapi_split.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ servers:
tags:
- name: Authentication
description: Authentication operations on YBA
- name: Backup and Restore
description: Operations related to universe backup and restore
- name: Continuous Backup
description: CRUD operations for Continuous YBA Backups
- name: Isolated Backup
Expand Down
25 changes: 25 additions & 0 deletions managed/src/main/resources/openapi/paths/_index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,31 @@
sourceType: endpoint
x-yba-api-since: 2024.2.0.0
x-yba-api-visibility: preview
/ybc/gflags-metadata:
get:
operationId: listYbcGflagsMetadata
summary: List YBC Gflags metadata
description: Get list of all YBC gflags and related metadata.
tags:
- Backup and Restore
responses:
'200':
$ref: "../components/responses/YbcGflagsResp.yaml"
'404':
description: Not found
security:
- apiKeyAuth: []
x-yba-api-audit:
noAudit: true
x-yba-api-authz:
- requiredPermission:
resourceType: other
action: read
resourceLocation:
path: customers
sourceType: endpoint
x-yba-api-since: 2024.2.0.0
x-yba-api-visibility: preview
'/customers/{cUUID}/auto-yba-backups':
parameters:
- name: cUUID
Expand Down
Loading

0 comments on commit a95dc94

Please sign in to comment.