Skip to content

Conversation

@brbzull0
Copy link
Contributor

@brbzull0 brbzull0 commented Dec 11, 2025

Adds traffic_ctl config reset to reset configuration records to their default values. Supports both record name format (proxy.config.) and YAML format (records.) for path matching.

There is no new ATS rpc handler needed, it just use the existing API and checks for differences between current value and default value. This can be used eventually to reset any config without changing the semantic, just use whatever config node you need(if able to) to change.

This includes Autests.

Examples:

  traffic_ctl config reset records
  traffic_ctl config reset proxy.config.diags.debug.enabled
  traffic_ctl config reset records.diags

Adds `traffic_ctl config reset` to reset configuration records to their
default values. Supports both record name format (proxy.config.*) and
YAML format (records.*) for path matching.

There is no new ATS rpc handler needed it just use the existing API and
checks for differences between current value and default value.

This includes Autests.

Examples:
  traffic_ctl config reset records
  traffic_ctl config reset proxy.config.diags.debug.enabled
  traffic_ctl config reset records.diags
@brbzull0 brbzull0 self-assigned this Dec 11, 2025
@brbzull0 brbzull0 requested a review from Copilot December 11, 2025 14:26
@brbzull0 brbzull0 added traffic_ctl traffic_ctl related work. Records Records related code. labels Dec 11, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new traffic_ctl config reset command that allows resetting configuration records to their default values. The implementation leverages existing RPC APIs by fetching records that match the provided path patterns, comparing current values against defaults, and using the existing set API to restore default values. The command supports both traditional record name format (proxy.config.*) and YAML format (records.*), with automatic conversion between the two.

Key changes:

  • Implements config_reset() method that uses regex-based record lookup to identify modified records and resets them to defaults
  • Adds helper function yaml_to_record_name() to convert YAML-style paths to record name format
  • Refactors test utilities to use a cleaner inheritance model with shared _finish() method and adds new validation helpers

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/traffic_ctl/CtrlCommands.cc Implements core reset logic: lookup matching records, filter modified ones, and reset to defaults via existing set API
src/traffic_ctl/CtrlCommands.h Adds RESET_STR constant and config_reset() method declaration
src/traffic_ctl/traffic_ctl.cc Registers new "reset" subcommand with CLI parser
src/mgmt/rpc/handlers/config/Configuration.cc Adds blank line for formatting consistency
tests/gold_tests/traffic_ctl/traffic_ctl_test_utils.py Refactors test utilities with cleaner inheritance, adds validate_contains_all() and exec() methods, updates validate_with_text() to handle empty output
tests/gold_tests/traffic_ctl/traffic_ctl_config_output.test.py Adds comprehensive test coverage for reset command including single record, partial path, all records, and YAML-style path scenarios
doc/appendices/command-line/traffic_ctl.en.rst Documents reset command with examples showing both record name and YAML format usage

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@brbzull0 brbzull0 marked this pull request as ready for review December 12, 2025 16:32
@brbzull0 brbzull0 added this to the 10.2.0 milestone Dec 12, 2025
@bryancall bryancall requested a review from serrislew December 15, 2025 22:43
.. option:: reset PATH [PATH ...]

Reset configuration record(s) to their default values. The PATH argument is used as a
regex pattern to match against record names. Multiple paths at once can be provided.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not really a regex pattern right? It's just prefix of the config. Can users put a full regex expression in the argument?

@serrislew
Copy link
Contributor

I like this idea but I wonder if it might be confusing that values return to default values as opposed to init values (what the user defined in files which got changed by traffic_ctl). When I think of reset, I think about returning values to the startup state, not the default state (as if I didn't configure anything). This might be a bit nitpicky, just wanted to share my thoughts.

@brbzull0
Copy link
Contributor Author

I like this idea but I wonder if it might be confusing that values return to default values as opposed to init values (what the user defined in files which got changed by traffic_ctl). When I think of reset, I think about returning values to the startup state, not the default state (as if I didn't configure anything). This might be a bit nitpicky, just wanted to share my thoughts.

Let me add a bit of context:

$ traffic_ctl config diff --records
records:
  diags:
    debug:
      enabled: 1  # default: 0
      tags: rpc|http|ssl|config$|filem # default: http|dns
    show_location: 2  # default: 1
  exec_thread:
    autoconfig:
      enabled: 0  # default: 1
    limit: 1  # default: 2
  http:
    connect:
      down:
        policy: 0  # default: 2

note the # default X beside each value. This values are what is set at compile time and used as default if nothing set in the record.yaml.
So you have the running value(if changed) and the default value, the reset basically means, let's set what's changed in the records.yaml to it's default value.
This only affect records for now.

How this is useful? This actually came from a need I had when testing some cve bugs, a simple flow would be.

1 - I have a working ATS running, with my own config.
2 - A patch/use case/bug needs to be tested. More likely without all our local changes in the records.yaml.
3 (new)- Run traffic_ctl config reset and it will only change the values a runtime, once you restart ats, it will still use records.yaml.

Without this feature, you would need to copy/save/edit your records.yaml just to do the test, instead of just run reset.

Thanks.

NOTE: traffic_ctl config diff --records the --records option is misleading in this case as in this case it refers to the format of the output(legacy, backguard compatibility)... honestly should be --yaml or something else.

@serrislew
Copy link
Contributor

Ah I see. Thank you for providing that context and explanation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Records Records related code. traffic_ctl traffic_ctl related work.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants