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

fix: routes with conflicting services #2988

Merged
merged 5 commits into from
Oct 6, 2022
Merged

Conversation

mlavacca
Copy link
Member

What this PR does / why we need it:
Gateway routes with conflicting services in their backend don't break config build.

Which issue this PR fixes:
Fixes #2565

Special notes for your reviewer:

PR Readiness Checklist:

Complete these before marking the PR as ready to review:

  • the CHANGELOG.md release notes have been updated to reflect any significant (and particularly user-facing) changes introduced by this PR

@mlavacca mlavacca temporarily deployed to Configure ci September 28, 2022 10:45 Inactive
@mlavacca mlavacca temporarily deployed to Configure ci September 28, 2022 11:09 Inactive
@mlavacca mlavacca temporarily deployed to Configure ci September 28, 2022 11:49 Inactive
@mlavacca mlavacca temporarily deployed to Configure ci September 28, 2022 11:49 Inactive
@mlavacca mlavacca marked this pull request as ready for review September 28, 2022 13:36
@mlavacca mlavacca requested a review from a team as a code owner September 28, 2022 13:36
@mlavacca mlavacca temporarily deployed to Configure ci September 28, 2022 14:00 Inactive
@mlavacca mlavacca temporarily deployed to Configure ci September 28, 2022 14:23 Inactive
Copy link
Member

@pmalek pmalek left a comment

Choose a reason for hiding this comment

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

Minor comments, overall this looks 👍

CHANGELOG.md Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
internal/dataplane/parser/ingressrules_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@rainest rainest left a comment

Choose a reason for hiding this comment

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

We definitely want to at least alert on these in logs, and the original request wanted to actually skip the routes that would result from these altogether, rather than choosing an arbitrary set of services that do have equal annotations.

The latter part is both for visibility (you're more likely to check something that isn't working altogether than something that appears to work fine) and because we have no way of knowing which set of annotations is correct.

@mlavacca mlavacca temporarily deployed to Configure ci September 29, 2022 14:15 Inactive
@mlavacca mlavacca temporarily deployed to Configure ci September 29, 2022 14:39 Inactive
@mlavacca
Copy link
Member Author

We definitely want to at least alert on these in logs, and the original request wanted to actually skip the routes that would result from these altogether, rather than choosing an arbitrary set of services that do have equal annotations.

The latter part is both for visibility (you're more likely to check something that isn't working altogether than something that appears to work fine) and because we have no way of knowing which set of annotations is correct.

I probably didn't get correctly what you meant In the issue. It's clearer to me now, I'm going to set the PR back to draft to reduce noise.

@mlavacca mlavacca marked this pull request as draft September 29, 2022 14:43
@mlavacca mlavacca temporarily deployed to Configure ci October 5, 2022 12:16 Inactive
@mlavacca mlavacca temporarily deployed to Configure ci October 5, 2022 12:25 Inactive
@mlavacca mlavacca temporarily deployed to Configure ci October 5, 2022 12:41 Inactive
@mlavacca mlavacca temporarily deployed to Configure ci October 5, 2022 12:59 Inactive
@mlavacca mlavacca temporarily deployed to Configure ci October 5, 2022 13:23 Inactive
@mlavacca mlavacca temporarily deployed to Configure ci October 5, 2022 13:23 Inactive
@mlavacca mlavacca marked this pull request as ready for review October 5, 2022 13:27
@mlavacca
Copy link
Member Author

mlavacca commented Oct 5, 2022

@pmalek @rainest this PR is ready to be reviewed again, PTAL

Copy link
Member

@pmalek pmalek left a comment

Choose a reason for hiding this comment

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

Minor spelling nits, otherwise 👍

CHANGELOG.md Outdated Show resolved Hide resolved
internal/dataplane/parser/ingressrules.go Outdated Show resolved Hide resolved
@mlavacca mlavacca requested a review from pmalek October 5, 2022 16:02
pmalek
pmalek previously approved these changes Oct 5, 2022
@mlavacca
Copy link
Member Author

mlavacca commented Oct 5, 2022

I'd like to have a review by @rainest as well, as he is the original author of the issue and questioned the first implementation.

@rainest rainest temporarily deployed to Configure ci October 5, 2022 21:21 Inactive
@rainest rainest temporarily deployed to Configure ci October 5, 2022 21:22 Inactive
@rainest rainest temporarily deployed to Configure ci October 5, 2022 21:45 Inactive
mlavacca and others added 5 commits October 5, 2022 14:46
When the kongState is built, if some backendRefs have inconsistent
annotations, a message is logged, and the service is skipped, instead
of breaking the whole configuration process.

Signed-off-by: Mattia Lavacca <lavacca.mattia@gmail.com>
Signed-off-by: Mattia Lavacca <lavacca.mattia@gmail.com>
Split the multi-backend HTTPRoute test into its own test function.

Added a test for invalid (inconsistent Service configuration) HTTPRoute
rules with multiple backends.
Change to active voice.

Remove mention of internal structs.

Fix number.
@rainest rainest temporarily deployed to Configure ci October 5, 2022 21:46 Inactive
Copy link
Contributor

@rainest rainest left a comment

Choose a reason for hiding this comment

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

Added an integration test since it's hard to think through the rule deletion and make HTTPRouteEssentials less massive. The whole "ingressRules is a list of services that we've appended routes to as we go through each rule, and deleting the service will in turn delete the routes" aspect of the parser is confusing to think through, even if I understand kinda why we did it.

Actually removed the log because the format string was never correct in the original error and would result in nonsense like

time="2022-10-05T11:28:48-07:00" level=error msg="the Kubernetes Services [&Service{ObjectMeta:{k8s-service-to-skip1  test-namespace    0 0001-01-01 00:00:00 +0000 UTC <nil> <nil> map[] map[konghq.com/foo:bar] [] [] []},Spec:ServiceSpec{Ports:[]ServicePort{},Selector:map[string]string{},ClusterIP:,Type:,ExternalIPs:[],SessionAffinity:,LoadBalancerIP:,LoadBalancerSourceRanges:[],ExternalName:,ExternalTrafficPolicy:,HealthCheckNodePort:0,PublishNotReadyAddresses:false,SessionAffinityConfig:nil,IPFamilyPolicy:nil,ClusterIPs:[],IPFamilies:[],AllocateLoadBalancerNodePorts:nil,LoadBalancerClass:nil,InternalTrafficPolicy:nil,},Status:ServiceStatus{LoadBalancer:LoadBalancerStatus{Ingress:[]LoadBalancerIngress{},},Conditions:[]Condition{},},} &Service{ObjectMeta:{k8s-service-to-skip2  test-namespace    0 0001-01-01 00:00:00 +0000 UTC <nil> <nil> map[] map[] [] [] []},Spec:ServiceSpec{Ports:[]ServicePort{},Selector:map[string]string{},ClusterIP:,Type:,ExternalIPs:[],SessionAffinity:,LoadBalancerIP:,LoadBalancerSourceRanges:[],ExternalName:,ExternalTrafficPolicy:,HealthCheckNodePort:0,PublishNotReadyAddresses:false,SessionAffinityConfig:nil,IPFamilyPolicy:nil,ClusterIPs:[],IPFamilies:[],AllocateLoadBalancerNodePorts:nil,LoadBalancerClass:nil,InternalTrafficPolicy:nil,},Status:ServiceStatus{LoadBalancer:LoadBalancerStatus{Ingress:[]LoadBalancerIngress{},},Conditions:[]Condition{},},}] cannot have different sets of konghq.com annotations. These Services are used in the same Gateway Route BackendRef together to create the Kong Service service-to-skipand must use the same Kong annotations"

We already were logging in the helper, which I didn't notice in the diff. That log does still have issues, but we can't fix them without changing further up the code, and that would potentially interfere with #3008.

Last change was some phrasing and incorrect PR numbers in the changelog.

Approving but leaving unmerged in case you wanted to look over my additional commits.

@rainest rainest temporarily deployed to Configure ci October 5, 2022 22:10 Inactive
@rainest rainest temporarily deployed to Configure ci October 5, 2022 22:10 Inactive
@mlavacca mlavacca merged commit 2bd0b23 into main Oct 6, 2022
@mlavacca mlavacca deleted the fix-conflicting-services branch October 6, 2022 03:31
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.

Gateway Routes with conflicting Services in their backend should not break config build
3 participants