Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#23332] Docdb: Fix yb-admin to handle snapshot_retention correctly
Summary: After adding a Time To Live to the snapshots created by the user. The default TTL for snapshots before deleting them is 24 hours or the flag `default_snapshot_retention_hours`. However, users can override this default behaviour when creating a snapshot using `yb-admin` by providing the desired `retention_duration_hours` as a second argument to the `create_database_snapshot`. So if the user wants to leave the snapshot for 72 hours, he can issue: ``` ./bin/yb-admin --master_addresses $MASTERS create_database_snapshot ysql.db1 72 ``` However, yb_admin CLI is not accepting that the user set the second argument and returns `Invalid argument` error by mistake. Additionally, if the user wants to retain the snapshot forever, the instructions say: `(set a <= 0 value to retain the snapshot forever. If not specified then takes the default value controlled by gflag default_retention_hours)` However, if the user tries to set a negative value, the negative sign will be parsed as an option for yb-admin. Ex: ``` $ ./build/latest/bin/yb-admin --master_addresses 127.0.0.1:7100,127.0.0.2:7100,127.0.0.3:7100 create_database_snapshot ysql.db1 '-9' ERROR: unknown command line flag '9' ``` The diff fixes these issues by: 1- Accepting 1 or 2 arguments for `create_database_snapshot` 2- A simpler message to the user if he wants to retain the snapshot forever: `set retention_duration_hours to 0 to retain the snapshot forever.` Instead of telling the user to set it to negative value while that is not possible. Jira: DB-12259 Test Plan: Tested manually, by running the yb-admin command `create_database_snapshot` with and without the `retention_duration_hours` option set. The command was failing before this diff. Before this diff: ``` $ ./build/latest/bin/yb-admin --master_addresses 127.0.0.1:7100,127.0.0.2:7100,127.0.0.3:7100 create_database_snapshot ysql.db1 72 Error running create_database_snapshot: Invalid argument (yb/tools/yb-admin_cli.cc:91): Invalid arguments for operation Usage: ./build/latest/bin/yb-admin create_database_snapshot [ysql.]<database_name> [retention_duration_hours] (set a <= 0 value to retain the snapshot forever. If not specified then takes the default value controlled by gflag default_retention_hours) ``` After this diff it works as desired. Reviewers: zdrudi Reviewed By: zdrudi Subscribers: ybase, slingam Differential Revision: https://phorge.dev.yugabyte.com/D36936
- Loading branch information