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

Update go to v1.22, controller-runtime dependency to v0.18.2, and kubernetes libs to v0.30.0 #3707

Merged
merged 14 commits into from
May 24, 2024

Conversation

larntz
Copy link
Contributor

@larntz larntz commented May 17, 2024

Issue

#3649

Description

There is a similar pr open for the kubernetes libs, but there haven't been any updates in a few weeks.

In the comments of that pr there is a comment:

yes we plan to upgrade the controller-runtime to v0.15+, but it has breaking changes and may need more time and efforts to investigate and implement corresponding changes. I think we need to do it sooner than later. Any community contribution is very welcome. Thanks.

This PR is to address the k8s 1.29 dependency updates and refactoring required (the bulk of the changes) to update the controller runtime to v0.15+. Also sets the go version 1.22.

Two tests were removed that were related to decoder injection that is no longer possible in new versions of controller runtime. Two other tests were removed that checked ingresses were deleted there was a deletion timestamp with no finalizer. This is no longer possible because controller-runtime sets the DeletionTimestamp to nil on Create(). Because of this the DeletionTimestamps were also removed from the deleted ingress with finalizer tests.

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 the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 17, 2024
@k8s-ci-robot
Copy link
Contributor

Welcome @larntz!

It looks like this is your first PR to kubernetes-sigs/aws-load-balancer-controller 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/aws-load-balancer-controller has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Contributor

Hi @larntz. 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 needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels May 17, 2024
@larntz
Copy link
Contributor Author

larntz commented May 17, 2024

@aaroniscode and @oliviassss This is related to pr 3675 and issue 3649. I can't push changes to that PR so I created this one.

@larntz larntz changed the title Update controller-runtime dependency to v0.18.2 and kubernetes libs to v0.30.0 Update go to v1.22, controller-runtime dependency to v0.18.2, and kubernetes libs to v0.30.0 May 17, 2024
@shraddhabang
Copy link
Collaborator

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 17, 2024
@larntz
Copy link
Contributor Author

larntz commented May 19, 2024

/retest

@oliviassss
Copy link
Collaborator

@larntz, thanks for the contribution! I'm reviewing this PR. but just notice the e2e test is still failing on this test suite

   STEP: expect dns name from Ingresses be non-empty @ 05/20/24 20:37:19.058
  STEP: expect dns name eventually be available: k8s-e2egroupa3a6c647-827aa94e50-910226086.us-west-2.elb.amazonaws.com @ 05/20/24 20:37:19.246
  STEP: expect http://k8s-e2egroupa3a6c647-827aa94e50-910226086.us-west-2.elb.amazonaws.com/path-a returns backend-a @ 05/20/24 20:40:50.701
  [FAILED] in [It] - /home/prow/go/src/github.com/kubernetes-sigs/aws-load-balancer-controller/test/e2e/ingress/multi_path_backend_test.go:201 @ 05/20/24 20:40:50.811
• [FAILED] [334.566 seconds]
test ingresses with multiple path and backends with podReadinessGate enabled [It] IngressGroup across namespaces should behaves correctly
/home/prow/go/src/github.com/kubernetes-sigs/aws-load-balancer-controller/test/e2e/ingress/multi_path_backend_test.go:101
  [FAILED] Unexpected error:
      <*utils.MultiError | 0xc0016a27f8>: 
      multiple error: [Response Body mismatches, diff:   []uint8{
      + 	0x62,
      + 	0x61,
      + 	0x63,
      + 	0x6b,
      + 	0x65,
      + 	0x6e,
      + 	0x64,
      + 	0x2d,
      + 	0x61,
        }
      ]
      {
          errs: [
              <*errors.fundamental | 0xc0016a2780>{
                  msg: "Response Body mismatches, diff: \u00a0\u00a0[]uint8{\n+\u00a0\t0x62,\n+\u00a0\t0x61,\n+\u00a0\t0x63,\n+\u00a0\t0x6b,\n+\u00a0\t0x65,\n+\u00a0\t0x6e,\n+\u00a0\t0x64,\n+\u00a0\t0x2d,\n+\u00a0\t0x61,\n\u00a0\u00a0}\n",
                  stack: [0x37dc114, 0x37dc4d6, 0x385f1b4, 0x378e015, 0x379ed16, 0x385e53a, 0x3782633, 0x37966ed, 0x162a9a1],
              },
          ],
      }
  occurred
  In [It] at: /home/prow/go/src/github.com/kubernetes-sigs/aws-load-balancer-controller/test/e2e/ingress/multi_path_backend_test.go:201 @ 05/20/24 20:40:50.811 

While I'm checking the code changes, can you try to run the failed test suites locally for a quicker debug? you can try to use ginkgo cmd with --focus option to focus on the specific suites. Something like

  ginkgo -focus "<test description>" -timeout 2h -v -r test/e2e -- \
    --kubeconfig=${CLUSTER_KUBECONFIG} \
    --cluster-name=${CLUSTER_NAME} \
    --aws-region=${AWS_REGION} \
    --aws-vpc-id=${cluster_vpc_id} \
    --helm-chart=${HELM_DIR}/aws-load-balancer-controller \
    --controller-image=${CONTROLLER_IMAGE_NAME} \

@larntz
Copy link
Contributor Author

larntz commented May 20, 2024

@oliviassss yes, I will work on that this evening.

@larntz
Copy link
Contributor Author

larntz commented May 21, 2024

I was able to test this some. I found on this failing test that two ingresses get created in one namespace and one or both are missing the group ingress finalizer metadata. Not sure yet if that's a symptom or cause of the failing test. I will continue troubleshooting, but wanted to provide an update.

This was causing e2e tests to fail when an ingress did not have the
group finalizer. The unit tests ing-1_been_deleted, and ing-6_been_deleted
will need reworked due to changes in the controller-runtime that cause
them to fail.
controller-runtime >=0.15 does not support creating (or adding the field via Update()) objects with a DeletionTimestamp. To work around this we add an annotation `unit-test/delete` to mark the ingresses that we want to test deletion. We check for this annotation and then call Delete(). This will set the DeletionTimestamp to the current date and time so we use IgnoreOtherFields to skip then comparing want to got.

relevant controller-runtime discussion/pr:

- kubernetes-sigs/controller-runtime#2184 (comment)
- kubernetes-sigs/controller-runtime#2316
@larntz
Copy link
Contributor Author

larntz commented May 21, 2024

@oliviassss I think this is ready for a more in depth review now. If you need anything else from me let me know. Thanks!

@oliviassss
Copy link
Collaborator

@larntz, thanks! I left some comments

@oliviassss
Copy link
Collaborator

/lgtm
sending to @M00nF1sh for second opinions
/assign @M00nF1sh

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 22, 2024
@oliviassss oliviassss added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label May 22, 2024
HealthProbeBindAddress: rtCfg.HealthProbeBindAddress,
LeaderElection: rtCfg.EnableLeaderElection,
LeaderElectionResourceLock: resourcelock.ConfigMapsLeasesResourceLock,
LeaderElectionResourceLock: resourcelock.LeasesResourceLock, // resourcelock.ConfigMapsLeasesResourceLock,
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is a behavior change and shall be noted in PR/release note.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Apologies for this. I had intended to remove that comment and explain why this changed. More detail can be found here, but resourcelock.ConfigMapsLeasesResourceLock is no longer an option -- it was removed in client-go v0.28.

From the link:

Note: before controller-runtime version v0.7, it was set to "configmaps".
And from v0.7 to v0.11, the default was "configmapsleases", which was
used to migrate from configmaps to leases.
Since the default was "configmapsleases" for over a year, spanning five minor releases,
any actively maintained operators are very likely to have a released version that uses
"configmapsleases". Therefore defaulting to "leases" should be safe since v0.12.

LeaderElectionID: rtCfg.LeaderElectionID,
LeaderElectionNamespace: rtCfg.LeaderElectionNamespace,
Namespace: rtCfg.WatchNamespace,
Copy link
Collaborator

Choose a reason for hiding this comment

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

this broken original functionality. When rtCfg.WatchNamespace is not empty, it's supposed to only watch Objects(ingress/service/tgb/pods) in specific namespaces.
in this change, i only saw it's passed to pods informer, but not to other the informers.
We need to test and find a alternative in updated controller runtime. it seems to be https://github.com/kubernetes-sigs/controller-runtime/blob/main/pkg/cache/cache.go#L192, but need code reading and tests to find out

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am going to do some additional research on this, and will answer asap.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe you are correct on this. I have added DefaultNamespaces to the cache options.

@M00nF1sh
Copy link
Collaborator

M00nF1sh commented May 22, 2024

@larntz
Thanks for making this change, it's much helpful and looks pretty solid. However, i noticed there are two changes

  1. changed the lease to lease only instead of configmaplease. Can we revert this change and do it in a separate PR(may be can be deferred to a minor version release)
  2. the rtCfg.Namespace is not passed to caches.

@k8s-ci-robot
Copy link
Contributor

New changes are detected. LGTM label has been removed.

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 23, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: larntz
Once this PR has been reviewed and has the lgtm label, please ask for approval from m00nf1sh. For more information see the Kubernetes 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

@larntz
Copy link
Contributor Author

larntz commented May 23, 2024

I tested this locally last night but now realize I didn't update the image tag. I'll work on fixing this today. Apologies for the noise.

If WatchNamespace is set to corev1.NamespaceAll we should not set
DefaultNamespaces.

This code assumes that only one namespace is specified for
WatchNamespace. That decision was based on the help text for the flag
`watch-namespace`.

Related controller-runtime issue: kubernetes-sigs/controller-runtime#2628
@M00nF1sh
Copy link
Collaborator

/ok-to-test

@oliviassss
Copy link
Collaborator

Merging this PR right now. We need to conduct thorough tests on it before shipping it to users.
For example, need to test across k8s versions and aws regions, as well as the features this PR amended, like ingressclassparam, webhookcerts, tgb, etc.

@oliviassss oliviassss merged commit e5c21db into kubernetes-sigs:main May 24, 2024
4 of 5 checks passed
oliviassss pushed a commit to oliviassss/aws-load-balancer-controller that referenced this pull request May 30, 2024
…ernetes libs to v0.30.0 (kubernetes-sigs#3707)

* go version, dep version

* refactor for controller-runtime udpate

* update tests, fix if statement

the controller-runtime strips DeletionTimestamp from manifests on
Create(). kubernetes-sigs/controller-runtime#2316

* refactor tests

* remove placeholder comments

* remove reconciler from WithOptions

* remove DefaultNamespace cache option

* remote `&& !hasGroupFinalizer`

This was causing e2e tests to fail when an ingress did not have the
group finalizer. The unit tests ing-1_been_deleted, and ing-6_been_deleted
will need reworked due to changes in the controller-runtime that cause
them to fail.

* update unit tests for ctrl client/fake >0.15

controller-runtime >=0.15 does not support creating (or adding the field via Update()) objects with a DeletionTimestamp. To work around this we add an annotation `unit-test/delete` to mark the ingresses that we want to test deletion. We check for this annotation and then call Delete(). This will set the DeletionTimestamp to the current date and time so we use IgnoreOtherFields to skip then comparing want to got.

relevant controller-runtime discussion/pr:

- kubernetes-sigs/controller-runtime#2184 (comment)
- kubernetes-sigs/controller-runtime#2316

* remove unused contexts

* add DefaultNamespaces cache config

* set opt.Cache.DefaultNamespaces conditionally

If WatchNamespace is set to corev1.NamespaceAll we should not set
DefaultNamespaces.

This code assumes that only one namespace is specified for
WatchNamespace. That decision was based on the help text for the flag
`watch-namespace`.

Related controller-runtime issue: kubernetes-sigs/controller-runtime#2628

* make crds

* set go to v1.22.3
@oliviassss oliviassss mentioned this pull request May 30, 2024
6 tasks
oliviassss added a commit that referenced this pull request May 30, 2024
* update the traffic test for ingress (#3725)

* update the traffic test for ingress

* make crds

* prevent controller runtime complaining about SetupLogger() was never called (#3724)

* Update go to v1.22, controller-runtime dependency to v0.18.2, and kubernetes libs to v0.30.0 (#3707)

* go version, dep version

* refactor for controller-runtime udpate

* update tests, fix if statement

the controller-runtime strips DeletionTimestamp from manifests on
Create(). kubernetes-sigs/controller-runtime#2316

* refactor tests

* remove placeholder comments

* remove reconciler from WithOptions

* remove DefaultNamespace cache option

* remote `&& !hasGroupFinalizer`

This was causing e2e tests to fail when an ingress did not have the
group finalizer. The unit tests ing-1_been_deleted, and ing-6_been_deleted
will need reworked due to changes in the controller-runtime that cause
them to fail.

* update unit tests for ctrl client/fake >0.15

controller-runtime >=0.15 does not support creating (or adding the field via Update()) objects with a DeletionTimestamp. To work around this we add an annotation `unit-test/delete` to mark the ingresses that we want to test deletion. We check for this annotation and then call Delete(). This will set the DeletionTimestamp to the current date and time so we use IgnoreOtherFields to skip then comparing want to got.

relevant controller-runtime discussion/pr:

- kubernetes-sigs/controller-runtime#2184 (comment)
- kubernetes-sigs/controller-runtime#2316

* remove unused contexts

* add DefaultNamespaces cache config

* set opt.Cache.DefaultNamespaces conditionally

If WatchNamespace is set to corev1.NamespaceAll we should not set
DefaultNamespaces.

This code assumes that only one namespace is specified for
WatchNamespace. That decision was based on the help text for the flag
`watch-namespace`.

Related controller-runtime issue: kubernetes-sigs/controller-runtime#2628

* make crds

* set go to v1.22.3

* restrict resolve resolveViaVPCENIs to fargate only (#3709)

* Added helm envFrom value parameter for cluster-name (#3683)

* Added helm envFrom value parameter for cluster-name

* Update README.md file

* Add envFrom configuration to values.yaml

* Remove empty line in values.yaml

* feat: disable default helm labels (#3574)

* feat: disable helm labels

* fix: doc

* Update README.md (#3638)

Remove extra / in crds

---------

Co-authored-by: Luke Arntz <[email protected]>
Co-authored-by: Omer Aplatony <[email protected]>
Co-authored-by: Rémi BUISSON <[email protected]>
Co-authored-by: Mike Wilson <[email protected]>
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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XXL Denotes a PR that changes 1000+ 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

5 participants