Skip to content

Commit

Permalink
Merge pull request #290 from vr4manta/release-4.15-ocpbugs-32414
Browse files Browse the repository at this point in the history
[Release 4.15] OCPBUGS-32414: Fix ExportFailureDomain to handle empty platform spec
  • Loading branch information
openshift-merge-bot[bot] committed Apr 24, 2024
2 parents d3990c3 + f41abb5 commit d782a61
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ func (v VSphereProviderConfig) ExtractFailureDomain() machinev1.VSphereFailureDo
return machinev1.VSphereFailureDomain{}
}

// Older OCP installs will not have PlatformSpec set for infrastructure.
if v.infrastructure.Spec.PlatformSpec.VSphere == nil {
return machinev1.VSphereFailureDomain{}
}

failureDomains := v.infrastructure.Spec.PlatformSpec.VSphere.FailureDomains

for _, failureDomain := range failureDomains {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,16 @@ var _ = Describe("VSphere Provider Config", Label("vSphereProviderConfig"), func
Expect(newProviderSpec.VSphere().providerConfig.Network.Devices[0].Nameservers).To(BeNil())
})
})

Context("no vsphere platform spec in infrastructure", func() {
BeforeEach(func() {
providerConfig.infrastructure.Spec.PlatformSpec.VSphere = nil
})

It("should should return empty failure domain", func() {
expected := providerConfig.ExtractFailureDomain()

Expect(expected).To(Equal(v1.VSphereFailureDomain{}))
})
})
})
4 changes: 4 additions & 0 deletions test/e2e/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,10 @@ func convertVSphereProviderConfigToControlPlaneMachineSetProviderSpec(providerCo
vspherePs := providerConfig.VSphere().Config()
vspherePs.Name = ""

vspherePs.Workspace = &machinev1beta1.Workspace{}
vspherePs.Template = ""
vspherePs.Network = machinev1beta1.NetworkSpec{}

rawBytes, err := json.Marshal(vspherePs)
if err != nil {
return nil, fmt.Errorf("error marshalling vsphere providerSpec: %w", err)
Expand Down

0 comments on commit d782a61

Please sign in to comment.