Skip to content

Commit

Permalink
Fix default k8s snap channel
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
petrutlucian94 committed Dec 5, 2024
1 parent da28413 commit c59f679
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions pkg/cloudinit/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/cloudinit/controlplane_init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))))
Expand Down
2 changes: 1 addition & 1 deletion pkg/cloudinit/controlplane_join_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))))
Expand Down
2 changes: 1 addition & 1 deletion pkg/cloudinit/worker_join_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))))
Expand Down

0 comments on commit c59f679

Please sign in to comment.