Skip to content

Commit d245c43

Browse files
Merge pull request #1275 from wking/giant-hop-guard-vs-version-5
OTA-1786: pkg/payload/precondition/clusterversion/gianthop: Allow updates to 5.0
2 parents 76ea813 + d544606 commit d245c43

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

pkg/payload/precondition/clusterversion/gianthop.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,16 @@ func (p *GiantHop) Run(ctx context.Context, releaseContext precondition.ReleaseC
6666
}
6767

6868
if targetVersion.Major > currentVersion.Major {
69+
if targetVersion.Major == 5 && currentVersion.Major == 4 { // TODO: temporary access from v4 to 5.0, to be reverted once we are in v5 development
70+
if targetVersion.Minor == 0 {
71+
return nil
72+
}
73+
return &precondition.Error{
74+
Reason: "MajorVersionUpdate",
75+
Message: fmt.Sprintf("%s has a larger major version than the current target %s (%d > %d), and only updates within the current major version or to 5.0 are supported.", targetVersion, currentVersion, targetVersion.Major, currentVersion.Major),
76+
Name: p.Name(),
77+
}
78+
}
6979
return &precondition.Error{
7080
Reason: "MajorVersionUpdate",
7181
Message: fmt.Sprintf("%s has a larger major version than the current target %s (%d > %d), and only updates within the current major version are supported.", targetVersion, currentVersion, targetVersion.Major, currentVersion.Major),

pkg/payload/precondition/clusterversion/gianthop_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,38 @@ func TestGiantHopRun(t *testing.T) {
6464
},
6565
expected: "2.0.0 has a larger major version than the current target 1.0.0 (2 > 1), and only updates within the current major version are supported.",
6666
},
67+
{
68+
name: "major version is 5.0",
69+
clusterVersion: configv1.ClusterVersion{
70+
Spec: configv1.ClusterVersionSpec{
71+
DesiredUpdate: &configv1.Update{
72+
Version: "5.0.0",
73+
},
74+
},
75+
Status: configv1.ClusterVersionStatus{
76+
Desired: configv1.Release{
77+
Version: "4.0.0",
78+
},
79+
},
80+
},
81+
expected: "",
82+
},
83+
{
84+
name: "major version is 5.1",
85+
clusterVersion: configv1.ClusterVersion{
86+
Spec: configv1.ClusterVersionSpec{
87+
DesiredUpdate: &configv1.Update{
88+
Version: "5.1.0",
89+
},
90+
},
91+
Status: configv1.ClusterVersionStatus{
92+
Desired: configv1.Release{
93+
Version: "4.0.0",
94+
},
95+
},
96+
},
97+
expected: "5.1.0 has a larger major version than the current target 4.0.0 (5 > 4), and only updates within the current major version or to 5.0 are supported.",
98+
},
6799
{
68100
name: "two minor versions",
69101
clusterVersion: configv1.ClusterVersion{

0 commit comments

Comments
 (0)