-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[feat gateway-api]implement gateway listener status #4357
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?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: shuqz The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
||
if needPatch { | ||
if err := r.k8sClient.Status().Patch(ctx, gw, client.MergeFrom(gwOld)); err != nil { | ||
fmt.Printf("failed to update status: %s\n", err.Error()) |
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.
will remove it
|
||
if needPatch { | ||
if err := r.k8sClient.Status().Patch(ctx, gw, client.MergeFrom(gwOld)); err != nil { | ||
fmt.Printf("failed to update status: %s\n", err.Error()) |
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.
will remove it
|
||
stack, lb, newAddOnConfig, backendSGRequired, secrets, err := r.buildModel(ctx, gw, mergedLbConfig, allRoutes, currentAddOns) | ||
|
||
if err != nil { |
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.
Seems this got removed, then didn't get re-added at a later place.
} | ||
|
||
// update listeners status | ||
ListenerStatuses, err := buildListenerStatus(r.controllerName, *gw, attachedRoutesMap, nil) |
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.
It seems this not possible to fail, can you remove returning an error?
result.Reason = gwv1.ListenerReasonPortUnavailable | ||
result.Message = fmt.Sprintf("Port %d is not available (listener name %s)", listener.Port, listener.Name) | ||
results.HasErrors = true | ||
} else if controllerName == gateway_constants.ALBGatewayController && |
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 don't think this will ever happen. As the loader will only load specific routes according to the gateway type:
aws-load-balancer-controller/pkg/gateway/routeutils/loader.go
Lines 103 to 113 in f1566e2
for route, loader := range l.allRouteLoaders { | |
applicable := filter.IsApplicable(route) | |
l.logger.V(1).Info("Processing route", "route", route, "is applicable", applicable) | |
if applicable { | |
data, err := loader(ctx, l.k8sClient) | |
if err != nil { | |
return nil, err | |
} | |
loadedRoutes = append(loadedRoutes, data...) | |
} | |
} |
I don't know if we'll want this check, because it would require users to install the NLB CRDs (even if they don't intend to use them)
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.
Ah, I see. The user can specify routes manually, so we'll need this. Good catch.
} | ||
} | ||
|
||
// Check cross-namespace references |
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 looks duplicated, and potentially incorrect -
func referenceGrantCheck(ctx context.Context, k8sClient client.Client, svcIdentifier types.NamespacedName, routeIdentifier types.NamespacedName, routeKind RouteKind) (bool, error) { |
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.
correct me if i am wrong, i felt it is a bit different? the referenceGrantCheck we had is checking From and To. but this one here is checking if another ns is specified here, there should be a referenceGrant for it
allowedRoutes:
namespaces:
from: Selector
selector:
matchLabels:
name: xx-random-ns
} | ||
|
||
// Check hostname conflicts - only when hostname is specified | ||
if listener.Hostname != nil { |
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.
Is this check duplicated too?
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.
it is different from hostname check. the existing hostname check checks if hostname in Route and hostname in listeners are compatible. but this hostname check here checks if hostnames in listeners have conflict.
@shuqz: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Description
Checklist
README.md
, or thedocs
directory)test case 1: (ALB, no routes attached to it, just want to see conflicts and invalid route kind)
test case 2: have some routes attached to each listener, and verified allowedRoutes value is correct

tese case3: with NLB, conflict protocol, and no attached routes
BONUS POINTS checklist: complete for good vibes and maybe prizes?! 🤯