Skip to content

2024.2.1.0-b12

@es1024 es1024 tagged this 01 Nov 19:06
Summary:
This change reduces boilerplate needed for some common gflag validators such as comparing against a value or another gflag, checking if a function returns OK, checking if a gflag is one of a few values. `DEFINE_validator` was extended to allow for a list of validators, which must all pass for a value to be valid, and a set of macros was added in flag_validators.h to create validators for common cases.

For example:
```
DEFINE_validator(
    pg_cron_leadership_refresh_sec,
    FLAG_LT_FLAG_VALIDATOR(pg_cron_leader_lease_sec));
```
to define a validator checking `pg_cron_leadership_refresh_sec` < `pg_cron_leader_lease_sec`, and
```
DEFINE_validator(
    protobuf_message_total_bytes_limit,
    FLAG_GT_FLAG_VALIDATOR(rpc_max_message_size),
    FLAG_LT_VALUE_VALIDATOR(512_MB));
```
to check that `rpc_max_message_size` < `protobuf_message_total_bytes_limit` < 512MB.

The missing reverse direction check for `rpc_max_message_size` < `protobuf_message_total_bytes_limit` and `pg_cron_leadership_refresh_sec` < `pg_cron_leader_lease_sec` were also added.
Jira: DB-13280

Original commit: 69540b88bc423b3b4c72024f4b8c143db178cfc4 / D38907

Test Plan:
Jenkins.

Also added test: `./yb_build.sh --gtest_filter FlagValidatorsTest.TestValidators`

Reviewers: hsunder, xCluster

Reviewed By: hsunder

Subscribers: yql, ybase

Differential Revision: https://phorge.dev.yugabyte.com/D39378
Assets 2
Loading