Skip to content

bumps Go version to 1.17, updates deps and kube libraries#4478

Merged
jetstack-bot merged 13 commits intocert-manager:masterfrom
irbekrm:bump_go_and_deps
Sep 30, 2021
Merged

bumps Go version to 1.17, updates deps and kube libraries#4478
jetstack-bot merged 13 commits intocert-manager:masterfrom
irbekrm:bump_go_and_deps

Conversation

@irbekrm
Copy link
Contributor

@irbekrm irbekrm commented Sep 27, 2021

What this PR does / why we need it:

  • Bumps Go 1.16 -> 1.17
  • Bumps kube libraries v0.22.0 -> v0.22.2
  • Bumps controller runtime v0.9.6 -> v0.10.1
  • Bumps some Bazel deps, nginx-ingress images for e2e tests and a few more things
  • Enforces minimum Bazel version of v4.0.0
  • Uses Bazel to load Kyverno images- this should allow for the images to be cached and hopefully for there to be less timeouts like this

Special notes for your reviewer:

  • Minimum required Bazel version is now v4.0.0 because this is the minimum version required by rules_go v0.28.0. I've updated the CI test images with Bazel in Bazel version bump testing#585 and website#708 updates supported Bazel versions in documentation. I've added some code borrowed from pixie to enforce the minimum version upfront as I think this is preferable as it'd be easier to debug than mystery errors because of version incompatibility

  • controller runtime v0.10.0 fixes a number of bugs that may or may not caused some of our test flakiness

Go 1.17:

irbe@cert-manager$ ls -lha bazel-out/k8-fastbuild/bin/cmd/controller/controller_/controller
-r-xr-xr-x 1 irbe irbe 60M Sep 27 15:53 bazel-out/k8-fastbuild/bin/cmd/controller/controller_/controller <- from current master

irbe@cert-manager$ ls -lha bazel-out/k8-fastbuild/bin/cmd/controller/controller_/controller
-r-xr-xr-x 1 irbe irbe 58M Sep 27 15:57 bazel-out/k8-fastbuild/bin/cmd/controller/controller_/controller <- this branch
cert-manager now uses Go 1.17.

@jetstack-bot jetstack-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. area/acme Indicates a PR directly modifies the ACME Issuer code area/api Indicates a PR directly modifies the 'pkg/apis' directory area/testing Issues relating to testing approved Indicates a PR has been approved by an approver from all required OWNERS files. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Sep 27, 2021
@irbekrm
Copy link
Contributor Author

irbekrm commented Sep 27, 2021

/kind cleanup

@jetstack-bot jetstack-bot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. and removed needs-kind Indicates a PR lacks a `kind/foo` label and requires one. labels Sep 27, 2021
@irbekrm irbekrm changed the title WIP bumps Go version to 1.17, updates deps and kube libraries bumps Go version to 1.17, updates deps and kube libraries Sep 27, 2021
@jetstack-bot jetstack-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 27, 2021
Comment on lines +30 to +45
# This has been copied from https://github.com/bazelbuild/bazel/blob/master/tools/bash/runfiles/runfiles.bash
# It exports rlocation function that can be used to access other bash scripts in this codebase.
# set -e pipefail needs to happen after sourcing runfiles.bash, see https://github.com/bazelbuild/bazel/blob/master/tools/bash/runfiles/runfiles.bash#L21

# --- begin runfiles.bash initialization v2 ---
# Copy-pasted from the Bazel Bash runfiles library v2.
set -uo pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash
source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \
source "$0.runfiles/$f" 2>/dev/null || \
source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
{ echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e
# --- end runfiles.bash initialization v2 ---


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 is so that we can source the functions that remove/replace the autogen build tags from another file (using the rlocation function that is being sourced here- I wanted to do that, to make this file shorter as I had to add some extra functionality to replacing/removing.
Arguably, this adds complexity, but is also an example of how bash libraries can be imported if that was ever useful.

This appears to be a standard way of doing it, see i.e https://github.com/pixie-io/pixie/blob/main/src/e2e_test/px_cluster/test_px_on_gke.sh#L33-L45

Copy link
Member

Choose a reason for hiding this comment

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

It's pretty unreadable, but also quite interesting to look at.
It seems to be attempting to load bazel_tools/tools/bash/runfiles/runfiles.bash from various directories, which may be derived from the name of the current script $0, right?

Thanks for the explanatory comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it is interesting to look at!

It seems to be attempting to load bazel_tools/tools/bash/runfiles/runfiles.bash from various directories, which may be derived from the name of the current script $0, right?

Yes, my understanding of this is that since bazel_tools/tools/bash/runfiles is declared as a dependency of the update-codegen Bazel target (here), it will get added to the 'runfiles' when we bazel run this target- see a limited description of that mechanism here and here. These lines then attempt to source the runfiles.bash script from one of the known locations of these Bazel runfiles.

Perhaps I should add a comment about this.

--set controller.config.no-tls-redirect-locations="" \
--set admissionWebhooks.enabled=false \
--set controller.admissionWebhooks.enabled=false \
--set controller.watchIngressWithoutClass="${INGRESS_WITHOUT_CLASS}" \
Copy link
Contributor Author

@irbekrm irbekrm Sep 28, 2021

Choose a reason for hiding this comment

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

This is because this PR bumps Ingress-NGINX controller's version to v1.0.2 when running on kube 1.22. v1.X Ingress-NGINX requires for ingress class name to be defined on Ingress resources (docs).

cert-manager ingress-shim creates Ingresses with our without class name depending on how the users have configured the HTTP-01 solver on the issuer, see the code. Our e2e tests create some Ingresses without the class name (and we probably want to keep doing that, at least for as long as we support Ingress-NGINX versions where the class name is not mandatory) so the tests break with v1 Ingress-NGINX as the Ingresses without class name are ignored by the controller. Adding this flag makes the controller watch Ingresses without class.

I think we should eventually test with a standard v1 ingress controller configuration (that only wathces Ingresses with class name), but I think we don't want to deploy two ingress controllers, so might need to allow for different test configurations for v1 and pre-v1 ingress controllers.
We may also want to make the field descriptions on the solver spec more clear as to when the class name is required.

Copy link
Member

Choose a reason for hiding this comment

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

Ok. I think I get it. Thanks for the explanatory comment.
It might be worth summarizing that explanation as a comment in the code, for the benefit of others who might be tempted to change the versions etc.

@jetstack-bot jetstack-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 29, 2021
Signed-off-by: irbekrm <irbekrm@gmail.com>
Updates go.mod for Go 1.17

Signed-off-by: irbekrm <irbekrm@gmail.com>
Also refactor

Signed-off-by: irbekrm <irbekrm@gmail.com>
New format of Go build tags gets added

Signed-off-by: irbekrm <irbekrm@gmail.com>
Signed-off-by: irbekrm <irbekrm@gmail.com>
In Go 1.17 x509.CreateCertificate fails if public key doesn't match private key https://golang.org/doc/go1.17

Signed-off-by: irbekrm <irbekrm@gmail.com>
Environment.CRDs is now a slice of apiextensionsv1.CustomResourceDefinitions instead of client.Object kubernetes-sigs/controller-runtime#1626 (comment)

Signed-off-by: irbekrm <irbekrm@gmail.com>
Signed-off-by: irbekrm <irbekrm@gmail.com>
Signed-off-by: irbekrm <irbekrm@gmail.com>
Signed-off-by: irbekrm <irbekrm@gmail.com>
So that we don't pull the same image for each test run.

Also run helm install with --debug so that it outputs more information.

Signed-off-by: irbekrm <irbekrm@gmail.com>
… controller

Because we need to support different versions and configurations

Signed-off-by: irbekrm <irbekrm@gmail.com>
@jetstack-bot jetstack-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 30, 2021
Copy link
Member

@wallrj wallrj left a comment

Choose a reason for hiding this comment

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

Thanks @irbekrm

That's a lot of work and some impressive hacking to work around the problems with the upgrade.

Some parts I didn't understand, and some things I'd like to see explained as comments in the code rather than as PR comments, but also happy to merge this as-is and improve later.

Unhold when you're happy with it.

/lgtm
/hold

--set controller.config.no-tls-redirect-locations="" \
--set admissionWebhooks.enabled=false \
--set controller.admissionWebhooks.enabled=false \
--set controller.watchIngressWithoutClass="${INGRESS_WITHOUT_CLASS}" \
Copy link
Member

Choose a reason for hiding this comment

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

Ok. I think I get it. Thanks for the explanatory comment.
It might be worth summarizing that explanation as a comment in the code, for the benefit of others who might be tempted to change the versions etc.

"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions"
apiextensionsinstall "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/install"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
Copy link
Member

Choose a reason for hiding this comment

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

We're importing this twice with different aliases.

t.Logf("Found CRD with name %q", crd.Name)
}
patchCRDConversion(crds, webhookOpts.URL, webhookOpts.CAPEM)
patchCRDServed(crds)
Copy link
Member

Choose a reason for hiding this comment

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

Wait a minute... I only added this yesterday!

Is it really not needed? If not, then remove the function definition too.

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, I was rebasing this morning and did not realize this was recently added.

I think it may not be needed- I see that served is set to true for all versions in patchCRDConversion function (which was called on the line above) here. I will remove this now, but it would be good if you could double check?

Copy link
Member

Choose a reason for hiding this comment

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

OMG, that's my fault. I originally added it to patchCRDConversion then thought it would be clearer as a separate function and forgot to remove the original place. Sorry about that.

Why does patchCRDConversion now return a new slice of CRDs?
It seems superficial because inside the function we're still mutating the original CRD objects.

If these functions are called patchXYZ then I think it makes sense if they clearly modify the supplied slice of CRDs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah it's a good point about the name and I didn't somehow didn't realize it was modifying those CRDs I think- I will change it back


# Check that a minimum version of bazel is being used.
def check_min_bazel_version(bazel_version):
if "bazel_version" in dir(native) and native.bazel_version:
Copy link
Member

Choose a reason for hiding this comment

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

I guess native is builtin. I don't see it imported anywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

native is a built-in module and bazel_version appears to be an undocumented method within it :) bazelbuild/bazel#8305

@jetstack-bot jetstack-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 30, 2021
@jetstack-bot jetstack-bot added the lgtm Indicates that a PR is ready to be merged. label Sep 30, 2021
@wallrj wallrj mentioned this pull request Sep 30, 2021
Copy link
Member

@wallrj wallrj left a comment

Choose a reason for hiding this comment

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

BTW I also confirmed that I was able to run all the E2E tests locally with Bazel 4

./devel/cluster/install.sh
./devel/setup-e2e-deps.sh
./devel/run-e2e.sh

Ran 468 of 789 Specs in 1059.924 seconds
SUCCESS! -- 468 Passed | 0 Failed | 0 Pending | 321 Skipped


Ginkgo ran 1 suite in 17m40.508821255s
Test Suite Passed

@jetstack-bot jetstack-bot removed the lgtm Indicates that a PR is ready to be merged. label Sep 30, 2021
@irbekrm irbekrm force-pushed the bump_go_and_deps branch 2 times, most recently from 3eb6a1e to 989c8d3 Compare September 30, 2021 15:59
Signed-off-by: irbekrm <irbekrm@gmail.com>
@irbekrm
Copy link
Contributor Author

irbekrm commented Sep 30, 2021

Thanks for the review, all the great comments and verifying that the setup works @wallrj !

I think I've addressed all the comments now.

Copy link
Member

@wallrj wallrj left a comment

Choose a reason for hiding this comment

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

/lgtm

@jetstack-bot jetstack-bot added the lgtm Indicates that a PR is ready to be merged. label Sep 30, 2021
@jetstack-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: irbekrm, wallrj

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

The pull request process is described here

Details 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

@irbekrm
Copy link
Contributor Author

irbekrm commented Sep 30, 2021

/hold cancel

@jetstack-bot jetstack-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 30, 2021
@jetstack-bot jetstack-bot merged commit cfbb32d into cert-manager:master Sep 30, 2021
@irbekrm irbekrm deleted the bump_go_and_deps branch September 30, 2021 17:08
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. area/acme Indicates a PR directly modifies the ACME Issuer code area/api Indicates a PR directly modifies the 'pkg/apis' directory area/testing Issues relating to testing dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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