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

internal/dag: Fix comparison of include match conditions #4931

Conversation

sunjayBhatia
Copy link
Member

Previously includeMatchConditionsIdentical was just comparing adjacent includes and comparing conditions element by element rather than as a whole, ANDed together

Fixes #4907

Previously includeMatchConditionsIdentical was just comparing adjacent
includes and comparing conditions element by element rather than as a
whole, ANDed together

Signed-off-by: Sunjay Bhatia <sunjayb@vmware.com>
@sunjayBhatia sunjayBhatia requested a review from a team as a code owner December 15, 2022 22:08
@sunjayBhatia sunjayBhatia requested review from tsaarni and stevesloka and removed request for a team December 15, 2022 22:08
@sunjayBhatia
Copy link
Member Author

might do another pass on the implementation to see if we can do something more elegant

currently uses the existing conversions to dag types for match conditions that are then sorted and stringified so they can be compared

since this happens before the match conditions are deemed valid or not, this is a little odd maybe

@codecov
Copy link

codecov bot commented Dec 15, 2022

Codecov Report

Merging #4931 (3e3ac65) into main (43c97d1) will increase coverage by 0.00%.
The diff coverage is 84.44%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #4931   +/-   ##
=======================================
  Coverage   77.63%   77.63%           
=======================================
  Files         140      140           
  Lines       16894    16922   +28     
=======================================
+ Hits        13116    13138   +22     
- Misses       3521     3526    +5     
- Partials      257      258    +1     
Impacted Files Coverage Δ
internal/dag/httpproxy_processor.go 92.35% <84.09%> (-0.44%) ⬇️
internal/dag/conditions.go 94.03% <100.00%> (ø)
internal/sorter/sorter.go 98.97% <0.00%> (+0.51%) ⬆️

@skriss skriss added the release-note/small A small change that needs one line of explanation in the release notes. label Dec 16, 2022
@github-actions
Copy link

The Contour project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 14d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, the PR is closed

You can:

  • Mark this PR as fresh by commenting or pushing a commit
  • Close this PR
  • Offer to help out with triage

Please send feedback to the #contour channel in the Kubernetes Slack

@github-actions github-actions bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Dec 31, 2022
@sunjayBhatia sunjayBhatia removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 3, 2023
…d-comparison

Signed-off-by: Sunjay Bhatia <sunjayb@vmware.com>
Signed-off-by: Sunjay Bhatia <sunjayb@vmware.com>
Also moves the check after checking for validity of the include
condition, to make sure we're not trying to check semantically invalid
conditions.

The included proxies that come before we find a duplicate are now not
marked as orphaned, which is a small behavior change.

Signed-off-by: Sunjay Bhatia <sunjayb@vmware.com>
…d-comparison

Signed-off-by: Sunjay Bhatia <sunjayb@vmware.com>
@sunjayBhatia sunjayBhatia requested a review from skriss January 13, 2023 20:52
@sunjayBhatia
Copy link
Member Author

from 37edb30

The included proxies that come before we find a duplicate are now not
marked as orphaned, which is a small behavior change.

maybe not desirable, would be good to hear what people thing about this

Signed-off-by: Sunjay Bhatia <sunjayb@vmware.com>
@skriss
Copy link
Member

skriss commented Jan 17, 2023

from 37edb30

The included proxies that come before we find a duplicate are now not
marked as orphaned, which is a small behavior change.

maybe not desirable, would be good to hear what people thing about this

If I'm reading it correctly, if we do end up finding a duplicate set of conditions on any two included proxies, then we end up not programming routes for any of the includes on the root HTTPProxy. Is that right? In that case, it does seem to me like all of those included proxies that didn't end up getting programmed should probably be called orphaned.

@skriss
Copy link
Member

skriss commented Jan 17, 2023

Possibly an easy fix would be on

delete(p.orphaned, types.NamespacedName{Name: includedProxy.Name, Namespace: includedProxy.Namespace})
instead of deleting from p.orphaned, just keep track of a list of child proxies that we want to eventually remove from p.orphaned, then if we get to we know we didn't return early due to duplicate conditions, so go ahead and delete from p.orphaned there

@sunjayBhatia
Copy link
Member Author

If I'm reading it correctly, if we do end up finding a duplicate set of conditions on any two included proxies, then we end up not programming routes for any of the includes on the root HTTPProxy. Is that right? In that case, it does seem to me like all of those included proxies that didn't end up getting programmed should probably be called orphaned.

ah good point, I was kinda thinking of the orphaned relationship similar to the Gateway/Route attachedRoutes idea so it might be ok, however in this case orphaned means a bit more than just the reference between the resources is good but that config has been generated, which you're right in this case will not be

@skriss
Copy link
Member

skriss commented Jan 17, 2023

If I'm reading it correctly, if we do end up finding a duplicate set of conditions on any two included proxies, then we end up not programming routes for any of the includes on the root HTTPProxy. Is that right? In that case, it does seem to me like all of those included proxies that didn't end up getting programmed should probably be called orphaned.

ah good point, I was kinda thinking of the orphaned relationship similar to the Gateway/Route attachedRoutes idea so it might be ok, however in this case orphaned means a bit more than just the reference between the resources is good but that config has been generated, which you're right in this case will not be

Yeah I think in this case it's probably safest to stick to the existing semantics, where child proxies that have an invalid include of them are called orphaned, rather than some form of attached + invalid.

to preserve traffic as much as possible

more similar to how other types of invalid match conditions are
processed

Signed-off-by: Sunjay Bhatia <sunjayb@vmware.com>
@sunjayBhatia
Copy link
Member Author

sunjayBhatia commented Jan 18, 2023

we can preserve some more of the includes/routes etc. that are valid by not returning early which would mean some traffic is still able to be served: 3ff0eaa

If I'm reading it correctly, if we do end up finding a duplicate set of conditions on any two included proxies, then we end up not programming routes for any of the includes on the root HTTPProxy.

this commit makes it so the valid stuff is still programmed (missed that I had it return rather than continue) so its more like other cases of invalid include match conditions

internal/dag/builder_test.go Show resolved Hide resolved
internal/dag/status_test.go Outdated Show resolved Hide resolved
Signed-off-by: Sunjay Bhatia <sunjayb@vmware.com>
…d-comparison

Signed-off-by: Sunjay Bhatia <sunjayb@vmware.com>
@sunjayBhatia sunjayBhatia added release-note/minor A minor change that needs about a paragraph of explanation in the release notes. and removed release-note/small A small change that needs one line of explanation in the release notes. labels Jan 18, 2023
@sunjayBhatia sunjayBhatia requested a review from skriss January 18, 2023 20:41
Copy link
Member

@skriss skriss left a comment

Choose a reason for hiding this comment

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

thanks for the updates, LGTM!

@sunjayBhatia sunjayBhatia merged commit bbc88a1 into projectcontour:main Jan 18, 2023
@sunjayBhatia sunjayBhatia deleted the fix-include-match-cond-comparison branch January 18, 2023 23:36
yangyy93 pushed a commit to projectsesame/contour that referenced this pull request Feb 16, 2023
…our#4931)

Previously includeMatchConditionsIdentical was just comparing adjacent
includes and comparing conditions element by element rather than as a
whole, ANDed together

Also don't exit processor early so other routes etc. are configured
to preserve traffic as much as possible. This behavior is more similar to
how other types of invalid match conditions are processed

Signed-off-by: Sunjay Bhatia <sunjayb@vmware.com>
Signed-off-by: yy <yang.yang@daocloud.io>
yangyy93 pushed a commit to projectsesame/contour that referenced this pull request Feb 16, 2023
…our#4931)

Previously includeMatchConditionsIdentical was just comparing adjacent
includes and comparing conditions element by element rather than as a
whole, ANDed together

Also don't exit processor early so other routes etc. are configured
to preserve traffic as much as possible. This behavior is more similar to
how other types of invalid match conditions are processed

Signed-off-by: Sunjay Bhatia <sunjayb@vmware.com>
Signed-off-by: yy <yang.yang@daocloud.io>
vmw-yingy pushed a commit to vmw-yingy/contour that referenced this pull request Feb 28, 2023
…our#4931)

Previously includeMatchConditionsIdentical was just comparing adjacent
includes and comparing conditions element by element rather than as a
whole, ANDed together

Also don't exit processor early so other routes etc. are configured
to preserve traffic as much as possible. This behavior is more similar to
how other types of invalid match conditions are processed

Signed-off-by: Sunjay Bhatia <sunjayb@vmware.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note/minor A minor change that needs about a paragraph of explanation in the release notes.
Projects
None yet
2 participants