From c59f679118ed0ee2e57f2c7df9d8c29cd40dc477 Mon Sep 17 00:00:00 2001 From: Lucian Petrut Date: Wed, 4 Dec 2024 14:36:18 +0000 Subject: [PATCH 1/2] Fix default k8s snap channel This commit ensures that the "-classic/edge" channel is used if no snap channel, revision or path is provided. We cannot use "stable" since we don't have a stable channel yet. --- pkg/cloudinit/common.go | 5 +++-- pkg/cloudinit/controlplane_init_test.go | 2 +- pkg/cloudinit/controlplane_join_test.go | 2 +- pkg/cloudinit/worker_join_test.go | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/cloudinit/common.go b/pkg/cloudinit/common.go index bd3320b8..e1e22ce0 100644 --- a/pkg/cloudinit/common.go +++ b/pkg/cloudinit/common.go @@ -73,10 +73,11 @@ func NewBaseCloudConfig(data BaseUserData) (CloudConfig, error) { snapInstall := data.SnapInstallData // Default to k8s version if snap install option is not set or empty. - if snapInstall == nil { + if snapInstall == nil || snapInstall.Option == "" { + // TODO: consider using "stable" once we'll have a stable channel. snapInstall = &SnapInstallData{ Option: InstallOptionChannel, - Value: fmt.Sprintf("%d.%d-classic/stable", kubernetesVersion.Major(), kubernetesVersion.Minor()), + Value: fmt.Sprintf("%d.%d-classic/edge", kubernetesVersion.Major(), kubernetesVersion.Minor()), } } diff --git a/pkg/cloudinit/controlplane_init_test.go b/pkg/cloudinit/controlplane_init_test.go index 676fe9ae..d46b66a3 100644 --- a/pkg/cloudinit/controlplane_init_test.go +++ b/pkg/cloudinit/controlplane_init_test.go @@ -246,7 +246,7 @@ func TestNewInitControlPlaneSnapInstall(t *testing.T) { g.Expect(err).NotTo(HaveOccurred()) g.Expect(config.WriteFiles).To(ContainElement(gstruct.MatchFields(gstruct.IgnoreExtras, gstruct.Fields{ "Path": Equal(fmt.Sprintf("/capi/etc/snap-%s", cloudinit.InstallOptionChannel)), - "Content": Equal("1.30-classic/stable"), + "Content": Equal("1.30-classic/edge"), }))) g.Expect(config.WriteFiles).ToNot(ContainElement(HaveField("Path", fmt.Sprintf("/capi/etc/snap-%s", cloudinit.InstallOptionRevision)))) g.Expect(config.WriteFiles).ToNot(ContainElement(HaveField("Path", fmt.Sprintf("/capi/etc/snap-%s", cloudinit.InstallOptionLocalPath)))) diff --git a/pkg/cloudinit/controlplane_join_test.go b/pkg/cloudinit/controlplane_join_test.go index 57eca5c5..cd4afb72 100644 --- a/pkg/cloudinit/controlplane_join_test.go +++ b/pkg/cloudinit/controlplane_join_test.go @@ -202,7 +202,7 @@ func TestNewJoinControlPlaneSnapInstall(t *testing.T) { g.Expect(err).NotTo(HaveOccurred()) g.Expect(config.WriteFiles).To(ContainElement(gstruct.MatchFields(gstruct.IgnoreExtras, gstruct.Fields{ "Path": Equal(fmt.Sprintf("/capi/etc/snap-%s", cloudinit.InstallOptionChannel)), - "Content": Equal("1.30-classic/stable"), + "Content": Equal("1.30-classic/edge"), }))) g.Expect(config.WriteFiles).ToNot(ContainElement(HaveField("Path", fmt.Sprintf("/capi/etc/snap-%s", cloudinit.InstallOptionRevision)))) g.Expect(config.WriteFiles).ToNot(ContainElement(HaveField("Path", fmt.Sprintf("/capi/etc/snap-%s", cloudinit.InstallOptionLocalPath)))) diff --git a/pkg/cloudinit/worker_join_test.go b/pkg/cloudinit/worker_join_test.go index 3fbd06f6..5667997e 100644 --- a/pkg/cloudinit/worker_join_test.go +++ b/pkg/cloudinit/worker_join_test.go @@ -203,7 +203,7 @@ func TestNewJoinWorkerSnapInstall(t *testing.T) { g.Expect(err).NotTo(HaveOccurred()) g.Expect(config.WriteFiles).To(ContainElement(gstruct.MatchFields(gstruct.IgnoreExtras, gstruct.Fields{ "Path": Equal(fmt.Sprintf("/capi/etc/snap-%s", cloudinit.InstallOptionChannel)), - "Content": Equal("1.30-classic/stable"), + "Content": Equal("1.30-classic/edge"), }))) g.Expect(config.WriteFiles).ToNot(ContainElement(HaveField("Path", fmt.Sprintf("/capi/etc/snap-%s", cloudinit.InstallOptionRevision)))) g.Expect(config.WriteFiles).ToNot(ContainElement(HaveField("Path", fmt.Sprintf("/capi/etc/snap-%s", cloudinit.InstallOptionLocalPath)))) From a992450ef68ea78fa56d274ec562aab64a3284ed Mon Sep 17 00:00:00 2001 From: Lucian Petrut Date: Thu, 5 Dec 2024 13:48:17 +0000 Subject: [PATCH 2/2] Switch back to "stable" by default A stable release of k8s-snap is expected to come out soon, so we'll stick to using "stable" by default instead of "edge". --- pkg/cloudinit/common.go | 3 +-- pkg/cloudinit/controlplane_init_test.go | 2 +- pkg/cloudinit/controlplane_join_test.go | 2 +- pkg/cloudinit/worker_join_test.go | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/pkg/cloudinit/common.go b/pkg/cloudinit/common.go index e1e22ce0..88d0e108 100644 --- a/pkg/cloudinit/common.go +++ b/pkg/cloudinit/common.go @@ -74,10 +74,9 @@ func NewBaseCloudConfig(data BaseUserData) (CloudConfig, error) { snapInstall := data.SnapInstallData // Default to k8s version if snap install option is not set or empty. if snapInstall == nil || snapInstall.Option == "" { - // TODO: consider using "stable" once we'll have a stable channel. snapInstall = &SnapInstallData{ Option: InstallOptionChannel, - Value: fmt.Sprintf("%d.%d-classic/edge", kubernetesVersion.Major(), kubernetesVersion.Minor()), + Value: fmt.Sprintf("%d.%d-classic/stable", kubernetesVersion.Major(), kubernetesVersion.Minor()), } } diff --git a/pkg/cloudinit/controlplane_init_test.go b/pkg/cloudinit/controlplane_init_test.go index d46b66a3..676fe9ae 100644 --- a/pkg/cloudinit/controlplane_init_test.go +++ b/pkg/cloudinit/controlplane_init_test.go @@ -246,7 +246,7 @@ func TestNewInitControlPlaneSnapInstall(t *testing.T) { g.Expect(err).NotTo(HaveOccurred()) g.Expect(config.WriteFiles).To(ContainElement(gstruct.MatchFields(gstruct.IgnoreExtras, gstruct.Fields{ "Path": Equal(fmt.Sprintf("/capi/etc/snap-%s", cloudinit.InstallOptionChannel)), - "Content": Equal("1.30-classic/edge"), + "Content": Equal("1.30-classic/stable"), }))) g.Expect(config.WriteFiles).ToNot(ContainElement(HaveField("Path", fmt.Sprintf("/capi/etc/snap-%s", cloudinit.InstallOptionRevision)))) g.Expect(config.WriteFiles).ToNot(ContainElement(HaveField("Path", fmt.Sprintf("/capi/etc/snap-%s", cloudinit.InstallOptionLocalPath)))) diff --git a/pkg/cloudinit/controlplane_join_test.go b/pkg/cloudinit/controlplane_join_test.go index cd4afb72..57eca5c5 100644 --- a/pkg/cloudinit/controlplane_join_test.go +++ b/pkg/cloudinit/controlplane_join_test.go @@ -202,7 +202,7 @@ func TestNewJoinControlPlaneSnapInstall(t *testing.T) { g.Expect(err).NotTo(HaveOccurred()) g.Expect(config.WriteFiles).To(ContainElement(gstruct.MatchFields(gstruct.IgnoreExtras, gstruct.Fields{ "Path": Equal(fmt.Sprintf("/capi/etc/snap-%s", cloudinit.InstallOptionChannel)), - "Content": Equal("1.30-classic/edge"), + "Content": Equal("1.30-classic/stable"), }))) g.Expect(config.WriteFiles).ToNot(ContainElement(HaveField("Path", fmt.Sprintf("/capi/etc/snap-%s", cloudinit.InstallOptionRevision)))) g.Expect(config.WriteFiles).ToNot(ContainElement(HaveField("Path", fmt.Sprintf("/capi/etc/snap-%s", cloudinit.InstallOptionLocalPath)))) diff --git a/pkg/cloudinit/worker_join_test.go b/pkg/cloudinit/worker_join_test.go index 5667997e..3fbd06f6 100644 --- a/pkg/cloudinit/worker_join_test.go +++ b/pkg/cloudinit/worker_join_test.go @@ -203,7 +203,7 @@ func TestNewJoinWorkerSnapInstall(t *testing.T) { g.Expect(err).NotTo(HaveOccurred()) g.Expect(config.WriteFiles).To(ContainElement(gstruct.MatchFields(gstruct.IgnoreExtras, gstruct.Fields{ "Path": Equal(fmt.Sprintf("/capi/etc/snap-%s", cloudinit.InstallOptionChannel)), - "Content": Equal("1.30-classic/edge"), + "Content": Equal("1.30-classic/stable"), }))) g.Expect(config.WriteFiles).ToNot(ContainElement(HaveField("Path", fmt.Sprintf("/capi/etc/snap-%s", cloudinit.InstallOptionRevision)))) g.Expect(config.WriteFiles).ToNot(ContainElement(HaveField("Path", fmt.Sprintf("/capi/etc/snap-%s", cloudinit.InstallOptionLocalPath))))