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

✨ enable kubeadm feature gates mutation #10154

Merged

Conversation

adityabhatia
Copy link
Contributor

@adityabhatia adityabhatia commented Feb 14, 2024

What this PR does / why we need it:

This PR aims at:

  1. Enabling mutation of FeatureGates in webhooks
  2. Updating the target field for FeatureGates in Kubeadm config map
  3. Reducing the number of API calls to update Kubeadm config map to 1

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #10050

/area api

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Feb 14, 2024
@k8s-ci-robot k8s-ci-robot added do-not-merge/needs-area PR is missing an area label size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 14, 2024
@adityabhatia
Copy link
Contributor Author

/area api

@k8s-ci-robot k8s-ci-robot added area/api Issues or PRs related to the APIs and removed do-not-merge/needs-area PR is missing an area label labels Feb 14, 2024
@adityabhatia
Copy link
Contributor Author

cc: @fabriziopandini

@adityabhatia adityabhatia force-pushed the kcpFeatureGatesMutation branch 2 times, most recently from 35c3ba4 to b5a33bc Compare February 14, 2024 23:04
@adityabhatia
Copy link
Contributor Author

/test pull-cluster-api-e2e-full-main

@k8s-ci-robot
Copy link
Contributor

@adityabhatia: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test pull-cluster-api-build-main
  • /test pull-cluster-api-e2e-blocking-main
  • /test pull-cluster-api-e2e-conformance-ci-latest-main
  • /test pull-cluster-api-e2e-conformance-main
  • /test pull-cluster-api-e2e-dualstack-and-ipv6-main
  • /test pull-cluster-api-e2e-main
  • /test pull-cluster-api-e2e-mink8s-main
  • /test pull-cluster-api-e2e-upgrade-1-29-1-30-main
  • /test pull-cluster-api-test-main
  • /test pull-cluster-api-test-mink8s-main
  • /test pull-cluster-api-verify-main

The following commands are available to trigger optional jobs:

  • /test pull-cluster-api-apidiff-main

Use /test all to run the following jobs that were automatically triggered:

  • pull-cluster-api-apidiff-main
  • pull-cluster-api-build-main
  • pull-cluster-api-e2e-blocking-main
  • pull-cluster-api-test-main
  • pull-cluster-api-verify-main

In response to this:

/test pull-cluster-api-e2e-full-main

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/test-infra repository.

@adityabhatia
Copy link
Contributor Author

/test pull-cluster-api-e2e-main

@adityabhatia adityabhatia changed the title ✨ enable kubeadm feature flags mutation ✨ enable kubeadm feature gates mutation Feb 15, 2024
Copy link
Member

@neolit123 neolit123 left a comment

Choose a reason for hiding this comment

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

would FG mutations trigger a machine roll-out?

some FGs would only matter for different kubeadm commands, some of which are not used in CAPI.

i guess CAPI users would be required to understand what FGs can be a NO-OP for them?
e.g. one that is "kubeadm reset" or "kubeadm upgrade apply" specific.

controlplane/kubeadm/internal/controllers/fakes_test.go Outdated Show resolved Hide resolved
controlplane/kubeadm/internal/controllers/upgrade.go Outdated Show resolved Hide resolved
controlplane/kubeadm/internal/workload_cluster_test.go Outdated Show resolved Hide resolved
controlplane/kubeadm/internal/workload_cluster_test.go Outdated Show resolved Hide resolved
@adityabhatia
Copy link
Contributor Author

would FG mutations trigger a machine roll-out?

some FGs would only matter for different kubeadm commands, some of which are not used in CAPI.

i guess CAPI users would be required to understand what FGs can be a NO-OP for them? e.g. one that is "kubeadm reset" or "kubeadm upgrade apply" specific.

It does an automatic machine rollout, also mentioned here. I will double check this.

@adityabhatia adityabhatia force-pushed the kcpFeatureGatesMutation branch from b5a33bc to 822ebcf Compare February 15, 2024 10:20
@adityabhatia
Copy link
Contributor Author

/test pull-cluster-api-e2e-main

@adityabhatia adityabhatia force-pushed the kcpFeatureGatesMutation branch from 822ebcf to a2b80c0 Compare February 15, 2024 15:15
@adityabhatia
Copy link
Contributor Author

/test pull-cluster-api-e2e-main

@chrischdi
Copy link
Member

Looks like this adds a panic / nil pointer dereference:

panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x187ad13]

goroutine 168 [running]:
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile.func1()
	sigs.k8s.io/controller-runtime@v0.17.1/pkg/internal/controller/controller.go:116 +0x1e5
panic({0x1d6e780?, 0x3585650?})
	runtime/panic.go:914 +0x21f
sigs.k8s.io/cluster-api/controlplane/kubeadm/internal/controllers.(*KubeadmControlPlaneReconciler).upgradeControlPlane(0x20eb3c3?, {0x23c8618, 0xc001d07dd0}, 0xc0023ea9a0, 0x2?)
	sigs.k8s.io/cluster-api/controlplane/kubeadm/internal/controllers/upgrade.go:91 +0x5f3
sigs.k8s.io/cluster-api/controlplane/kubeadm/internal/controllers.(*KubeadmControlPlaneReconciler).reconcile(0xc0004ce6e0?, {0x23c8618, 0xc001d07dd0}, 0xc0023ea9a0)
	sigs.k8s.io/cluster-api/controlplane/kubeadm/internal/controllers/controller.go:407 +0x1579
sigs.k8s.io/cluster-api/controlplane/kubeadm/internal/controllers.(*KubeadmControlPlaneReconciler).Reconcile(0xc0004ce6e0, {0x23c8618, 0xc001d07bc0}, {{{0xc0023cc4a6?, 0x0?}, {0xc0023cc4b0?, 0xc001fb0d08?}}})
	sigs.k8s.io/cluster-api/controlplane/kubeadm/internal/controllers/controller.go:251 +0x994
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile(0x23cced0?, {0x23c8618?, 0xc001d07bc0?}, {{{0xc0023cc4a6?, 0xb?}, {0xc0023cc4b0?, 0x0?}}})
	sigs.k8s.io/controller-runtime@v0.17.1/pkg/internal/controller/controller.go:119 +0xb7
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler(0xc0004ce780, {0x23c8650, 0xc0003582d0}, {0x1e33aa0?, 0xc0016fe4a0?})
	sigs.k8s.io/controller-runtime@v0.17.1/pkg/internal/controller/controller.go:316 +0x3cc
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem(0xc0004ce780, {0x23c8650, 0xc0003582d0})
	sigs.k8s.io/controller-runtime@v0.17.1/pkg/internal/controller/controller.go:266 +0x1af
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2()
	sigs.k8s.io/controller-runtime@v0.17.1/pkg/internal/controller/controller.go:227 +0x79
created by sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2 in goroutine 201
	sigs.k8s.io/controller-runtime@v0.17.1/pkg/internal/controller/controller.go:223 +0x565

@adityabhatia adityabhatia force-pushed the kcpFeatureGatesMutation branch from a2b80c0 to 8702cfc Compare February 16, 2024 10:08
@adityabhatia
Copy link
Contributor Author

/retest

@adityabhatia
Copy link
Contributor Author

/test pull-cluster-api-e2e-main

@adityabhatia adityabhatia force-pushed the kcpFeatureGatesMutation branch 2 times, most recently from 2616f47 to b68eefb Compare February 16, 2024 15:12
controlplane/kubeadm/internal/workload_cluster.go Outdated Show resolved Hide resolved
controlplane/kubeadm/internal/workload_cluster.go Outdated Show resolved Hide resolved
@@ -93,22 +93,24 @@ loopmembers:
}

// UpdateEtcdVersionInKubeadmConfigMap sets the imageRepository or the imageTag or both in the kubeadm config map.
func (w *Workload) UpdateEtcdVersionInKubeadmConfigMap(ctx context.Context, imageRepository, imageTag string, version semver.Version) error {
return w.updateClusterConfiguration(ctx, func(c *bootstrapv1.ClusterConfiguration) {
func (w *Workload) UpdateEtcdVersionInKubeadmConfigMap(imageRepository, imageTag string) func(*bootstrapv1.ClusterConfiguration, *[]string) {
Copy link
Member

Choose a reason for hiding this comment

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

I think we are missing something for etcd.
If I look at what the webhook allows to change, we can change everything both for local etcd and external etcd.

Instead here (and in UpdateEtcdExtraArgsInKubeadmConfigMap) we do not persist changes to:

  • etcd.local.DataDir
  • etcd.local.ServerCertSANs
  • etcd.local.PeerCertSANs
  • etcd.External.*

What about refactoring UpdateEtcdVersionInKubeadmConfigMap and UpdateEtcdExtraArgsInKubeadmConfigMap into UpdateEtcdLocalInKubeadmConfigMap (+ filling the gaps) and adding a new UpdateEtcdExternalInKubeadmConfigMap to be called from controlplane/kubeadm/internal/controllers/upgrade.go?

Copy link
Contributor Author

@adityabhatia adityabhatia Feb 19, 2024

Choose a reason for hiding this comment

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

Sounds good, we can additionally persist all local and external properties of etcd in the config map.
Since this requires a refactoring to the current methods and subsequently the interface as well (and tests), it makes sense to combine it with the interface clean-up addressed here IMHO #10154 (comment), wdyt? I can take this up directly after this issues is closed.

Copy link
Member

Choose a reason for hiding this comment

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

let's tackle this in this PR (thinking about a potential backport in the 1.6 branch)

@adityabhatia adityabhatia force-pushed the kcpFeatureGatesMutation branch 5 times, most recently from f2d9b42 to 885fd17 Compare February 20, 2024 19:45
@adityabhatia
Copy link
Contributor Author

/test pull-cluster-api-e2e-main

@fabriziopandini
Copy link
Member

/lgtm
@chrischdi do you have time for a final pass?

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

LGTM label has been added.

Git tree hash: 278f3645cf59d69dc575f439192a09a621799c61

@@ -30,6 +30,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
yaml2 "sigs.k8s.io/yaml"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
yaml2 "sigs.k8s.io/yaml"
"sigs.k8s.io/yaml"

Let's alias the capi owned yaml package to utilyaml here (we already do so in other packages)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also changed in other files, which are a part of 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.

would not have been necessary but also does not hurt 👍

@chrischdi
Copy link
Member

One last nit :-)

@adityabhatia adityabhatia force-pushed the kcpFeatureGatesMutation branch from 885fd17 to d86ba52 Compare February 22, 2024 12:24
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 22, 2024
@chrischdi
Copy link
Member

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chrischdi

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 Feb 22, 2024
@fabriziopandini
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 Feb 22, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 91b6788c82d31056e1b3a78bb7094878283641d2

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/api Issues or PRs related to the APIs 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.

Kubeadm feature flags should be mutable
5 participants