Skip to content

Commit 8702cfc

Browse files
committed
enable kubeadm feature flags mutation
1 parent d63021c commit 8702cfc

11 files changed

+242
-113
lines changed

controlplane/kubeadm/internal/controllers/controller_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1279,7 +1279,8 @@ dns:
12791279
type: CoreDNS
12801280
imageRepository: registry.k8s.io
12811281
kind: ClusterConfiguration
1282-
kubernetesVersion: metav1.16.1`,
1282+
kubernetesVersion: metav1.16.1
1283+
`,
12831284
},
12841285
}
12851286
g.Expect(env.Create(ctx, kubeadmCM)).To(Succeed())

controlplane/kubeadm/internal/controllers/fakes_test.go

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (f *fakeManagementCluster) List(ctx context.Context, list client.ObjectList
4848
return f.Reader.List(ctx, list, opts...)
4949
}
5050

51-
func (f *fakeManagementCluster) GetWorkloadCluster(_ context.Context, _ client.ObjectKey) (internal.WorkloadCluster, error) {
51+
func (f *fakeManagementCluster) GetWorkloadCluster(context.Context, client.ObjectKey) (internal.WorkloadCluster, error) {
5252
return f.Workload, nil
5353
}
5454

@@ -80,65 +80,69 @@ func (f fakeWorkloadCluster) ForwardEtcdLeadership(_ context.Context, _ *cluster
8080
return nil
8181
}
8282

83-
func (f fakeWorkloadCluster) ReconcileEtcdMembers(_ context.Context, _ []string, _ semver.Version) ([]string, error) {
83+
func (f fakeWorkloadCluster) ReconcileEtcdMembers(context.Context, []string, semver.Version) ([]string, error) {
8484
return nil, nil
8585
}
8686

87-
func (f fakeWorkloadCluster) ClusterStatus(_ context.Context) (internal.ClusterStatus, error) {
87+
func (f fakeWorkloadCluster) ClusterStatus(context.Context) (internal.ClusterStatus, error) {
8888
return f.Status, nil
8989
}
9090

91-
func (f fakeWorkloadCluster) GetAPIServerCertificateExpiry(_ context.Context, _ *bootstrapv1.KubeadmConfig, _ string) (*time.Time, error) {
91+
func (f fakeWorkloadCluster) GetAPIServerCertificateExpiry(context.Context, *bootstrapv1.KubeadmConfig, string) (*time.Time, error) {
9292
return f.APIServerCertificateExpiry, nil
9393
}
9494

95-
func (f fakeWorkloadCluster) AllowBootstrapTokensToGetNodes(_ context.Context) error {
95+
func (f fakeWorkloadCluster) AllowBootstrapTokensToGetNodes(context.Context) error {
9696
return nil
9797
}
9898

99-
func (f fakeWorkloadCluster) AllowClusterAdminPermissions(_ context.Context, _ semver.Version) error {
99+
func (f fakeWorkloadCluster) AllowClusterAdminPermissions(context.Context, semver.Version) error {
100100
return nil
101101
}
102102

103-
func (f fakeWorkloadCluster) ReconcileKubeletRBACRole(_ context.Context, _ semver.Version) error {
103+
func (f fakeWorkloadCluster) ReconcileKubeletRBACRole(context.Context, semver.Version) error {
104104
return nil
105105
}
106106

107-
func (f fakeWorkloadCluster) ReconcileKubeletRBACBinding(_ context.Context, _ semver.Version) error {
107+
func (f fakeWorkloadCluster) ReconcileKubeletRBACBinding(context.Context, semver.Version) error {
108108
return nil
109109
}
110110

111-
func (f fakeWorkloadCluster) UpdateKubernetesVersionInKubeadmConfigMap(_ context.Context, _ semver.Version) error {
111+
func (f fakeWorkloadCluster) UpdateKubernetesVersionInKubeadmConfigMap(semver.Version) func(*bootstrapv1.ClusterConfiguration, *[]string) {
112112
return nil
113113
}
114114

115-
func (f fakeWorkloadCluster) UpdateEtcdVersionInKubeadmConfigMap(_ context.Context, _, _ string, _ semver.Version) error {
115+
func (f fakeWorkloadCluster) UpdateEtcdVersionInKubeadmConfigMap(*bootstrapv1.LocalEtcd) func(*bootstrapv1.ClusterConfiguration, *[]string) {
116116
return nil
117117
}
118118

119-
func (f fakeWorkloadCluster) UpdateKubeletConfigMap(_ context.Context, _ semver.Version) error {
119+
func (f fakeWorkloadCluster) UpdateKubeletConfigMap(context.Context, semver.Version) error {
120120
return nil
121121
}
122122

123-
func (f fakeWorkloadCluster) RemoveEtcdMemberForMachine(_ context.Context, _ *clusterv1.Machine) error {
123+
func (f fakeWorkloadCluster) RemoveEtcdMemberForMachine(context.Context, *clusterv1.Machine) error {
124124
return nil
125125
}
126126

127-
func (f fakeWorkloadCluster) RemoveMachineFromKubeadmConfigMap(_ context.Context, _ *clusterv1.Machine, _ semver.Version) error {
127+
func (f fakeWorkloadCluster) RemoveMachineFromKubeadmConfigMap(context.Context, *clusterv1.Machine, semver.Version) error {
128128
return nil
129129
}
130130

131-
func (f fakeWorkloadCluster) EtcdMembers(_ context.Context) ([]string, error) {
131+
func (f fakeWorkloadCluster) EtcdMembers(context.Context) ([]string, error) {
132132
return f.EtcdMembersResult, nil
133133
}
134134

135+
func (f fakeWorkloadCluster) UpdateClusterConfiguration(context.Context, semver.Version, ...func(*bootstrapv1.ClusterConfiguration, *[]string)) error {
136+
return nil
137+
}
138+
135139
type fakeMigrator struct {
136140
migrateCalled bool
137141
migrateErr error
138142
migratedCorefile string
139143
}
140144

141-
func (m *fakeMigrator) Migrate(_, _, _ string, _ bool) (string, error) {
145+
func (m *fakeMigrator) Migrate(string, string, string, bool) (string, error) {
142146
m.migrateCalled = true
143147
if m.migrateErr != nil {
144148
return "", m.migrateErr

controlplane/kubeadm/internal/controllers/upgrade.go

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"github.com/pkg/errors"
2424
ctrl "sigs.k8s.io/controller-runtime"
2525

26+
bootstrapv1 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta1"
2627
controlplanev1 "sigs.k8s.io/cluster-api/controlplane/kubeadm/api/v1beta1"
2728
"sigs.k8s.io/cluster-api/controlplane/kubeadm/internal"
2829
"sigs.k8s.io/cluster-api/util"
@@ -73,9 +74,8 @@ func (r *KubeadmControlPlaneReconciler) upgradeControlPlane(
7374
return ctrl.Result{}, errors.Wrap(err, "failed to set cluster-admin ClusterRoleBinding for kubeadm")
7475
}
7576

76-
if err := workloadCluster.UpdateKubernetesVersionInKubeadmConfigMap(ctx, parsedVersion); err != nil {
77-
return ctrl.Result{}, errors.Wrap(err, "failed to update the kubernetes version in the kubeadm config map")
78-
}
77+
kubeadmCMMutators := make([]func(*bootstrapv1.ClusterConfiguration, *[]string), 0)
78+
kubeadmCMMutators = append(kubeadmCMMutators, workloadCluster.UpdateKubernetesVersionInKubeadmConfigMap(parsedVersion))
7979

8080
if controlPlane.KCP.Spec.KubeadmConfigSpec.ClusterConfiguration != nil {
8181
// We intentionally only parse major/minor/patch so that the subsequent code
@@ -84,38 +84,23 @@ func (r *KubeadmControlPlaneReconciler) upgradeControlPlane(
8484
if err != nil {
8585
return ctrl.Result{}, errors.Wrapf(err, "failed to parse kubernetes version %q", controlPlane.KCP.Spec.Version)
8686
}
87+
8788
// Get the imageRepository or the correct value if nothing is set and a migration is necessary.
8889
imageRepository := internal.ImageRepositoryFromClusterConfig(controlPlane.KCP.Spec.KubeadmConfigSpec.ClusterConfiguration, parsedVersionTolerant)
8990

90-
if err := workloadCluster.UpdateImageRepositoryInKubeadmConfigMap(ctx, imageRepository, parsedVersion); err != nil {
91-
return ctrl.Result{}, errors.Wrap(err, "failed to update the image repository in the kubeadm config map")
92-
}
93-
}
94-
95-
if controlPlane.KCP.Spec.KubeadmConfigSpec.ClusterConfiguration != nil && controlPlane.KCP.Spec.KubeadmConfigSpec.ClusterConfiguration.Etcd.Local != nil {
96-
meta := controlPlane.KCP.Spec.KubeadmConfigSpec.ClusterConfiguration.Etcd.Local.ImageMeta
97-
if err := workloadCluster.UpdateEtcdVersionInKubeadmConfigMap(ctx, meta.ImageRepository, meta.ImageTag, parsedVersion); err != nil {
98-
return ctrl.Result{}, errors.Wrap(err, "failed to update the etcd version in the kubeadm config map")
99-
}
100-
101-
extraArgs := controlPlane.KCP.Spec.KubeadmConfigSpec.ClusterConfiguration.Etcd.Local.ExtraArgs
102-
if err := workloadCluster.UpdateEtcdExtraArgsInKubeadmConfigMap(ctx, extraArgs, parsedVersion); err != nil {
103-
return ctrl.Result{}, errors.Wrap(err, "failed to update the etcd extra args in the kubeadm config map")
104-
}
91+
kubeadmCMMutators = append(kubeadmCMMutators,
92+
workloadCluster.UpdateImageRepositoryInKubeadmConfigMap(imageRepository),
93+
workloadCluster.UpdateFeatureGatesInKubeadmConfigMap(controlPlane.KCP.Spec.KubeadmConfigSpec.ClusterConfiguration.FeatureGates),
94+
workloadCluster.UpdateEtcdVersionInKubeadmConfigMap(controlPlane.KCP.Spec.KubeadmConfigSpec.ClusterConfiguration.Etcd.Local),
95+
workloadCluster.UpdateEtcdExtraArgsInKubeadmConfigMap(controlPlane.KCP.Spec.KubeadmConfigSpec.ClusterConfiguration.Etcd.Local),
96+
workloadCluster.UpdateAPIServerInKubeadmConfigMap(controlPlane.KCP.Spec.KubeadmConfigSpec.ClusterConfiguration.APIServer),
97+
workloadCluster.UpdateControllerManagerInKubeadmConfigMap(controlPlane.KCP.Spec.KubeadmConfigSpec.ClusterConfiguration.ControllerManager),
98+
workloadCluster.UpdateSchedulerInKubeadmConfigMap(controlPlane.KCP.Spec.KubeadmConfigSpec.ClusterConfiguration.Scheduler))
10599
}
106100

107-
if controlPlane.KCP.Spec.KubeadmConfigSpec.ClusterConfiguration != nil {
108-
if err := workloadCluster.UpdateAPIServerInKubeadmConfigMap(ctx, controlPlane.KCP.Spec.KubeadmConfigSpec.ClusterConfiguration.APIServer, parsedVersion); err != nil {
109-
return ctrl.Result{}, errors.Wrap(err, "failed to update api server in the kubeadm config map")
110-
}
111-
112-
if err := workloadCluster.UpdateControllerManagerInKubeadmConfigMap(ctx, controlPlane.KCP.Spec.KubeadmConfigSpec.ClusterConfiguration.ControllerManager, parsedVersion); err != nil {
113-
return ctrl.Result{}, errors.Wrap(err, "failed to update controller manager in the kubeadm config map")
114-
}
115-
116-
if err := workloadCluster.UpdateSchedulerInKubeadmConfigMap(ctx, controlPlane.KCP.Spec.KubeadmConfigSpec.ClusterConfiguration.Scheduler, parsedVersion); err != nil {
117-
return ctrl.Result{}, errors.Wrap(err, "failed to update scheduler in the kubeadm config map")
118-
}
101+
// collectively update Kubeadm config map
102+
if err = workloadCluster.UpdateClusterConfiguration(ctx, parsedVersion, kubeadmCMMutators...); err != nil {
103+
return ctrl.Result{}, err
119104
}
120105

121106
if err := workloadCluster.UpdateKubeletConfigMap(ctx, parsedVersion); err != nil {

controlplane/kubeadm/internal/webhooks/kubeadm_control_plane.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ const (
150150
ntp = "ntp"
151151
ignition = "ignition"
152152
diskSetup = "diskSetup"
153+
featureGates = "featureGates"
153154
)
154155

155156
const minimumCertificatesExpiryDays = 7
@@ -176,6 +177,8 @@ func (webhook *KubeadmControlPlane) ValidateUpdate(_ context.Context, oldObj, ne
176177
{spec, kubeadmConfigSpec, clusterConfiguration, "dns", "imageRepository"},
177178
{spec, kubeadmConfigSpec, clusterConfiguration, "dns", "imageTag"},
178179
{spec, kubeadmConfigSpec, clusterConfiguration, "imageRepository"},
180+
{spec, kubeadmConfigSpec, clusterConfiguration, featureGates},
181+
{spec, kubeadmConfigSpec, clusterConfiguration, featureGates, "*"},
179182
{spec, kubeadmConfigSpec, clusterConfiguration, apiServer},
180183
{spec, kubeadmConfigSpec, clusterConfiguration, apiServer, "*"},
181184
{spec, kubeadmConfigSpec, clusterConfiguration, controllerManager},

controlplane/kubeadm/internal/webhooks/kubeadm_control_plane_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -886,8 +886,8 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) {
886886
kcp: imageRepository,
887887
},
888888
{
889-
name: "should fail when making a change to the cluster config's featureGates",
890-
expectErr: true,
889+
name: "should succeed when making a change to the cluster config's featureGates",
890+
expectErr: false,
891891
before: before,
892892
kcp: featureGates,
893893
},

controlplane/kubeadm/internal/workload_cluster.go

Lines changed: 50 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"fmt"
2828
"math/big"
2929
"reflect"
30+
"strings"
3031
"time"
3132

3233
"github.com/blang/semver/v4"
@@ -105,13 +106,14 @@ type WorkloadCluster interface {
105106
// Upgrade related tasks.
106107
ReconcileKubeletRBACBinding(ctx context.Context, version semver.Version) error
107108
ReconcileKubeletRBACRole(ctx context.Context, version semver.Version) error
108-
UpdateKubernetesVersionInKubeadmConfigMap(ctx context.Context, version semver.Version) error
109-
UpdateImageRepositoryInKubeadmConfigMap(ctx context.Context, imageRepository string, version semver.Version) error
110-
UpdateEtcdVersionInKubeadmConfigMap(ctx context.Context, imageRepository, imageTag string, version semver.Version) error
111-
UpdateEtcdExtraArgsInKubeadmConfigMap(ctx context.Context, extraArgs map[string]string, version semver.Version) error
112-
UpdateAPIServerInKubeadmConfigMap(ctx context.Context, apiServer bootstrapv1.APIServer, version semver.Version) error
113-
UpdateControllerManagerInKubeadmConfigMap(ctx context.Context, controllerManager bootstrapv1.ControlPlaneComponent, version semver.Version) error
114-
UpdateSchedulerInKubeadmConfigMap(ctx context.Context, scheduler bootstrapv1.ControlPlaneComponent, version semver.Version) error
109+
UpdateKubernetesVersionInKubeadmConfigMap(version semver.Version) func(*bootstrapv1.ClusterConfiguration, *[]string)
110+
UpdateImageRepositoryInKubeadmConfigMap(imageRepository string) func(*bootstrapv1.ClusterConfiguration, *[]string)
111+
UpdateFeatureGatesInKubeadmConfigMap(featureGates map[string]bool) func(*bootstrapv1.ClusterConfiguration, *[]string)
112+
UpdateEtcdVersionInKubeadmConfigMap(etcd *bootstrapv1.LocalEtcd) func(*bootstrapv1.ClusterConfiguration, *[]string)
113+
UpdateEtcdExtraArgsInKubeadmConfigMap(etcd *bootstrapv1.LocalEtcd) func(*bootstrapv1.ClusterConfiguration, *[]string)
114+
UpdateAPIServerInKubeadmConfigMap(apiServer bootstrapv1.APIServer) func(*bootstrapv1.ClusterConfiguration, *[]string)
115+
UpdateControllerManagerInKubeadmConfigMap(controllerManager bootstrapv1.ControlPlaneComponent) func(*bootstrapv1.ClusterConfiguration, *[]string)
116+
UpdateSchedulerInKubeadmConfigMap(scheduler bootstrapv1.ControlPlaneComponent) func(*bootstrapv1.ClusterConfiguration, *[]string)
115117
UpdateKubeletConfigMap(ctx context.Context, version semver.Version) error
116118
UpdateKubeProxyImageInfo(ctx context.Context, kcp *controlplanev1.KubeadmControlPlane, version semver.Version) error
117119
UpdateCoreDNS(ctx context.Context, kcp *controlplanev1.KubeadmControlPlane, version semver.Version) error
@@ -121,6 +123,7 @@ type WorkloadCluster interface {
121123
ForwardEtcdLeadership(ctx context.Context, machine *clusterv1.Machine, leaderCandidate *clusterv1.Machine) error
122124
AllowBootstrapTokensToGetNodes(ctx context.Context) error
123125
AllowClusterAdminPermissions(ctx context.Context, version semver.Version) error
126+
UpdateClusterConfiguration(ctx context.Context, version semver.Version, mutators ...func(*bootstrapv1.ClusterConfiguration, *[]string)) error
124127

125128
// State recovery tasks.
126129
ReconcileEtcdMembers(ctx context.Context, nodeNames []string, version semver.Version) ([]string, error)
@@ -173,20 +176,35 @@ func (w *Workload) getConfigMap(ctx context.Context, configMap ctrlclient.Object
173176
}
174177

175178
// UpdateImageRepositoryInKubeadmConfigMap updates the image repository in the kubeadm config map.
176-
func (w *Workload) UpdateImageRepositoryInKubeadmConfigMap(ctx context.Context, imageRepository string, version semver.Version) error {
177-
return w.updateClusterConfiguration(ctx, func(c *bootstrapv1.ClusterConfiguration) {
179+
func (w *Workload) UpdateImageRepositoryInKubeadmConfigMap(imageRepository string) func(*bootstrapv1.ClusterConfiguration, *[]string) {
180+
return func(c *bootstrapv1.ClusterConfiguration, updatedKeys *[]string) {
178181
if imageRepository == "" {
179182
return
180183
}
184+
181185
c.ImageRepository = imageRepository
182-
}, version)
186+
*updatedKeys = append(*updatedKeys, "imageRepository")
187+
}
188+
}
189+
190+
// UpdateFeatureGatesInKubeadmConfigMap updates the feature gates in the kubeadm config map.
191+
func (w *Workload) UpdateFeatureGatesInKubeadmConfigMap(featureGates map[string]bool) func(*bootstrapv1.ClusterConfiguration, *[]string) {
192+
return func(c *bootstrapv1.ClusterConfiguration, updatedKeys *[]string) {
193+
if featureGates == nil {
194+
return
195+
}
196+
197+
c.FeatureGates = featureGates
198+
*updatedKeys = append(*updatedKeys, "featureGates")
199+
}
183200
}
184201

185202
// UpdateKubernetesVersionInKubeadmConfigMap updates the kubernetes version in the kubeadm config map.
186-
func (w *Workload) UpdateKubernetesVersionInKubeadmConfigMap(ctx context.Context, version semver.Version) error {
187-
return w.updateClusterConfiguration(ctx, func(c *bootstrapv1.ClusterConfiguration) {
203+
func (w *Workload) UpdateKubernetesVersionInKubeadmConfigMap(version semver.Version) func(*bootstrapv1.ClusterConfiguration, *[]string) {
204+
return func(c *bootstrapv1.ClusterConfiguration, updatedKeys *[]string) {
188205
c.KubernetesVersion = fmt.Sprintf("v%s", version.String())
189-
}, version)
206+
*updatedKeys = append(*updatedKeys, "kubernetesVersion")
207+
}
190208
}
191209

192210
// UpdateKubeletConfigMap will create a new kubelet-config-1.x config map for a new version of the kubelet.
@@ -270,24 +288,27 @@ func (w *Workload) UpdateKubeletConfigMap(ctx context.Context, version semver.Ve
270288
}
271289

272290
// UpdateAPIServerInKubeadmConfigMap updates api server configuration in kubeadm config map.
273-
func (w *Workload) UpdateAPIServerInKubeadmConfigMap(ctx context.Context, apiServer bootstrapv1.APIServer, version semver.Version) error {
274-
return w.updateClusterConfiguration(ctx, func(c *bootstrapv1.ClusterConfiguration) {
291+
func (w *Workload) UpdateAPIServerInKubeadmConfigMap(apiServer bootstrapv1.APIServer) func(*bootstrapv1.ClusterConfiguration, *[]string) {
292+
return func(c *bootstrapv1.ClusterConfiguration, updatedKeys *[]string) {
275293
c.APIServer = apiServer
276-
}, version)
294+
*updatedKeys = append(*updatedKeys, "apiServer")
295+
}
277296
}
278297

279298
// UpdateControllerManagerInKubeadmConfigMap updates controller manager configuration in kubeadm config map.
280-
func (w *Workload) UpdateControllerManagerInKubeadmConfigMap(ctx context.Context, controllerManager bootstrapv1.ControlPlaneComponent, version semver.Version) error {
281-
return w.updateClusterConfiguration(ctx, func(c *bootstrapv1.ClusterConfiguration) {
299+
func (w *Workload) UpdateControllerManagerInKubeadmConfigMap(controllerManager bootstrapv1.ControlPlaneComponent) func(*bootstrapv1.ClusterConfiguration, *[]string) {
300+
return func(c *bootstrapv1.ClusterConfiguration, updatedKeys *[]string) {
282301
c.ControllerManager = controllerManager
283-
}, version)
302+
*updatedKeys = append(*updatedKeys, "controllerManager")
303+
}
284304
}
285305

286306
// UpdateSchedulerInKubeadmConfigMap updates scheduler configuration in kubeadm config map.
287-
func (w *Workload) UpdateSchedulerInKubeadmConfigMap(ctx context.Context, scheduler bootstrapv1.ControlPlaneComponent, version semver.Version) error {
288-
return w.updateClusterConfiguration(ctx, func(c *bootstrapv1.ClusterConfiguration) {
307+
func (w *Workload) UpdateSchedulerInKubeadmConfigMap(scheduler bootstrapv1.ControlPlaneComponent) func(*bootstrapv1.ClusterConfiguration, *[]string) {
308+
return func(c *bootstrapv1.ClusterConfiguration, updatedKeys *[]string) {
289309
c.Scheduler = scheduler
290-
}, version)
310+
*updatedKeys = append(*updatedKeys, "scheduler")
311+
}
291312
}
292313

293314
// RemoveMachineFromKubeadmConfigMap removes the entry for the machine from the kubeadm configmap.
@@ -350,11 +371,11 @@ func (w *Workload) updateClusterStatus(ctx context.Context, mutator func(status
350371
})
351372
}
352373

353-
// updateClusterConfiguration gets the ClusterConfiguration kubeadm-config ConfigMap, converts it to the
374+
// UpdateClusterConfiguration gets the ClusterConfiguration kubeadm-config ConfigMap, converts it to the
354375
// Cluster API representation, and then applies a mutation func; if changes are detected, the
355376
// data are converted back into the Kubeadm API version in use for the target Kubernetes version and the
356377
// kubeadm-config ConfigMap updated.
357-
func (w *Workload) updateClusterConfiguration(ctx context.Context, mutator func(*bootstrapv1.ClusterConfiguration), version semver.Version) error {
378+
func (w *Workload) UpdateClusterConfiguration(ctx context.Context, version semver.Version, mutators ...func(*bootstrapv1.ClusterConfiguration, *[]string)) error {
358379
return retry.RetryOnConflict(retry.DefaultBackoff, func() error {
359380
key := ctrlclient.ObjectKey{Name: kubeadmConfigKey, Namespace: metav1.NamespaceSystem}
360381
configMap, err := w.getConfigMap(ctx, key)
@@ -373,7 +394,10 @@ func (w *Workload) updateClusterConfiguration(ctx context.Context, mutator func(
373394
}
374395

375396
updatedObj := currentObj.DeepCopy()
376-
mutator(updatedObj)
397+
updatedKeys := make([]string, 0)
398+
for i := range mutators {
399+
mutators[i](updatedObj, &updatedKeys)
400+
}
377401

378402
if !reflect.DeepEqual(currentObj, updatedObj) {
379403
updatedData, err := kubeadmtypes.MarshalClusterConfigurationForVersion(updatedObj, version)
@@ -382,7 +406,7 @@ func (w *Workload) updateClusterConfiguration(ctx context.Context, mutator func(
382406
}
383407
configMap.Data[clusterConfigurationKey] = updatedData
384408
if err := w.Client.Update(ctx, configMap); err != nil {
385-
return errors.Wrap(err, "failed to upgrade the kubeadmConfigMap")
409+
return errors.Wrapf(err, "failed to upgrade the kubeadmConfigMap with the following properties %s", strings.Join(updatedKeys, ","))
386410
}
387411
}
388412
return nil

0 commit comments

Comments
 (0)