-
Notifications
You must be signed in to change notification settings - Fork 596
ir: Fix Service updates not propagating through translation #12809
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -254,23 +254,6 @@ func (l AttachedPolicies) MarshalJSON() ([]byte, error) { | |
| return json.Marshal(m) | ||
| } | ||
|
|
||
| type BackendRefIR struct { | ||
| // TODO: remove cluster name from here, it's redundant. | ||
| ClusterName string | ||
| Weight uint32 | ||
|
|
||
| // backend could be nil if not found or no ref grant | ||
| BackendObject *BackendObjectIR | ||
| // if nil, error might say why | ||
| Err error | ||
| } | ||
|
|
||
| type HttpBackendOrDelegate struct { | ||
| Backend *BackendRefIR | ||
| Delegate *ObjectSource | ||
| AttachedPolicies AttachedPolicies | ||
| } | ||
|
|
||
| type HttpRouteRuleIR struct { | ||
| ExtensionRefs AttachedPolicies | ||
| AttachedPolicies AttachedPolicies | ||
|
|
@@ -282,3 +265,28 @@ type HttpRouteRuleIR struct { | |
| // that should be propagated through to translation to any derived ir.HttpRouteRuleMatchIRs | ||
| Err error | ||
| } | ||
|
|
||
| type HttpBackendOrDelegate struct { | ||
| AttachedPolicies AttachedPolicies | ||
| Backend *BackendRefIR | ||
| Delegate *ObjectSource | ||
| } | ||
|
|
||
| func (h HttpBackendOrDelegate) Equals(other HttpBackendOrDelegate) bool { | ||
| if !h.AttachedPolicies.Equals(other.AttachedPolicies) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: order comparision in the order of fields declared in the struct |
||
| return false | ||
| } | ||
| if h.Backend != nil && other.Backend != nil { | ||
| return h.Backend.Equals(*other.Backend) | ||
| } | ||
| if h.Backend == nil && other.Backend == nil { | ||
| if h.Delegate == nil && other.Delegate == nil { | ||
| return true | ||
| } | ||
| if h.Delegate != nil && other.Delegate != nil { | ||
| return h.Delegate.Equals(*other.Delegate) | ||
| } | ||
| return false | ||
| } | ||
| return false | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -19,6 +19,8 @@ type Route interface { | |||||||||||||||||||||||||||||||||||||||
| GetSourceObject() metav1.Object | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| var _ Route = &HttpRouteIR{} | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| // this is 1:1 with httproute, and is a krt type | ||||||||||||||||||||||||||||||||||||||||
| // maybe move this to krtcollections package? | ||||||||||||||||||||||||||||||||||||||||
| type HttpRouteIR struct { | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -54,7 +56,6 @@ func (c HttpRouteIR) ResourceName() string { | |||||||||||||||||||||||||||||||||||||||
| return c.ObjectSource.ResourceName() | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| // get hostnames | ||||||||||||||||||||||||||||||||||||||||
| func (c *HttpRouteIR) GetHostnames() []string { | ||||||||||||||||||||||||||||||||||||||||
| if c == nil { | ||||||||||||||||||||||||||||||||||||||||
| return nil | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -99,21 +100,7 @@ func (c HttpRouteIR) rulesEqual(in HttpRouteIR) bool { | |||||||||||||||||||||||||||||||||||||||
| return false | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| for j, backend := range backendsa { | ||||||||||||||||||||||||||||||||||||||||
| otherbackend := backendsb[j] | ||||||||||||||||||||||||||||||||||||||||
| if backend.Backend == nil && otherbackend.Backend == nil { | ||||||||||||||||||||||||||||||||||||||||
| continue | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| if backend.Backend != nil && otherbackend.Backend != nil { | ||||||||||||||||||||||||||||||||||||||||
| if backend.Backend.ClusterName != otherbackend.Backend.ClusterName { | ||||||||||||||||||||||||||||||||||||||||
| return false | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| if backend.Backend.Weight != otherbackend.Backend.Weight { | ||||||||||||||||||||||||||||||||||||||||
| return false | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| if !backend.AttachedPolicies.Equals(otherbackend.AttachedPolicies) { | ||||||||||||||||||||||||||||||||||||||||
| return false | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||
| if !backend.Equals(backendsb[j]) { | ||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Were we intentionally restricting Backend comparison to specific fields before or was this an oversight? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the latter is very likely. If you go through the git history for this file, you'll reach the massive refactor PR that Yuval did during the early days of the donation that predated my time: 5d4e603#diff-5b7e43b2f30d5fce0ff29295ccad60d0882ce08abb34ba7e6f9464b942e02a6f. @lgadban @yuval-k if you can confirm There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is intentional - there's no need to propagate changes like app protocol for routes - i believe it is a no-op in envoy There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i.e. i don't care about backend properties that don't end up on the envoy route object There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @timflannagan do you know if something about the app protcol impacts the envoy route? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the problem is that appProtocol, at least for websockets, does contribute to envoy config: kgateway/internal/kgateway/translator/irtranslator/route.go Lines 594 to 603 in e74aaa4
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FWIW for the BackendObjectIR's Equals() not checking the AppProtocol field. I think we're all set due to kgateway/pkg/pluginsdk/ir/iface.go Lines 306 to 314 in 7a9e2af
So the issue here is solely due to the lack of explicit backend.Backend equals checking. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, we are automatically add an upgrade to the route based on the backend app protocol. then yea the app protocol is effectivly a route policy in this case, so it should be in the equals |
||||||||||||||||||||||||||||||||||||||||
| return false | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.