Skip to content

tools: updating deprecation scripts#6289

Merged
alyssawilk merged 4 commits intoenvoyproxy:masterfrom
alyssawilk:flags_deprecation_script
Mar 25, 2019
Merged

tools: updating deprecation scripts#6289
alyssawilk merged 4 commits intoenvoyproxy:masterfrom
alyssawilk:flags_deprecation_script

Conversation

@alyssawilk
Copy link
Copy Markdown
Contributor

Updating per new file locations. Updates (unused) reloadable flags to default true.

Risk Level: n/a (tooling)
Testing: manual
Docs Changes: n/a
Release Notes: n/a

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
@alyssawilk
Copy link
Copy Markdown
Contributor Author

https://pastebin.com/ahycWwku for sample email
https://pastebin.com/41NhkNen for diffs (before I removed the test flag)

@alyssawilk
Copy link
Copy Markdown
Contributor Author

Sorry for crummy diffs - only like 1/3 of this is new but because I stuck code in a function all the diffs are different.

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Copy link
Copy Markdown
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.

LGTM, but do you think we should start adding tests, even if it's a simple golden text file style, as this script is becoming more involved?



# Gather code and suggested email changes.
(runtime_email, runtime_features_code) = flip_runtime_features()
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.

Nit: parens aren't needed here in tuple destruction.

@htuch htuch added the waiting label Mar 15, 2019
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
@alyssawilk
Copy link
Copy Markdown
Contributor Author

Golden files won't work here, as the output would change every time we ran the deprecation script.

I think I could refactor the functions so the grep were function input, then we could test the functions with echo commands faking what should happen. I got as far as trying to figure out how to run an envoy python test, realized we don't do that, realized I'd need to run an sh test in some sort of venv wrapper and convert error codes, and came back to "there is no way I'd rather do this than just fix the tool once a quarter if it were broken"
If you want to override me on this it is a completely legitimate request and I will go for it, but unless you do I'm sticking with manually running it before and after I make changes since it's pretty simple to manually verify correctness.

@htuch
Copy link
Copy Markdown
Member

htuch commented Mar 18, 2019

@alyssawilk I was mostly after adding tests if it was reasonable, no need to do gymnastics. We can revisit if the script continues to grow more complicated. Will review later today.

htuch
htuch previously approved these changes Mar 19, 2019
Copy link
Copy Markdown
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.

LGTM; a few nits, feel free to fix and merge.

for (filename, field) in filenames_and_fields:
code += (' "envoy.deprecated_features.' + filename + ':' + field + '",\n')
email += (field + ' from ' + filename + '\n')
return (email, code)
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.

Nit: no need for parens here or the other return statements.

code = ''
email = 'the following features will be defaulted to true:\n'
for (feature) in features_to_flip:
code += (' "' + feature + '",\n')
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.

Nit: prefer building up a list and then doing a join later.

@htuch htuch added the waiting label Mar 19, 2019
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
@alyssawilk
Copy link
Copy Markdown
Contributor Author

Sadly the way github works I will need a follow-up stamp
(and the way my python looks I should probably get that final pass anyway)

email = ''
if email_snippets:
email = ('\nThe following deprecated configuration fields will be disallowed by default:\n' +
''.join(email_snippets))
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.

Looks good, but one slight Pythonic nit. Could we do '\n'.join(email_snippets)'? That way the above append becomes a bit more declarative. Same for code_snippets (and below..).

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 can, but I'd prefer not to if I can talk you out of it :-)

If I pull newlines out of email snippets I think I should do it for the code for consistency. But for code it's a need-to-have and for email it's a nice-to-have to have the trailing \n after the join. I mean I could append another newline after both but if I want it after each snippet rather than between each snippet I think having it in the snippet rather than having it in the join is semantically correct.

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.

It's semantically correct, I'm just suggesting there are more Pythonic ways to do it if you're after Python style suggestions. Since the join value is substituted into a string in both cases, you can write something like 'foo bar:\n %s\n' % '\n'.join(stuff without any new lines in it). This discussion is really me being nit-picky, but reflects my understanding of Python best practices.

@alyssawilk alyssawilk merged commit 03b28bd into envoyproxy:master Mar 25, 2019
@alyssawilk alyssawilk deleted the flags_deprecation_script branch July 31, 2019 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants