Skip to content

matching: add support for generic inputs and add environment variable input#15410

Merged
snowp merged 16 commits intoenvoyproxy:mainfrom
snowp:env-generic-input
Apr 1, 2021
Merged

matching: add support for generic inputs and add environment variable input#15410
snowp merged 16 commits intoenvoyproxy:mainfrom
snowp:env-generic-input

Conversation

@snowp
Copy link
Copy Markdown
Contributor

@snowp snowp commented Mar 10, 2021

Adds support for a "generic input" extension point that allows specifying inputs that are not dependent on protocol data.

Adds an environment variable generic input that allows matching on the value of an environment variable.

Risk Level: Medium
Testing: UTs for extension and generic input creation
Docs Changes: n/a
Release Notes:
Platform Specific Features:
Fixes #14781

Snow Pettersen added 5 commits March 10, 2021 17:19
Signed-off-by: Snow Pettersen <snowp@lyft.com>
Signed-off-by: Snow Pettersen <snowp@lyft.com>
Signed-off-by: Snow Pettersen <snowp@lyft.com>
Signed-off-by: Snow Pettersen <snowp@lyft.com>
Signed-off-by: Snow Pettersen <snowp@lyft.com>
@repokitteh-read-only
Copy link
Copy Markdown

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/envoy/.
API shepherd assignee is @lizan
CC @envoyproxy/api-watchers: FYI only for changes made to api/envoy/.

🐱

Caused by: #15410 was opened by snowp.

see: more, trace.

Signed-off-by: Snow Pettersen <snowp@lyft.com>
// [#extension: envoy.matching.generic_inputs.environment]

// Reads an environment variable to provide an input for matching.
message Environment {
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.

Environment sounds ambiguous, something more descriptive, perhaps EnvironmentVariable, would be clearer.

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.

Yea agreed, will update

@dmitri-d
Copy link
Copy Markdown
Contributor

Could you add some docs/examples demonstrating how this DataInput is configured/used?

Snow Pettersen added 2 commits March 11, 2021 15:38
Signed-off-by: Snow Pettersen <snowp@lyft.com>
Signed-off-by: Snow Pettersen <snowp@lyft.com>
@snowp
Copy link
Copy Markdown
Contributor Author

snowp commented Mar 11, 2021

@dmitri-d I think I would want this to be covered by docs just as an extension of the match API, so just I figured I'd just update the docs that will be added in #14864 (either in this PR or follow up, depending on merge order)

explicit Input(absl::string_view name) {
// We read the env variable at construction time to avoid repeat lookups.
// This assumes that the environment remains stable during the process lifetime.
auto* value = getenv(name.data());
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.

Mostly curious what you think: if this side-effect was moved out of the constructor (into the factory perhaps?), this class would become a trivial wrapper around absl::optional<std::string>. This would make tests simpler, I think: GenericTestInput wouldn't be needed, and TestGenericDataInputFactory would only need to overload the method that retrieves env var with one that returns something expected in the test. Even though getenv() is pretty benign, side-effects in constructors always catch my attention...

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.

I like that, let me give that a go!

@dmitri-d
Copy link
Copy Markdown
Contributor

Looks good, other than a small nits re: naming.

Copy link
Copy Markdown
Member

@lizan lizan left a comment

Choose a reason for hiding this comment

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

/lgtm api

Snow Pettersen added 3 commits March 15, 2021 16:36
Signed-off-by: Snow Pettersen <snowp@lyft.com>
Signed-off-by: Snow Pettersen <snowp@lyft.com>
Signed-off-by: Snow Pettersen <snowp@lyft.com>
@dmitri-d
Copy link
Copy Markdown
Contributor

/retest

@repokitteh-read-only
Copy link
Copy Markdown

Retrying Azure Pipelines:
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #15410 (comment) was created by @dmitri-d.

see: more, trace.

@dmitri-d
Copy link
Copy Markdown
Contributor

lgtm, not sure why precheck docs is failing; perhaps try merging in the latest from the main branch?

@lizan
Copy link
Copy Markdown
Member

lizan commented Mar 16, 2021

@dmitri-d the doc fails because:

2021-03-15T19:24:09.4627982Z looking for now-outdated files... none found
2021-03-15T19:24:09.4630549Z pickling environment... /source/generated/rst/api-v3/common_messages/common_messages.rst:4: WARNING: toctree contains reference to nonexisting document 'api-v3/extensions/matching/generic_inputs/environment/v3/environment.proto'
2021-03-15T19:24:09.5144597Z done

Snow Pettersen added 2 commits March 18, 2021 13:56
Signed-off-by: Snow Pettersen <snowp@lyft.com>
Signed-off-by: Snow Pettersen <snowp@lyft.com>
Copy link
Copy Markdown
Member

@lizan lizan left a comment

Choose a reason for hiding this comment

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

/lgtm api

can you check CI?

Signed-off-by: Snow Pettersen <snowp@lyft.com>
@snowp
Copy link
Copy Markdown
Contributor Author

snowp commented Mar 23, 2021

This should be ready for another pass

@snowp
Copy link
Copy Markdown
Contributor Author

snowp commented Mar 31, 2021

@htuch @mattklein123 either of you want to review this?

@mattklein123 mattklein123 self-assigned this Mar 31, 2021
@mattklein123
Copy link
Copy Markdown
Member

Sure I can take a look.

mattklein123
mattklein123 previously approved these changes Mar 31, 2021
Copy link
Copy Markdown
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

LGTM!

@phlax
Copy link
Copy Markdown
Member

phlax commented Mar 31, 2021

this needs to merge main - it would fail linting on postsubmit if merged as is

/wait

Signed-off-by: Snow Pettersen <snowp@lyft.com>
Signed-off-by: Snow Pettersen <snowp@lyft.com>
@snowp snowp merged commit 758a9a9 into envoyproxy:main Apr 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add environment variable DataInput extension

6 participants