Skip to content

Commit

Permalink
Fix cluster upgrading to default version always (#2414)
Browse files Browse the repository at this point in the history
  • Loading branch information
martina-if authored Jul 10, 2020
1 parent d03424d commit 0ed18ee
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
2 changes: 2 additions & 0 deletions pkg/ctl/update/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (

func updateClusterCmd(cmd *cmdutils.Cmd) {
cfg := api.NewClusterConfig()
// Reset version before loading
cfg.Metadata.Version = ""
cmd.ClusterConfig = cfg

cmd.SetDescription("cluster", "DEPRECATED: use 'upgrade cluster' instead. Upgrade control plane to the next version. ",
Expand Down
2 changes: 2 additions & 0 deletions pkg/ctl/upgrade/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ func upgradeCluster(cmd *cmdutils.Cmd) {

func upgradeClusterWithRunFunc(cmd *cmdutils.Cmd, runFunc func(cmd *cmdutils.Cmd) error) {
cfg := api.NewClusterConfig()
// Reset version
cfg.Metadata.Version = ""
cmd.ClusterConfig = cfg

cmd.SetDescription("cluster", "Upgrade control plane to the next version",
Expand Down
21 changes: 19 additions & 2 deletions pkg/ctl/upgrade/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,13 @@ var _ = Describe("upgrade cluster", func() {

cfg := cmd.Cmd.ClusterConfig
Expect(cfg.Metadata.Name).To(Equal("clus-1"))

// The version should be empty when not specified as a flag
Expect(cfg.Metadata.Version).To(Equal(""))

// I cannot test the region here because this flag is loaded into the cmd.ProviderConfig.Region
//Expect(cfg.Metadata.Region).To(Equal("us-west-2"))

Expect(cmd.Cmd.ProviderConfig.Region).To(Equal("us-west-2"))
Expect(cmd.Cmd.Plan).To(BeFalse())
Expect(cmd.Cmd.ProviderConfig.WaitTimeout).To(Equal(123 * time.Minute))
Expand Down Expand Up @@ -147,6 +152,18 @@ var _ = Describe("upgrade cluster", func() {
Expect(loadedCfg.Region).To(Equal("us-west-2"))
Expect(loadedCfg.Version).To(Equal("1.16"))
})

It("when not specified in the config file the version is empty", func() {
cfg.Metadata.Version = ""
configFile = CreateConfigFile(cfg)

cmd := newMockUpgradeClusterCmd("cluster", "--config-file", configFile)
_, err := cmd.Execute()
Expect(err).To(Not(HaveOccurred()))

loadedCfg := cmd.Cmd.ClusterConfig.Metadata
Expect(loadedCfg.Version).To(Equal(""))
})
})

type upgradeCase struct {
Expand Down Expand Up @@ -175,8 +192,8 @@ var _ = Describe("upgrade cluster", func() {

Entry("upgrades by default when the version is not specified", upgradeCase{
givenVersion: "",
eksVersion: "1.15",
expectedUpgradeVersion: "1.16",
eksVersion: "1.16",
expectedUpgradeVersion: "1.17",
expectedUpgrade: true,
}),

Expand Down

0 comments on commit 0ed18ee

Please sign in to comment.