@@ -640,7 +640,7 @@ func validateMachineHealthChecks(cluster *clusterv1.Cluster, clusterClass *clust
640
640
fldPath := field .NewPath ("spec" , "topology" , "controlPlane" , "machineHealthCheck" )
641
641
642
642
// Validate ControlPlane MachineHealthCheck if defined.
643
- if ! cluster .Spec .Topology .ControlPlane .HealthCheck .IsDefined () {
643
+ if cluster .Spec .Topology .ControlPlane .HealthCheck .IsDefined () {
644
644
// Ensure ControlPlane does not define a MachineHealthCheck if the ClusterClass does not define MachineInfrastructure.
645
645
if clusterClass .Spec .ControlPlane .MachineInfrastructure == nil {
646
646
allErrs = append (allErrs , field .Forbidden (
@@ -659,7 +659,7 @@ func validateMachineHealthChecks(cluster *clusterv1.Cluster, clusterClass *clust
659
659
// Check if the machineHealthCheck is explicitly enabled in the ControlPlaneTopology.
660
660
if cluster .Spec .Topology .ControlPlane .HealthCheck .Enabled != nil && * cluster .Spec .Topology .ControlPlane .HealthCheck .Enabled {
661
661
// Ensure the MHC is defined in at least one of the ControlPlaneTopology of the Cluster or the ControlPlaneClass of the ClusterClass.
662
- if cluster .Spec .Topology .ControlPlane .HealthCheck .IsDefined () && clusterClass .Spec .ControlPlane .HealthCheck == nil {
662
+ if ! cluster .Spec .Topology .ControlPlane .HealthCheck .IsDefined () && clusterClass .Spec .ControlPlane .HealthCheck == nil {
663
663
allErrs = append (allErrs , field .Forbidden (
664
664
fldPath .Child ("enable" ),
665
665
fmt .Sprintf ("cannot be set to %t as MachineHealthCheck definition is not available in the Cluster topology or the ClusterClass" , * cluster .Spec .Topology .ControlPlane .HealthCheck .Enabled ),
@@ -674,7 +674,7 @@ func validateMachineHealthChecks(cluster *clusterv1.Cluster, clusterClass *clust
674
674
fldPath := field .NewPath ("spec" , "topology" , "workers" , "machineDeployments" ).Key (md .Name ).Child ("machineHealthCheck" )
675
675
676
676
// Validate the MachineDeployment MachineHealthCheck if defined.
677
- if ! md .HealthCheck .IsDefined () {
677
+ if md .HealthCheck .IsDefined () {
678
678
allErrs = append (allErrs , validateMachineHealthCheckNodeStartupTimeoutSeconds (fldPath , md .HealthCheck .Checks .NodeStartupTimeoutSeconds )... )
679
679
allErrs = append (allErrs , validateMachineHealthCheckUnhealthyLessThanOrEqualTo (fldPath , md .HealthCheck .Remediation .TriggerIf .UnhealthyLessThanOrEqualTo )... )
680
680
}
@@ -687,7 +687,7 @@ func validateMachineHealthChecks(cluster *clusterv1.Cluster, clusterClass *clust
687
687
// Check if the machineHealthCheck is explicitly enabled in the machineDeploymentTopology.
688
688
if md .HealthCheck .Enabled != nil && * md .HealthCheck .Enabled {
689
689
// Ensure the MHC is defined in at least one of the MachineDeploymentTopology of the Cluster or the MachineDeploymentClass of the ClusterClass.
690
- if md .HealthCheck .IsDefined () && mdClass .HealthCheck == nil {
690
+ if ! md .HealthCheck .IsDefined () && mdClass .HealthCheck == nil {
691
691
allErrs = append (allErrs , field .Forbidden (
692
692
fldPath .Child ("enable" ),
693
693
fmt .Sprintf ("cannot be set to %t as MachineHealthCheck definition is not available in the Cluster topology or the ClusterClass" , * md .HealthCheck .Enabled ),
0 commit comments