Adds support for a YAML formatted parent.config file.#4857
Adds support for a YAML formatted parent.config file.#4857jrushford wants to merge 2 commits intoapache:masterfrom
Conversation
b1ab8a3 to
3b78b6d
Compare
|
[approve ci] |
2cc60ef to
0ac1129
Compare
|
Sorry for the delay, but there's a first pass. |
686a2da to
cd073f5
Compare
9f1ea4f to
e5cc7d6
Compare
|
|
||
| if (!label) { | ||
| continue; // Already use. | ||
| if (!line_info->config_is_yaml) { |
There was a problem hiding this comment.
Is this really switching formats on a per line basis? That seems a bit excessive. The file should be old style, or it should be YAML, but never both. I don't think ControlMatcher should ever be exposed to YAML configuration.
There was a problem hiding this comment.
@SolidWallOfCode It's not switching formats on a per line basis. For YAML, each node is parsed sequentially. I wanted to add YAML support making it optional, you only need to change the filename used from parent.config to parent.yaml to use YAML. It doesn't change the behavior of the current parent.config parser which is per line, that remains. For YAML, the entire file is loaded and you have a YAML sequence of maps basically for each parent entry. I have the ControlMatcher just reading enough of the YAML, each YAML Node in the sequence, so that it can allocate space by destination type, just as is currently done for the line by line config file. Once space has been allocated for each destination type, HostMatcher, IPMatcher, URLMatcher etc... will make a call to ParentSelection::Init() to parse the parent selection specific stuff which is then added to the appropriate matchers data structure.
ControlMatcher is parsing line-by-line now. With this PR, it will be able to use the YAML format as well.
There was a problem hiding this comment.
@SolidWallOfCode I made changes here and removed the unnecessary config_is_yaml bool. I am passing a pointer to the root yaml node though on each matcher_line but, it's either all yaml or all old style line format. The two are not mixed.
| * sequence when it is called. | ||
| * | ||
| */ | ||
| const std::string content{file_buf}; |
There was a problem hiding this comment.
you might want to look at ts::file::load, which reads the file contents directly in to a std::string, and avoid file_buf. You can pass the content string instead of file_buf if that's still needed.
There was a problem hiding this comment.
So this PR just adds YAML support without taking out the current line by line configuration. I just used the current code for reading the file.
There was a problem hiding this comment.
@SolidWallOfCode I went with YAML::Load(char *) here as the config file is already read by the current code.
| } while (0) | ||
|
|
||
| // set's the filename with a recognized yaml suffix for testing a yaml config. | ||
| #define REBUILD_YAML \ |
There was a problem hiding this comment.
Why #define instead of an inline function or lambda?
There was a problem hiding this comment.
@SolidWallOfCode This is only used for unit tests, see also REBUILD for the current unit-tests. Do you think I should change this?
There was a problem hiding this comment.
Yes. Test code should be held to the same coding standards as regular code.
There was a problem hiding this comment.
@SolidWallOfCode There are 212 tests using these test macros, T, REBUILD, REBUILD_YAML, REINIT, ST, RE, and FP. Would it be acceptable to create an issue to circle back and refactor the unit-tests in a separate PR as changing these to inline functions will require changing all the existing tests? Personally, I think this should be done in a separate PR.
|
[approve ci autest] |
d62e6da to
ac98738
Compare
ac98738 to
401ec25
Compare
401ec25 to
c1abd68
Compare
| const char *val; | ||
| matcher_type type = MATCH_NONE; | ||
|
|
||
| YAML::Node root = *(p->root_node); |
There was a problem hiding this comment.
Allright. The matcher_line contains a root_node which is presumed to be a list of objects, each of which has keys that correspond to the keys in tags. All the instances of p passed in point to the same root node? Why can't the matcher_line just point directly at the object?
ac4b5ef to
c11dcd7
Compare
3e60782 to
7aebaf0
Compare
|
@jrushford Looks like the build is failing on this. |
This PR adds YAML configuration support to the trafficserver parent.config file. By default, The current style line by line format is parsed and loaded. To use a YAML parent configuration file edit records.config and change "proxy.config.http.parent_proxy.file" so that the file name is "parent.yaml" instead of "parent.config".