Skip to content

Commit 6ee1a00

Browse files
authored
Merge pull request #12415 from sbueringer/pr-improve-cc-rebase-err
🌱 Improve error message if rebase fails because target ClusterClass is not reconciled
2 parents 536647d + 5cf9f66 commit 6ee1a00

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

internal/webhooks/cluster.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,16 @@ func (webhook *Cluster) validateTopology(ctx context.Context, oldCluster, newClu
393393

394394
// If the ClusterClass referenced in the Topology has changed compatibility checks are needed.
395395
if oldCluster.GetClassKey() != newCluster.GetClassKey() {
396+
if clusterClassPollErr != nil {
397+
allErrs = append(
398+
allErrs, field.Forbidden(
399+
fldPath.Child("class"),
400+
fmt.Sprintf("cannot rebase to ClusterClass %q: %s",
401+
newCluster.GetClassKey(), clusterClassPollErr.Error())))
402+
// Return early with errors if the new ClusterClass can't be retrieved.
403+
return allWarnings, allErrs
404+
}
405+
396406
// Check to see if the ClusterClass referenced in the old version of the Cluster exists.
397407
oldClusterClass, err := webhook.pollClusterClassForCluster(ctx, oldCluster)
398408
if err != nil {
@@ -402,7 +412,7 @@ func (webhook *Cluster) validateTopology(ctx context.Context, oldCluster, newClu
402412
fmt.Sprintf("valid ClusterClass with name %q could not be retrieved, change from class %[1]q to class %q cannot be validated. Error: %s",
403413
oldCluster.GetClassKey(), newCluster.GetClassKey(), err.Error())))
404414

405-
// Return early with errors if the ClusterClass can't be retrieved.
415+
// Return early with errors if the old ClusterClass can't be retrieved.
406416
return allWarnings, allErrs
407417
}
408418

0 commit comments

Comments
 (0)