Skip to content

Refactor vtctld Flags to Use Hyphen-Based Naming Convention #18021

@mounicasruthi

Description

@mounicasruthi

This issue is part of the ongoing flag refactor project: Flag renaming: replace underscores with dashes (#17880). Vitess is moving toward standardizing all CLI flags to use hyphen (-) instead of underscore (_) delimiters. The vtctld binary currently uses a mix of these conventions.

Plan:

  • Both underscore and hyphen forms must be supported in v23 and v24
  • Underscore versions will be removed in v25

This issue focuses on migrating the flags in the vtctld binary to the new format.

Note: Related PR should be based off branch flags-refactor and not main.


Affected Binary

  • vtctld

Goal

Refactor all flags in vtctld to use dashed (-) notation instead of underscored (_), while continuing to support the old names during the deprecation period. Ensure codebase-wide consistency by updating flag usage in all references


Scope of Work

1. Flag Refactoring

Update the registration of the flags with (_) notation in the vtctld binary

Examples:

--action_timeout 
--backup_storage_block_size 
--tablet_manager_grpc_concurrency 
--vtctld_sanitize_log_messages 

Total flags: ~76

For each, convert from:

--backup_storage_block_size

to:

--backup-storage-block-size

Use the helpers from go/vt/utils/flags.go (already available):

  • SetFlagStringVar, SetFlagBoolVar, etc.
  • These helpers already register both dashed and underscored variants:
    • Marks the _ form as deprecated
    • Hides the _ form from help output

Use these helpers instead of direct pflag calls.


2. Codebase-wide Usage

Replace all underscored versions (--flag_name) with dashed versions (--flag-name) wherever they are used.

Do NOT Modify

  • .diff files
  • changelogs

Note: Upgrade/downgrade tests should continue using flags with underscores (--some_flag_example) to ensure backward compatibility. Add a comment in these places (if not already present) indicating that these should be replaced with dashed notation in v25.


3. Test File Handling

If any test files set these flags programmatically, replace code like:

flags["--backup_storage_block_size"] = "4096"

with:

SetFlagVariantsForTests(flags, "--backup_storage_block_size", "4096")

Or if accessing:

GetFlagVariantForTests("--backup_storage_block_size")

This ensures both variants are tested.
If needed, create more helper functions accordingly.


Flag Source Reference

The full list of current flags in vtctld is found here:

go/flags/endtoend/vtctld.txt

Use this to locate the exact flags that need renaming. All flags following the underscore (_) naming convention in this file should be refactored.


Testing

Ensure tests pass in both forms by:

  • Running unit and integration tests
  • Verifying that test code uses SetFlagVariantsForTests or GetFlagVariantForTests or other helper functions where applicable

📎 Related References


Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions