Skip to content

[feat gw-api]implement finalizer #4217

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

Merged
merged 1 commit into from
Jun 6, 2025
Merged

Conversation

shuqz
Copy link
Collaborator

@shuqz shuqz commented Jun 4, 2025

Description

  • implement finalizer for target group configuration and load balancer configuration
  • LBConfig finalizer will be added during reconcileUpdate and removed during reconcileDelete, it will check both gateway and gatewayClass
  • TargetGroupConfig will be added in backend loader and removed when service is deleted

Checklist

  • Added tests that cover your change (if possible)
  • Added/modified documentation as required (such as the README.md, or the docs directory)
  • Manually tested
    ========== test targetgroupconfiguration =======
    targetgroupconfiguration will be removed when service is deleted
    Test process:
  1. targetgroupconfiguration refers to a service
  2. http route added this service to trigger reconcile
  3. delete service -> finalizer should be deleted
    Result
sic-test-alb % k describe targetgroupconfiguration targetgroupconfiguration-sample -n gateway-alb
Name:         targetgroupconfiguration-sample
Namespace:    gateway-alb
Labels:       <none>
Annotations:  <none>
API Version:  gateway.k8s.aws/v1beta1
Kind:         TargetGroupConfiguration
Metadata:
  Creation Timestamp:  2025-05-30T01:11:34Z
  Finalizers:
    gateway.k8s.aws/targetgroupconfigurations
  Generation:        5
  Resource Version:  21594197
  UID:               582df46b-2d0a-4a41-b23f-ffc42e07bdd0
Spec:
  Default Configuration:
    Health Check Config:
      Health Check Interval:      30
      Health Check Path:          /health
      Health Check Protocol:      http
      Health Check Timeout:       5
      Healthy Threshold Count:    2
      Unhealthy Threshold Count:  2
    Protocol:                     HTTP
    Protocol Version:             HTTP1
    Target Type:                  ip
  Target Reference:
    Group:
    Kind:   Service
    Name:   echoserver2
Events:     <none>

Load balancer Configuration result

k describe loadbalancerconfiguration test-gw-alb-lb-config-1 -n gateway-alb
Name:         test-gw-alb-lb-config-1
Namespace:    gateway-alb
Labels:       <none>
Annotations:  <none>
API Version:  gateway.k8s.aws/v1beta1
Kind:         LoadBalancerConfiguration
Metadata:
  Creation Timestamp:  2025-06-03T20:48:36Z
  Finalizers:
    gateway.k8s.aws/loadbalancerconfigurations
  Generation:        1
  Resource Version:  21606856
  UID:               b2e9ef38-c25d-4625-817d-4f5aa4892990
Spec:
  Load Balancer Name:  customized-alb-lb-name-1
Events:                <none>
$ k delete gateway test-gw-alb -n gateway-alb
gateway.gateway.networking.k8s.io "test-gw-alb" deleted
$ k describe loadbalancerconfiguration test-gw-alb-lb-config-1 -n gateway-alb
Name:         test-gw-alb-lb-config-1
Namespace:    gateway-alb
Labels:       <none>
Annotations:  <none>
API Version:  gateway.k8s.aws/v1beta1
Kind:         LoadBalancerConfiguration
Metadata:
  Creation Timestamp:  2025-06-03T20:48:36Z
  Generation:          1
  Resource Version:    21692623
  UID:                 b2e9ef38-c25d-4625-817d-4f5aa4892990
Spec:
  Load Balancer Name:  customized-alb-lb-name-1
Events:                <none>
  • Made sure the title of the PR is a good description that can go into the release notes

BONUS POINTS checklist: complete for good vibes and maybe prizes?! 🤯

  • Backfilled missing tests for code in same general area 🎉
  • Refactored something and made the world a better place 🌟

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: shuqz
Once this PR has been reviewed and has the lgtm label, please assign oliviassss for approval. For more information see the Code Review Process.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 4, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @shuqz. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 4, 2025
@@ -284,6 +297,93 @@ func (r *gatewayReconciler) reconcileUpdate(ctx context.Context, gw *gwv1.Gatewa
return nil
}

// add finalizer to load balancer configuration when it is in use by gateway or gatewayClass
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we move these adding and removing finalizers methods to FinalizerManager to consolidate them under same manager?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

During offline conversation with Shraddha, she found an edge case when GWA and GWB both refers to GWClass-A. and GWClass A has lbConfig. in this case, when GWA and GWB both got deleted, there is no reconcile to trigger finalizer removal on the remaining gatewayClass based on current logic, will address it

h.enqueueImpactedRoutes(ctx, svc)
}

func (h *enqueueRequestsForServiceEvent) removeTargetGroupConfigurationFinalizer(ctx context.Context, svc *corev1.Service) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same lets move this to FinalizerManager

@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 5, 2025
refactor code and add unit tests

fix logic bug
@shraddhabang shraddhabang merged commit 1dbb7bd into kubernetes-sigs:main Jun 6, 2025
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants