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

Make Ingress validating webhook ignore ingresses not managed by AWS LBC #3272

Merged

Conversation

johngmyers
Copy link
Contributor

@johngmyers johngmyers commented Jul 3, 2023

Issue

None

Description

Makes the validating admission webhook for Ingress permit creation and modification all ingresses for which it is able to determine that it is not going to manage.

Also fixes a bug where LBC would incorrectly manage Ingresses with an IngressClassName specifying a different controller when LBC was configured to manage Ingresses without either annotation or IngressClassName.

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
  • 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 k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 3, 2023
@codecov-commenter
Copy link

Codecov Report

Patch coverage: 56.00% and project coverage change: +0.01 🎉

Comparison is base (940efc7) 54.70% compared to head (1cf03cc) 54.71%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3272      +/-   ##
==========================================
+ Coverage   54.70%   54.71%   +0.01%     
==========================================
  Files         148      148              
  Lines        8590     8604      +14     
==========================================
+ Hits         4699     4708       +9     
- Misses       3559     3564       +5     
  Partials      332      332              
Impacted Files Coverage Δ
pkg/config/ingress_config.go 0.00% <ø> (ø)
pkg/ingress/class_annotation_matcher.go 100.00% <ø> (ø)
webhooks/networking/ingress_validator.go 63.46% <42.10%> (-0.28%) ⬇️
pkg/ingress/class_loader.go 87.30% <100.00%> (+0.20%) ⬆️
pkg/ingress/group_loader.go 86.23% <100.00%> (ø)
pkg/ingress/reference_indexer.go 73.07% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@johngmyers
Copy link
Contributor Author

/retest

@kishorj kishorj added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Jul 21, 2023
@johngmyers
Copy link
Contributor Author

/retest

2 similar comments
@johngmyers
Copy link
Contributor Author

/retest

@johngmyers
Copy link
Contributor Author

/retest

@johngmyers
Copy link
Contributor Author

@kishorj @M00nF1sh can I please get a review? This has been open a month and I have other PRs stacked behind it.

@@ -88,6 +98,21 @@ func (v *ingressValidator) ValidateDelete(ctx context.Context, obj runtime.Objec
return nil
}

// checkIngressClass checks to see if this ingress is handled by this controller.
func (v *ingressValidator) checkIngressClass(ctx context.Context, ing *networking.Ingress) (bool, error) {
Copy link
Collaborator

@kishorj kishorj Aug 2, 2023

Choose a reason for hiding this comment

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

nit: the checkIngressClass name is confusing. Since the purpose here is to check if the webhook should skip validating further, we could rename to either of checkIngressSkipValidation, shouldSkipFurtherValidation, checkIngressUnmanaged. Let me know if you think the current name is good enough.

Changes look good otherwise.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function is validating the kubernetes.io/ingress.class annotation, the IngressClassName field, and the spec.controller of the IngressClass referenced by the IngressClassName field. Skipping further validation is only one possible outcome; it can fail validation if the IngressClassName references a nonexistent IngressClass.

For naming these sub-validation methods, I tend to prefer using the name of the field or subsection that is being validated. The existing naming pattern isn't entirely consistent; this could be fixed in follow-up.

It looks like checkIngressClassUsage() is being made redundant; it could be removed in this or the followup PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

lets refactor in a follow up PR

@kishorj
Copy link
Collaborator

kishorj commented Aug 4, 2023

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 4, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: johngmyers, kishorj

The full list of commands accepted by this bot can be found here.

The pull request process is described 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 the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 4, 2023
@k8s-ci-robot k8s-ci-robot merged commit 5c892f5 into kubernetes-sigs:main Aug 4, 2023
6 checks passed
@johngmyers johngmyers deleted the ingore-other-controller branch August 4, 2023 18:50
@johngmyers johngmyers mentioned this pull request Aug 23, 2023
12 tasks
johngmyers added a commit to johngmyers/aws-load-balancer-controller that referenced this pull request Feb 6, 2024
…to 2.6.0

Merge in DEL/aws-load-balancer-controller-fork from merge-up to main

* commit '195e896b0efbd467694bb9a19de7c5a12c5dde8c': (71 commits)
  check the canary test result and exit if it failed
  Apply suggestions from code review
  Update docs/guide/service/annotations.md
  Addressing the comment
  Remove dependency on aws-sdk-go-v2 (kubernetes-sigs#3320)
  Update live docs for NLB-SG feature release
  cut v2.6.0 release
  refactor targetGroupBinding network builder
  Add support for NLB security groups
  Allow TLS 1.2 with restricted ciphers for webhooks
  Update the RSA filter for Cert discovery
  Doc: Add note for rename behavior of IngressGroup (kubernetes-sigs#3283)
  Make Ingress validating webhook ignore ingresses not managed by AWS LBC (kubernetes-sigs#3272)
  add oliviassss as reviewer
  fix the race condition in pod cache and endpoint resolver
  Bump github.com/onsi/ginkgo/v2 from 2.6.0 to 2.11.0
  Bump github.com/aws/aws-sdk-go from 1.44.184 to 1.44.294 (kubernetes-sigs#3271)
  Provide better explanation of failure to find a subnet (kubernetes-sigs#3292)
  test/framework: replace deprecated ioutil.ReadAll (kubernetes-sigs#3256)
  Add warning in doc for ServiceMutatorWebhook (kubernetes-sigs#3180)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants