-
Notifications
You must be signed in to change notification settings - Fork 687
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
Fix redirect mapping regression #4028
Conversation
1. The ldflags thing is a sham, we must always get it from the ambassador.version file. + And therefore we should not set -ldflags in Dockerfile or builder.sh. And because the 'version' build-arg is now unused, remove that too. 2. Use go-shellquote instead of our own janky de-quoting. 3. Simplify by using os.ReadFile. 4. Don't use global variables. 5. Emphasize that the version-parsing code must be kept in-sync with VERSION.py Signed-off-by: Luke Shumaker <[email protected]> (cherry picked from commit 02a83ee)
Signed-off-by: Flynn <[email protected]> Signed-off-by: Luke Shumaker <[email protected]>
Signed-off-by: Flynn <[email protected]>
Signed-off-by: Flynn <[email protected]>
Signed-off-by: Flynn <[email protected]> Signed-off-by: Luke Shumaker <[email protected]>
Signed-off-by: Luke Shumaker <[email protected]>
Signed-off-by: Luke Shumaker <[email protected]>
This turned out to be an upstream bug in k8s.io/kube-openapi. Upgrading that package fixes the bug. kubernetes/kube-openapi#230 Signed-off-by: Flynn <[email protected]> Signed-off-by: Luke Shumaker <[email protected]>
Signed-off-by: Flynn <[email protected]> Signed-off-by: Luke Shumaker <[email protected]>
Signed-off-by: Flynn <[email protected]>
Signed-off-by: Flynn <[email protected]>
Signed-off-by: Gabriel Féron <[email protected]> Signed-off-by: AliceProxy <[email protected]>
Signed-off-by: AliceProxy <[email protected]>
Signed-off-by: AliceProxy <[email protected]>
Does this need to be on top of |
Oops, I accidentally clicked "Close with comment" instead of "Comment". 😬 |
@@ -383,7 +383,8 @@ def matches_httpgroup(self, group: 'IRHTTPMappingGroup') -> bool: | |||
else: | |||
# It is NOT A TYPO that we use group.get("host") here -- whether the Mapping supplies | |||
# "hostname" or "host", the Mapping code normalizes to "host" internally. | |||
group_glob = group.get('host') or None # NOT A TYPO: see above. | |||
redirect_glob = group.get('host_redirect', {}).get('host') if group.get('host_redirect', {}) else None |
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 confused, isn't this equivalent to just
redirect_glob = group.get('host_redirect', {}).get('host')
?
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 main issue with why this looks so gross is that group.get('host_redirect', {})
is sometimes None
meaning that a group.get('host_redirect', {}).get('host')
will throw an error because you cant NoneType.get('host')
thats why I first check if anything is returned by group.get('host_redirect', {})
before doing group.get('host_redirect', {}).get('host')
that said, there is still probably a better way to write that out.
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 would probably do
# It's possible for group.host_redirect to be None instead of missing, and it's also
# conceivably possible for group.host_redirect.host to be "", which we'd rather be
# None. Hence we do this two-line dance to massage the various cases.
host_redirect = group.get('host_redirect') or {}
redirect_glob = host_redirect.get('host') or None
This might not be "better" but at least there's room for the explanation...
@@ -383,7 +383,8 @@ def matches_httpgroup(self, group: 'IRHTTPMappingGroup') -> bool: | |||
else: | |||
# It is NOT A TYPO that we use group.get("host") here -- whether the Mapping supplies | |||
# "hostname" or "host", the Mapping code normalizes to "host" internally. | |||
group_glob = group.get('host') or None # NOT A TYPO: see above. | |||
redirect_glob = group.get('host_redirect', {}).get('host') if group.get('host_redirect', {}) else None | |||
group_glob = group.get('host') or redirect_glob or None # NOT A TYPO: see above. |
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.
If redirect_glob
is falsey, doesn't that mean it's None
? Isn't the or None
superfluous?
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.
This is true, I can definitely change that
I would encourage you to squash this in to just 1 commit (and add a bit to the commit message explaining what's different from @gferon's original commit). |
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 agree with @LukeShu that this could be collapsed into one commit, and that some of the Python can be cleaned up a bit. Thanks for taking this one on!
(Oh, and I think it can go directly onto release/v2.1
, too.)
348b2e7
to
dd18207
Compare
closing in favor of #4034 |
Description
Cherry picking a community contribution and making a small change to the tests so they actually run now so we can get this out in the next release.
Related Issues
Original Contribution: #4004
Related issues:
#3709
#4005
Testing
We already had tests that should have discovered that this regression occurred, but those tests were set to not run. I've re-enabled them and updated the gold test config to account for the fact that the redirects are now showing up in the Envoy config.
Checklist
I made sure to update
CHANGELOG.md
.Remember, the CHANGELOG needs to mention:
This is unlikely to impact how Ambassador performs at scale.
Remember, things that might have an impact at scale include:
My change is adequately tested.
Remember when considering testing:
I updated
DEVELOPING.md
with any any special dev tricks I had to use to work on this code efficiently.