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

🐛 Fix CoreDNS upgrade from v1.20 to v1.21 #4476

Conversation

fabriziopandini
Copy link
Member

What this PR does / why we need it:
The upstream image for CoreDNS was renamed from 'k8s.gcr.io/coredns' to k8s.gcr.io/coredns/coredns, and this is impacting upgrades of workload clusters from v1.20 to v1.21.
This PR makes KCP upgrades to account for this change.

Please note that:

  • the change applies only to users relying on upstream image repository ('k8s.gcr.io); users relying on custom repository could continue to use mrepo.io/coredns` as image name (no changes required).
  • starting from CoreDNS 1.8.0, the upstream images requires the v prefix on the ImageTag, but this should be taken care by the user when specifying the desired version in KCP.

Which issue(s) this PR fixes:
Fixes #4463

/assign @vincepri
@sbueringer

@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 Apr 14, 2021
@sbueringer
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 14, 2021
@vincepri
Copy link
Member

/hold

Need more time for a review

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 14, 2021
controlplane/kubeadm/internal/workload_cluster_coredns.go Outdated Show resolved Hide resolved
if clusterConfig.ImageRepository != "" {
toImageRepository = fmt.Sprintf("%s/%s", clusterConfig.ImageRepository, coreDNSKey)
toImageRepository = strings.TrimSuffix(clusterConfig.ImageRepository, "/")
Copy link
Member

Choose a reason for hiding this comment

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

Do we need the trim suffix here?

Copy link
Member Author

Choose a reason for hiding this comment

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

given that the image repository is provider by the user, and that down we are concatenating it with image name and tag, I thought that removing the suffix makes the concat operation more robust (it will work with the user providing "k8s.gcr.io" but also "k8s.gcr.io/")

Copy link
Member

Choose a reason for hiding this comment

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

Should we instead validate input and provide guidance to users?

Copy link
Member Author

@fabriziopandini fabriziopandini Apr 14, 2021

Choose a reason for hiding this comment

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

We can add validation and documentation as well (in another PR)
Nevertheless, I don't think this extra caution will hurt, but if you prefer I can remove it; it is not core to the fix we are discussing here

Copy link
Member

Choose a reason for hiding this comment

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

Do we know how kubeadm itself handles / suffixes? (depending on how they are doing it, consistency might be a factor)

Copy link
Member Author

Choose a reason for hiding this comment

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

AFAIK kubeadm is not doing any validation on ImageTag/ImageRepository, nor we are doing in CAPI
Also kubeadm, is not involved in immutable upgrades.

I just thought it making the operation more robust, but happy to remove it if it is blocking this PR...

Copy link
Member

Choose a reason for hiding this comment

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

was just an idea, it's fine for me either way

Copy link
Member

Choose a reason for hiding this comment

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

Could we open a follow-up PR to add validation?

Copy link
Member Author

Choose a reason for hiding this comment

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

Adding validation could have some implications. I opened an issue to discuss them #4482

}
if clusterConfig.DNS.ImageRepository != "" {
toImageRepository = fmt.Sprintf("%s/%s", clusterConfig.DNS.ImageRepository, coreDNSKey)
toImageRepository = strings.TrimSuffix(clusterConfig.DNS.ImageRepository, "/")
Copy link
Member

Choose a reason for hiding this comment

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

Do we need the trim suffix here?

Copy link
Member Author

Choose a reason for hiding this comment

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

(see comment above)

// Handle the renaming of the upstream image from "k8s.gcr.io/coredns" to "k8s.gcr.io/coredns/coredns"
toImageName := parsedImage.Name
if toImageRepository == "k8s.gcr.io" && toImageName == "coredns" && targetMajorMinorPatch.GTE(semver.MustParse("1.8.0")) {
toImageName = "coredns/coredns"
Copy link
Contributor

Choose a reason for hiding this comment

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

we should add some constants for these

Copy link
Member

@sbueringer sbueringer Apr 14, 2021

Choose a reason for hiding this comment

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

Similar to how kubeadm does it, probably add a comment which references the kubeadm upstream contant here https://github.com/kubernetes/kubernetes/blob/release-1.21/cmd/kubeadm/app/constants/constants.go#L331?

Copy link
Contributor

Choose a reason for hiding this comment

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

even better ^

Copy link
Member Author

Choose a reason for hiding this comment

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

Constant added
I would avoid to link to the kubeadm code, because things can change there (e.g constant order was changed during v1.21); also, kubeadm is just adapting to what happen somewhere else

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 14, 2021
@sbueringer
Copy link
Member

/lgtm

@CecileRobertMichon
Copy link
Contributor

/lgtm
/assign @vincepri

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 14, 2021
Copy link
Member

@vincepri vincepri left a comment

Choose a reason for hiding this comment

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

/approve
/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 14, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vincepri

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 Apr 14, 2021
@k8s-ci-robot k8s-ci-robot merged commit 7a3b56d into kubernetes-sigs:master Apr 14, 2021
@k8s-ci-robot k8s-ci-robot added this to the v0.4 milestone Apr 14, 2021
@fabriziopandini fabriziopandini deleted the fix-CoreDNS-1.20-1.21upgrade branch April 15, 2021 10:13
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Periodic e2e test for workload cluster upgrade from v1.20 to v1.21 are failing
5 participants