Skip to content

Adds support for a YAML formatted parent.config file.#4857

Closed
jrushford wants to merge 2 commits intoapache:masterfrom
jrushford:parent_config_yml
Closed

Adds support for a YAML formatted parent.config file.#4857
jrushford wants to merge 2 commits intoapache:masterfrom
jrushford:parent_config_yml

Conversation

@jrushford
Copy link
Copy Markdown
Contributor

@jrushford jrushford commented Jan 24, 2019

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".

@jrushford jrushford self-assigned this Jan 24, 2019
@jrushford jrushford force-pushed the parent_config_yml branch 3 times, most recently from b1ab8a3 to 3b78b6d Compare January 24, 2019 23:04
@jrushford
Copy link
Copy Markdown
Contributor Author

[approve ci]

@jrushford jrushford force-pushed the parent_config_yml branch 2 times, most recently from 2cc60ef to 0ac1129 Compare January 25, 2019 20:47
Comment thread proxy/ParentYamlConfig.cc Outdated
Comment thread proxy/ParentYamlConfig.cc Outdated
Comment thread proxy/ParentYamlConfig.cc Outdated
Comment thread proxy/ParentYamlConfig.cc Outdated
Comment thread proxy/ParentYamlConfig.cc Outdated
Comment thread proxy/ParentYamlConfig.h Outdated
Comment thread proxy/ParentSelection.cc Outdated
Comment thread proxy/ParentYamlConfig.cc Outdated
Comment thread proxy/ParentYamlConfig.h Outdated
Comment thread proxy/ParentYamlConfig.h Outdated
Comment thread proxy/ParentYamlConfig.h Outdated
Comment thread proxy/ParentYamlConfig.h Outdated
Comment thread proxy/ParentYamlConfig.cc Outdated
@SolidWallOfCode
Copy link
Copy Markdown
Member

Sorry for the delay, but there's a first pass.

@jrushford jrushford force-pushed the parent_config_yml branch 4 times, most recently from 686a2da to cd073f5 Compare February 6, 2019 17:03
@jrushford jrushford force-pushed the parent_config_yml branch 3 times, most recently from 9f1ea4f to e5cc7d6 Compare March 1, 2019 21:12
@jrushford jrushford added Parent Proxy and removed WIP labels Mar 1, 2019
Comment thread configs/parent.schema.json
Comment thread proxy/ControlBase.cc Outdated

if (!label) {
continue; // Already use.
if (!line_info->config_is_yaml) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

@jrushford jrushford Mar 4, 2019

Choose a reason for hiding this comment

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

@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.

Copy link
Copy Markdown
Contributor Author

@jrushford jrushford Mar 5, 2019

Choose a reason for hiding this comment

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

@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.

Comment thread proxy/ControlBase.cc
Comment thread proxy/ControlMatcher.cc Outdated
* sequence when it is called.
*
*/
const std::string content{file_buf};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@SolidWallOfCode I went with YAML::Load(char *) here as the config file is already read by the current code.

Comment thread proxy/ParentSelection.cc Outdated
} while (0)

// set's the filename with a recognized yaml suffix for testing a yaml config.
#define REBUILD_YAML \
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why #define instead of an inline function or lambda?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@SolidWallOfCode This is only used for unit tests, see also REBUILD for the current unit-tests. Do you think I should change this?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes. Test code should be held to the same coding standards as regular code.

Copy link
Copy Markdown
Contributor Author

@jrushford jrushford Mar 6, 2019

Choose a reason for hiding this comment

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

@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.

@jrushford
Copy link
Copy Markdown
Contributor Author

[approve ci autest]

@jrushford jrushford force-pushed the parent_config_yml branch from d62e6da to ac98738 Compare March 6, 2019 17:15
@jrushford jrushford changed the title Update that adds a YAML format and parsing to the existing parent.config Adds support for a YAML formatted parent.config file. Mar 6, 2019
@jrushford jrushford force-pushed the parent_config_yml branch from ac98738 to 401ec25 Compare March 6, 2019 18:06
@jrushford jrushford force-pushed the parent_config_yml branch from 401ec25 to c1abd68 Compare April 6, 2019 03:52
Comment thread proxy/ControlBase.cc Outdated
Comment thread configs/parent.schema.json Outdated
Comment thread configs/parent.schema.json Outdated
Comment thread configs/parent.schema.json Outdated
Comment thread src/tscore/MatcherUtils.cc Outdated
const char *val;
matcher_type type = MATCH_NONE;

YAML::Node root = *(p->root_node);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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?

Comment thread src/tscore/MatcherUtils.cc Outdated
@jrushford jrushford force-pushed the parent_config_yml branch 3 times, most recently from ac4b5ef to c11dcd7 Compare May 20, 2019 21:13
@apache apache deleted a comment from jrushford May 23, 2019
Comment thread configs/parent.schema.json Outdated
Comment thread configs/parent.schema.json Outdated
Comment thread configs/parent.schema.json Outdated
@jrushford jrushford force-pushed the parent_config_yml branch from 3e60782 to 7aebaf0 Compare May 28, 2019 19:01
@bryancall
Copy link
Copy Markdown
Contributor

@jrushford Looks like the build is failing on this.

@apache apache deleted a comment from bryancall Jul 17, 2019
@jrushford jrushford closed this Jul 18, 2019
@zwoop zwoop removed this from the 9.0.0 milestone Aug 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants