@@ -79,7 +79,7 @@ var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:VSphereHostVMGroupZonal
7979 })
8080
8181 It ("should enforce vm-host affinity rules between VM groups and host groups [apigroup:machine.openshift.io][Suite:openshift/conformance/parallel]" , func () {
82- failIfVMHostAffinityRulesAreNotEnforced (ctx , nodes , infra .Spec .PlatformSpec .VSphere , vsphereCreds )
82+ failIfVMHostAffinityRulesAreNotEnforced (ctx , infra .Spec .PlatformSpec .VSphere , vsphereCreds )
8383 })
8484
8585 It ("should respect zonal constraints during machine provisioning and scaling operations [apigroup:machine.openshift.io][Suite:openshift/conformance/parallel]" , func () {
@@ -257,6 +257,11 @@ func failIfMachineIsNotInCorrectVMGroup(ctx context.Context,
257257 Expect (err ).NotTo (HaveOccurred (), "expected to get vSphere clients from cluster credentials" )
258258
259259 for _ , fd := range platform .FailureDomains {
260+ if fd .ZoneAffinity == nil || fd .ZoneAffinity .HostGroup == nil {
261+ By (fmt .Sprintf ("skipping failure domain %s - no HostGroup ZoneAffinity configured" , fd .Name ))
262+ continue
263+ }
264+
260265 clusterVmGroups , err := getClusterVmGroups (ctx , vim25Client , fd .Topology .ComputeCluster )
261266 Expect (err ).NotTo (HaveOccurred (), "expected cluster vm groups to be available" )
262267
@@ -314,7 +319,6 @@ func failIfMachineIsNotInCorrectVMGroup(ctx context.Context,
314319}
315320
316321func failIfVMHostAffinityRulesAreNotEnforced (ctx context.Context ,
317- nodes * corev1.NodeList ,
318322 platform * configv1.VSpherePlatformSpec ,
319323 vsphereCreds * corev1.Secret ) {
320324
@@ -330,6 +334,11 @@ func failIfVMHostAffinityRulesAreNotEnforced(ctx context.Context,
330334 for _ , fd := range platform .FailureDomains {
331335 By (fmt .Sprintf ("checking VM-Host affinity rules for failure domain %s" , fd .Name ))
332336
337+ if fd .ZoneAffinity == nil || fd .ZoneAffinity .HostGroup == nil {
338+ By (fmt .Sprintf ("skipping failure domain %s - no HostGroup ZoneAffinity configured" , fd .Name ))
339+ continue
340+ }
341+
333342 // Get cluster configuration to check VM-Host rules
334343 finder := find .NewFinder (vim25Client , true )
335344 ccr , err := finder .ClusterComputeResource (ctx , fd .Topology .ComputeCluster )
@@ -341,16 +350,17 @@ func failIfVMHostAffinityRulesAreNotEnforced(ctx context.Context,
341350 // Verify VM-Host affinity rule exists and is properly configured
342351 var vmHostRule * types.ClusterVmHostRuleInfo
343352 for _ , rule := range clusterConfig .Rule {
344- if vmHostRule , ok := rule .(* types.ClusterVmHostRuleInfo ); ok {
345- if vmHostRule .Name == fd .ZoneAffinity .HostGroup .VMHostRule {
353+ if r , ok := rule .(* types.ClusterVmHostRuleInfo ); ok {
354+ if r .Name == fd .ZoneAffinity .HostGroup .VMHostRule {
355+ vmHostRule = r
346356 By (fmt .Sprintf ("found VM-Host rule %s for failure domain %s" , vmHostRule .Name , fd .Name ))
347357
348358 // Verify the rule references the correct VM and Host groups
349359 Expect (vmHostRule .VmGroupName ).To (Equal (fd .ZoneAffinity .HostGroup .VMGroup ),
350360 "VM-Host rule should reference the correct VM group" )
351361 Expect (vmHostRule .AffineHostGroupName ).To (Equal (fd .ZoneAffinity .HostGroup .HostGroup ),
352362 "VM-Host rule should reference the correct Host group" )
353- Expect (vmHostRule .Enabled ).To (BeTrue (),
363+ Expect (ptr . Deref ( vmHostRule .Enabled , false ) ).To (BeTrue (),
354364 "VM-Host affinity rule should be enabled" )
355365
356366 By (fmt .Sprintf ("verified VM-Host affinity rule %s is correctly configured" , vmHostRule .Name ))
@@ -391,6 +401,11 @@ func failIfMachineAPIViolatesZonalConstraints(ctx context.Context,
391401 for _ , fd := range platform .FailureDomains {
392402 By (fmt .Sprintf ("verifying machines in failure domain %s comply with zonal constraints" , fd .Name ))
393403
404+ if fd .ZoneAffinity == nil || fd .ZoneAffinity .HostGroup == nil {
405+ By (fmt .Sprintf ("skipping failure domain %s - no HostGroup ZoneAffinity configured" , fd .Name ))
406+ continue
407+ }
408+
394409 machinesInFd , err := getMachinesInFailureDomain (platform , fd , machineList )
395410 Expect (err ).NotTo (HaveOccurred (), "expected to get machines in failure domain" )
396411
0 commit comments