Skip to content

Commit f49e500

Browse files
Address comments
1 parent ff7df7b commit f49e500

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

exp/topology/scope/hookresponsetracker_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ func TestHookResponseTracker_IsBlocking(t *testing.T) {
164164
},
165165
}
166166

167-
afterClusterUpgradeResponse := &runtimehooksv1.AfterControlPlaneInitializedResponse{
167+
afterAfterControlPlaneInitializedResponse := &runtimehooksv1.AfterControlPlaneInitializedResponse{
168168
CommonResponse: runtimehooksv1.CommonResponse{},
169169
}
170170

@@ -195,8 +195,8 @@ func TestHookResponseTracker_IsBlocking(t *testing.T) {
195195
t.Run("should return false if the hook is non-blocking", func(t *testing.T) {
196196
g := NewWithT(t)
197197
hrt := NewHookResponseTracker()
198-
// AfterClusterUpgradeHook is non-blocking.
199-
hrt.Add(runtimehooksv1.AfterClusterUpgrade, afterClusterUpgradeResponse)
200-
g.Expect(hrt.IsBlocking(runtimehooksv1.AfterClusterUpgrade)).To(BeFalse())
198+
// AfterControlPlaneInitialized is non-blocking.
199+
hrt.Add(runtimehooksv1.AfterControlPlaneInitialized, afterAfterControlPlaneInitializedResponse)
200+
g.Expect(hrt.IsBlocking(runtimehooksv1.AfterControlPlaneInitialized)).To(BeFalse())
201201
})
202202
}

internal/webhooks/cluster.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -440,15 +440,6 @@ func (webhook *Cluster) validateTopologyVersionUpdate(ctx context.Context, fldPa
440440
return nil
441441
}
442442

443-
// Cannot upgrade when lifecycle hooks are still being completed for the previous upgrade.
444-
if IsPending(runtimehooksv1.AfterClusterUpgrade, newCluster) {
445-
return field.Invalid(
446-
fldPath,
447-
fldValue,
448-
fmt.Sprintf("version cannot be change when the %q hook is still blocking", runtimecatalog.HookName(runtimehooksv1.AfterClusterUpgrade)),
449-
)
450-
}
451-
452443
// Version could only be increased.
453444
if inVersion.NE(semver.Version{}) && oldVersion.NE(semver.Version{}) && version.Compare(inVersion, oldVersion, version.WithoutPreReleases()) < 0 {
454445
return field.Invalid(
@@ -474,6 +465,15 @@ func (webhook *Cluster) validateTopologyVersionUpdate(ctx context.Context, fldPa
474465
}
475466
}
476467

468+
// Cannot upgrade when lifecycle hooks are still being completed for the previous upgrade.
469+
if IsPending(runtimehooksv1.AfterClusterUpgrade, newCluster) {
470+
return field.Invalid(
471+
fldPath,
472+
fldValue,
473+
fmt.Sprintf("version cannot be changed when the %q hook is still blocking", runtimecatalog.HookName(runtimehooksv1.AfterClusterUpgrade)),
474+
)
475+
}
476+
477477
allErrs := []error{}
478478
// minor version cannot be increased if control plane is upgrading or not yet on the current version
479479
if err := validateTopologyControlPlaneVersion(ctx, webhook.Client, oldCluster, oldVersion); err != nil {

0 commit comments

Comments
 (0)