Skip to content

Commit 24daea6

Browse files
authored
Merge pull request #8339 from bavarianbidi/support_ubuntu_to_flatcar_updates
🐛 enable updates from CloudInit (mostly ubuntu) based KCPs to Ignition (flatcar) based KCPs
2 parents 3fead04 + 13b7f71 commit 24daea6

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_webhook.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ func (in *KubeadmControlPlane) ValidateUpdate(old runtime.Object) error {
171171
{spec, kubeadmConfigSpec, ignition, "*"},
172172
{spec, kubeadmConfigSpec, diskSetup},
173173
{spec, kubeadmConfigSpec, diskSetup, "*"},
174+
{spec, kubeadmConfigSpec, "format"},
175+
{spec, kubeadmConfigSpec, "mounts"},
174176
{spec, "machineTemplate", "metadata"},
175177
{spec, "machineTemplate", "metadata", "*"},
176178
{spec, "machineTemplate", "infrastructureRef", "apiVersion"},
@@ -197,12 +199,6 @@ func (in *KubeadmControlPlane) ValidateUpdate(old runtime.Object) error {
197199
return apierrors.NewBadRequest(fmt.Sprintf("expecting KubeadmControlPlane but got a %T", old))
198200
}
199201

200-
// NOTE: Defaulting for the format field has been added in v1.1.0 after implementing ignition support.
201-
// This allows existing KCP objects to pick up the new default.
202-
if prev.Spec.KubeadmConfigSpec.Format == "" && in.Spec.KubeadmConfigSpec.Format == bootstrapv1.CloudConfig {
203-
allowedPaths = append(allowedPaths, []string{spec, kubeadmConfigSpec, "format"})
204-
}
205-
206202
originalJSON, err := json.Marshal(prev)
207203
if err != nil {
208204
return apierrors.NewInternalError(err)

controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_webhook_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,12 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) {
663663
},
664664
}
665665

666+
switchFromCloudInitToIgnition := before.DeepCopy()
667+
switchFromCloudInitToIgnition.Spec.KubeadmConfigSpec.Format = bootstrapv1.Ignition
668+
switchFromCloudInitToIgnition.Spec.KubeadmConfigSpec.Mounts = []bootstrapv1.MountPoints{
669+
{"/var/lib/testdir", "/var/lib/etcd/data"},
670+
}
671+
666672
tests := []struct {
667673
name string
668674
enableIgnitionFeature bool
@@ -1001,6 +1007,13 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) {
10011007
before: validIgnitionConfigurationBefore,
10021008
kcp: validIgnitionConfigurationAfter,
10031009
},
1010+
{
1011+
name: "should succeed when CloudInit was used before",
1012+
enableIgnitionFeature: true,
1013+
expectErr: false,
1014+
before: before,
1015+
kcp: switchFromCloudInitToIgnition,
1016+
},
10041017
}
10051018

10061019
for _, tt := range tests {

0 commit comments

Comments
 (0)