@@ -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