@@ -393,6 +393,16 @@ func (webhook *Cluster) validateTopology(ctx context.Context, oldCluster, newClu
393
393
394
394
// If the ClusterClass referenced in the Topology has changed compatibility checks are needed.
395
395
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
+
396
406
// Check to see if the ClusterClass referenced in the old version of the Cluster exists.
397
407
oldClusterClass , err := webhook .pollClusterClassForCluster (ctx , oldCluster )
398
408
if err != nil {
@@ -402,7 +412,7 @@ func (webhook *Cluster) validateTopology(ctx context.Context, oldCluster, newClu
402
412
fmt .Sprintf ("valid ClusterClass with name %q could not be retrieved, change from class %[1]q to class %q cannot be validated. Error: %s" ,
403
413
oldCluster .GetClassKey (), newCluster .GetClassKey (), err .Error ())))
404
414
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.
406
416
return allWarnings , allErrs
407
417
}
408
418
0 commit comments