-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
config: support extrinsic yaml anchor declarations #16543
config: support extrinsic yaml anchor declarations #16543
Conversation
Signed-off-by: Mike Schore <[email protected]>
Signed-off-by: Mike Schore <[email protected]>
Signed-off-by: Mike Schore <[email protected]>
/retest |
Retrying Azure Pipelines: |
Is there an appropriate docs change you've identified so this is highlighted in the release? Seems rather buried. You may need to merge main again to pick up newer coverage thresholds for quic and pass CI. |
Signed-off-by: Mike Schore <[email protected]>
Signed-off-by: Mike Schore <[email protected]>
Merged main and added documentation*. |
Signed-off-by: Mike Schore <[email protected]>
Signed-off-by: Mike Schore <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks this looks great to me! Maybe include a version note about this?
@phlax this change might be interesting to you if you want to take a look, maybe there are use cases for this in existing documentation/examples
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @goaway i defo like the idea but i had some issues with trying to load the config with the python parser
i would really appreciate if you could move the config (edit: this) to a literalinclude as it means the config will be tested loading in Envoy
.. validated-code-block:: yaml | ||
:type-name: envoy.config.bootstrap.v3.Bootstrap | ||
|
||
dynamic_sockets: !ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the issue with this afaict is that it means the config is not loadable with a standard yaml parser - at least trying to load it with pyyaml failed
yaml.constructor.ConstructorError: could not determine a constructor for the tag '!ignore'
in "<unicode string>", line 1, column 18:
dynamic_sockets: !ignore
this ticket yaml/pyyaml#266 suggests it should be possible with a full yaml loader (ie not safe_load) but i couldnt seem to make it work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a subject matter expert, but based on my read of https://yaml.org/spec/1.2/spec.html this a correct and adherent usage of an application-specific local tag. This tag informs Envoy's (application-specific) loader of the type of the deserialized representation (in this case "nothing"). In theory, a validator should not complain, because this is valid yaml. In practice, a given YAML loader might complain, based on how it's configured, because it believes it should be doing something with the tag, and hasn't been told what to do. From my own Googling, various YAML loading tools, including pyyaml, provide various mechanisms for informing the library of how to handle custom local tags.
See also 3.3.2 and 3.3.3:
https://yaml.org/spec/1.2/spec.html#id2769212
Especially:
That said, tag resolution is specific to the application. YAML processors should therefore provide a mechanism allowing the application to override and expand these default tag resolution rules.
I haven't attempted, but this stack overflow post appears to explain how to configure pyyaml to handle a custom tag:
https://stackoverflow.com/questions/43058050/creating-custom-tag-in-pyyaml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep - i didnt try too hard to get it to work tbh and yaml parsers can a bit "ymmv" - defo not a blocker
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, looks like it's going to be necessary to pass bazel-bin/configs/example_configs_validation - let me see what I can come up with. :)
Signed-off-by: Mike Schore <[email protected]>
Signed-off-by: Mike Schore <[email protected]>
Thank you all for the comments so far! @snowp, what format would I use for adding the release notes? |
see |
Thank you @phlax! |
Merging main should get you past the format_pre breakage. |
Signed-off-by: Mike Schore <[email protected]>
Signed-off-by: Mike Schore <[email protected]>
Signed-off-by: Mike Schore <[email protected]>
Signed-off-by: Mike Schore <[email protected]>
I think the CI failures might be spurious - this was green before the docs change. Not sure if I can /retest |
/retest |
Retrying Azure Pipelines: |
i think there is some confusion here the the Prefixing with Using
i appreciate that and welcome the addition of this - but its a significant change and should be thought about properly and not rushed
my concerns have nothing to do with docs broadly my concerns are as follows
for clarity - here are 2 examples showing the different approaches !ignore dynamic_sockets:
&admin_address
address: 127.0.0.1
port_value: 9901
admin:
address:
socket_address: *admin_address x-dynamic_sockets:
&admin_address
address: 127.0.0.1
port_value: 9901
admin:
address:
socket_address: *admin_address i have tried again parsing using both wrt using this with yaml-language-server - i have checked and wasnt able to find any evidence that the there is still a further challenge of expressing this in jsonschema to make it work with yaml-language-server with either way overall, im -1 to the approach implemented here because:
|
Not to belabor the point, but we are not hacking PyYAML. We may differ on our notion of "out-of-the-box", but we are making use of an official public interface as intended, supported and documented. Please see:
|
my intended meaning of ie
yes - but with a custom class with a fair amount of complexity to do so |
...also without reading the Envoy source code - there is not any obvious way for an end user to know how to do this |
discussing this further with @goaway offline - i did a bit of a survey of other projects/services that use yaml config to see how they dealt with the same problem to define and allow anchors this is roughly what i found (please feel free to correct if my quick research is wrong): ansible: kubernetes: docker-compose: travis: bitbucket: circleci: azure: i didnt find any examples that use |
OK thanks @phlax I think I understand the issue better now. I didn't realize that
I think that would be a reasonable compromise to move this forward. The other alternative would be to just not document it at all, though that would not be my first choice. |
OK sorry for the back and forth on this. I just discussed this further with @goaway and I better understand this issue. I agree that using tags vs. magic strings is a better way of handling this. As such my opinion is we should stick with the So concretely I think we should:
|
Signed-off-by: Mike Schore <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks. @phlax let's chat early in the morning tomorrow on Slack and resolve any remaining issues so we can move this forward. It's fairly urgent we get this merged so if we can't agree to this quickly we will need to carry a patch in Envoy Mobile.
docs needs fixing |
Signed-off-by: Mike Schore <[email protected]>
@@ -328,9 +328,10 @@ See the following example: | |||
|
|||
For example, this will instruct `PyYAML <https://github.com/yaml/pyyaml>` to treat an ignored | |||
node as a simple scalar when loading: | |||
.. code-block:: python | |||
|
|||
.. code-block:: python3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure this is any different from python
lexer - i think if not just use python
as that is what is used everywhere else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually - checking - seems like neither are used anywhere atm - i still think just use python
just to confirm the it throws a couple of errors it might be possible to edit vscodes' |
a fixed key such as the |
@phlax objection noted but I think it's time to move this forward. I think it's fine if this feature does not work with the language server. That's why we have the warning. We can ship and iterate on this later if needed. (@goaway please do a follow up for the docs comments but I don't think we need to wait for more CI on this.) |
Signed-off-by: Mike Schore <[email protected]>
Commit Message: config: support extrinsic yaml anchor declarations
Additional Description: This relatively simple change adds the ability to declare yaml anchors outside the bounds of Envoy configuration structure, for later aliasing and merging, using a new
!ignore
tag. This allows for bootstrap and static configuration to include variable content without requiring secondary pre-parsing or interpolation, by leveraging the yaml parser cheaply and directly. In the case of Envoy Mobile, this dramatically improves startup latency, and it likely has applications elsewhere.Risk Level: Moderate
Testing: Locally with Envoy Mobile, and Unit test in CI
Docs Changes: Configuration examples
Signed-off-by: Mike Schore [email protected]