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

[release-1.3] 🐛 enable updates from CloudInit (mostly ubuntu) based KCPs to Ignition (flatcar) based KCPs #8350

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ func (in *KubeadmControlPlane) ValidateUpdate(old runtime.Object) error {
{spec, kubeadmConfigSpec, ignition, "*"},
{spec, kubeadmConfigSpec, diskSetup},
{spec, kubeadmConfigSpec, diskSetup, "*"},
{spec, kubeadmConfigSpec, "format"},
{spec, kubeadmConfigSpec, "mounts"},
{spec, "machineTemplate", "metadata"},
{spec, "machineTemplate", "metadata", "*"},
{spec, "machineTemplate", "infrastructureRef", "apiVersion"},
Expand All @@ -195,12 +197,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 @@ -658,6 +658,12 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) {
},
}

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 @@ -996,6 +1002,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