Skip to content

Commit

Permalink
Merge pull request #8356 from bavarianbidi/ubuntu_flatcar_updates_rel…
Browse files Browse the repository at this point in the history
…ease1.2

🐛 Enable updates from CloudInit (mostly ubuntu) based KCPs to Ignition (flatcar) based KCPs
  • Loading branch information
k8s-ci-robot committed Mar 28, 2023
2 parents c1660d3 + 0710c20 commit 55421a1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ func (in *KubeadmControlPlane) ValidateUpdate(old runtime.Object) error {
{spec, kubeadmConfigSpec, ntp, "*"},
{spec, kubeadmConfigSpec, ignition},
{spec, kubeadmConfigSpec, ignition, "*"},
{spec, kubeadmConfigSpec, "format"},
{spec, kubeadmConfigSpec, "mounts"},
{spec, "machineTemplate", "metadata"},
{spec, "machineTemplate", "metadata", "*"},
{spec, "machineTemplate", "infrastructureRef", "apiVersion"},
Expand All @@ -184,12 +186,6 @@ func (in *KubeadmControlPlane) ValidateUpdate(old runtime.Object) error {
return apierrors.NewBadRequest(fmt.Sprintf("expecting KubeadmControlPlane but got a %T", old))
}

// NOTE: Defaulting for the format field has been added in v1.1.0 after implementing ignition support.
// This allows existing KCP objects to pick up the new default.
if prev.Spec.KubeadmConfigSpec.Format == "" && in.Spec.KubeadmConfigSpec.Format == bootstrapv1.CloudConfig {
allowedPaths = append(allowedPaths, []string{spec, kubeadmConfigSpec, "format"})
}

originalJSON, err := json.Marshal(prev)
if err != nil {
return apierrors.NewInternalError(err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,12 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) {
Directory: "/tmp/patches",
}

switchFromCloudInitToIgnition := before.DeepCopy()
switchFromCloudInitToIgnition.Spec.KubeadmConfigSpec.Format = bootstrapv1.Ignition
switchFromCloudInitToIgnition.Spec.KubeadmConfigSpec.Mounts = []bootstrapv1.MountPoints{
{"/var/lib/testdir", "/var/lib/etcd/data"},
}

tests := []struct {
name string
enableIgnitionFeature bool
Expand Down Expand Up @@ -914,6 +920,13 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) {
before: validIgnitionConfigurationBefore,
kcp: validIgnitionConfigurationAfter,
},
{
name: "should succeed when CloudInit was used before",
enableIgnitionFeature: true,
expectErr: false,
before: before,
kcp: switchFromCloudInitToIgnition,
},
}

for _, tt := range tests {
Expand Down

0 comments on commit 55421a1

Please sign in to comment.