Skip to content

traffic_ctl config convert remap#13053

Open
bneradt wants to merge 1 commit intoapache:masterfrom
bneradt:refactor-remapyaml-parsing
Open

traffic_ctl config convert remap#13053
bneradt wants to merge 1 commit intoapache:masterfrom
bneradt:refactor-remapyaml-parsing

Conversation

@bneradt
Copy link
Copy Markdown
Contributor

@bneradt bneradt commented Apr 2, 2026

Move ATS core off the remaining remap-only parsing path and route remap.config loading through the shared src/config remap parser. This lets traffic_ctl and traffic_server use the same conversion logic while leaving only runtime regex-mapping helpers in the remap loader.

This builds off of the work to support remap.yaml here: #12997

@bneradt bneradt added this to the 11.0.0 milestone Apr 2, 2026
@bneradt bneradt requested a review from masaori335 April 2, 2026 19:56
@bneradt bneradt self-assigned this Apr 2, 2026
@bneradt bneradt added Remap traffic_ctl traffic_ctl related work. labels Apr 2, 2026
Move ATS core off the remaining remap-only parsing path and
route remap.config loading through the shared src/config remap
parser. This lets traffic_ctl and traffic_server use the
same conversion logic while leaving only runtime regex-mapping helpers
in the remap loader.

This builds off of the work to support remap.yaml here: apache#12997
@bneradt bneradt force-pushed the refactor-remapyaml-parsing branch from 5c17ee4 to 22db9c6 Compare April 2, 2026 21:42
Comment thread src/config/remap.cc

constexpr swoc::Errata::Severity ERRATA_NOTE_SEV{static_cast<swoc::Errata::severity_type>(DL_Note)};
constexpr swoc::Errata::Severity ERRATA_ERROR_SEV{static_cast<swoc::Errata::severity_type>(DL_Error)};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I prefer YAML key names definition in the beginning.

Comment thread include/config/remap.h
namespace config
{

using RemapConfig = YAML::Node;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmm, can we define some struct describes remap.yaml node tree? It'll help us understanding type of node - int, string, list, map.

DbgCtl dbg_ctl_url_rewrite{"url_rewrite"};

swoc::Errata
parse_yaml_volume(const YAML::Node &node, url_mapping *url_mapping)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I feel these parsers in this file should moved to config/remap.cc

Copy link
Copy Markdown
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 moves remap configuration parsing/conversion onto the shared src/config remap parser so traffic_ctl and traffic_server can reuse the same remap.config → remap.yaml normalization and reduce legacy-only parsing paths in core.

Changes:

  • Add traffic_ctl config convert remap and gold tests for legacy remap.config → remap.yaml conversion output.
  • Introduce shared config::RemapParser / config::RemapMarshaller (src/config/remap.cc, include/config/remap.h) and corresponding unit tests.
  • Route UrlRewrite::BuildTable() through remap_parse_yaml() unconditionally, with remap_parse_yaml_bti() using the shared parser to accept legacy or YAML input.

Reviewed changes

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

Show a summary per file
File Description
tests/gold_tests/traffic_ctl/convert_remap/legacy_config/basic.config Adds legacy remap.config input fixture for conversion tests.
tests/gold_tests/traffic_ctl/convert_remap/gold/basic.yaml Adds expected remap.yaml output fixture for conversion tests.
tests/gold_tests/traffic_ctl/convert_remap/convert_remap.test.py Adds gold test coverage for traffic_ctl config convert remap (stdout + file output).
src/traffic_ctl/traffic_ctl.cc Registers the new traffic_ctl config convert remap subcommand.
src/traffic_ctl/ConvertConfigCommand.{h,cc} Implements remap conversion using the shared config remap parser/marshaller.
src/config/remap.cc / include/config/remap.h Adds shared remap parser/marshaller for legacy+YAML remap config.
src/config/unit_tests/test_remap.cc Adds unit tests for legacy conversion, round-trip, and error reporting.
src/proxy/http/remap/RemapYamlConfig.cc Switches YAML loader to use shared parser; adds YAML parsing for unique, tag, and volume.
src/proxy/http/remap/UrlRewrite.cc Removes legacy parse path selection; always calls remap_parse_yaml().
src/proxy/http/remap/RemapConfig.cc + include/proxy/http/remap/RemapConfig.h Removes legacy remap.config parsing implementation and leaves runtime helpers / BUILD_TABLE_INFO cleanup.
src/proxy/http/remap/unit-tests/test_RemapRules*.cc Updates remap unit tests to use the YAML parsing entry point and adds metadata coverage.
src/*/CMakeLists.txt Wires new config module + tests into builds and links remap code to ts::config.

Comment thread src/config/remap.cc
} else if (is_deactivate_filter_directive(directive)) {
entry["deactivate_filter"] = params[1];
} else if (directive == ".include") {
entry["include"] = params[1];
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

Legacy .include supports a list of file names (see remap.config docs), but this conversion only preserves params[1] and silently drops any additional include arguments. Consider emitting one include entry per provided path (i.e., loop params[1..] and push multiple include directives) so .include one.config two.config converts correctly.

Suggested change
entry["include"] = params[1];
for (size_t idx = 1; idx < params.size(); ++idx) {
YAML::Node include_entry{YAML::NodeType::Map};
include_entry["include"] = params[idx];
remap_entries.push_back(include_entry);
}
return errata;

Copilot uses AI. Check for mistakes.
Comment on lines +850 to 851
bool parse_success = remap_parse_yaml(path, this);

Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

BuildTable() now always routes through remap_parse_yaml(), which means legacy remap.config .include directives are handled by the YAML include path. That include path registers child files under ts::filename::REMAP_YAML, so changes to remap.config won't clear/update the registered children (FileManager only deletes children of the changed parent), potentially leaving stale include dependencies and causing spurious reloads. Consider registering included fragments under ts::filename::REMAP when the primary config being parsed is legacy remap.config (e.g., consult UrlRewrite::is_remap_yaml() when calling load_remap_file_cb).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Remap traffic_ctl traffic_ctl related work.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants