Skip to content
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

tools: adding a python script for making deprecated featured fail-by-default #5922

Merged
merged 5 commits into from
Feb 14, 2019

Conversation

alyssawilk
Copy link
Contributor

plus venv wrappers shamelessly cut-and-pasted from tools/deprecate_version

Risk Level: n/a (tools only)
Testing: manual testing
Docs Changes: updated GOVERNANCE.md
Release Notes: n/a
Fixes #5559

@alyssawilk
Copy link
Contributor Author

Apologies to whoever reviews this: I don't really do python. I figured if I tried to submit the original .sh version someone was going to make me rewrite it in Python anyway :-P

Signed-off-by: Alyssa Wilk <[email protected]>
Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

So, I think the really clean way to do this is to add a proto annotation deprecated_at_version, containing the release version at which a field was deprecated. Then we can automatically build a runtime_features_deprecated_flags.h file via genrule during the build build via a protoc plugin.

This is a fair bit of work to do right, so maybe you can file an issue and we can start with what you have here.

stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
shell=True)
grep_output = grep.communicate()[0]
Copy link
Member

Choose a reason for hiding this comment

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

Prefer subprocess.check_output(..)


# Now discard any deprecated features already listed in runtime_features
exiting_deprecated_regex = re.compile(r".*\"envoy.deprecated_features.(.*):(.*)\",.*")
features = open('source/common/runtime/runtime_features.h', "r")
Copy link
Member

Choose a reason for hiding this comment

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

Nit: prefer context managers:

with open(...) as f:
  do stuff with f

this auto-closes.

import fileinput

grep = subprocess.Popen(
'grep -r "deprecated = true" api/*',
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, this is pretty fuzzy; the clean way to do it would be via Python reflection and protobuf, or with a protoc plugin. It might be good enough though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, for a script we are literally running once a quarter, I think the hacky way is fine :-)

We're also going to want to do a similar thing for runtime feature flags, and I'd prefer we stick everything in one script. If we start simple on the flags side we will probably want to grep and dedup there as well.

We can easily note deprecation in with a comment in runtime_features.h if we think it's worth tracking, just by running the script with the version as we do with deprecate_version/...

@htuch htuch self-assigned this Feb 13, 2019
@htuch htuch added the waiting label Feb 13, 2019
htuch
htuch previously approved these changes Feb 14, 2019
if not raw_input('Apply runtime changes? [yN] ').strip().lower() in ("y", "yes"):
exit(1)

for line in fileinput.FileInput('source/common/runtime/runtime_features.h', inplace=1):
Copy link
Member

Choose a reason for hiding this comment

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

Nit: can you be consistent in whether to use single or double quotes for strings across this file?

'
Signed-off-by: Alyssa Wilk <[email protected]>
Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

Thanks!

@htuch htuch merged commit d2babe9 into envoyproxy:master Feb 14, 2019
fredlas pushed a commit to fredlas/envoy that referenced this pull request Mar 5, 2019
…default (envoyproxy#5922)

plus venv wrappers shamelessly cut-and-pasted from tools/deprecate_version

Risk Level: n/a (tools only)
Testing: manual testing
Docs Changes: updated GOVERNANCE.md
Release Notes: n/a
Fixes envoyproxy#5559

Signed-off-by: Alyssa Wilk <[email protected]>
Signed-off-by: Fred Douglas <[email protected]>
@alyssawilk alyssawilk deleted the deprecation_script branch May 15, 2019 19:08
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.

None yet

2 participants