Skip to content

Commit

Permalink
Merge pull request #203 from openshift-cherrypick-robot/cherry-pick-2…
Browse files Browse the repository at this point in the history
…02-to-18.0.0-proposed

[18.0.0-proposed] Give preference to PreprovisioningNetworkDataName
  • Loading branch information
openshift-merge-bot[bot] authored Aug 22, 2024
2 parents c8e3253 + 96fe7a3 commit bf1610d
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions pkg/openstackbaremetalset/baremetalhost.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,21 @@ func BaremetalHostProvision(

}

if networkDataSecret == nil {
//
// Provision the BaremetalHost
//
foundBaremetalHost := &metal3v1.BareMetalHost{}
err := helper.GetClient().Get(ctx, types.NamespacedName{Name: bmh, Namespace: instance.Spec.BmhNamespace}, foundBaremetalHost)
if err != nil {
return err
}

preProvNetworkData := foundBaremetalHost.Spec.PreprovisioningNetworkDataName
if preProvNetworkData == "" {
preProvNetworkData = instance.Spec.BaremetalHosts[hostName].PreprovisioningNetworkDataName
}

if networkDataSecret == nil && preProvNetworkData == "" {

// Check IP version and set template variables accordingly
ipAddr, ipNet, err := net.ParseCIDR(ctlPlaneIP)
Expand Down Expand Up @@ -181,15 +195,6 @@ func BaremetalHostProvision(
}
}

//
// Provision the BaremetalHost
//
foundBaremetalHost := &metal3v1.BareMetalHost{}
err := helper.GetClient().Get(ctx, types.NamespacedName{Name: bmh, Namespace: instance.Spec.BmhNamespace}, foundBaremetalHost)
if err != nil {
return err
}

op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), foundBaremetalHost, func() error {
// Set our ownership labels so we can watch this resource and also indicate that this BMH
// belongs to the particular OSBMS.Spec.BaremetalHosts entry we have passed to this function.
Expand All @@ -205,11 +210,7 @@ func BaremetalHostProvision(
// Ensure AutomatedCleaningMode is set as per spec
foundBaremetalHost.Spec.AutomatedCleaningMode = metal3v1.AutomatedCleaningMode(instance.Spec.AutomatedCleaningMode)

// Ensure PreprovisioningNetworkDataName is set as per spec
preprovNetworkData := instance.Spec.BaremetalHosts[hostName].PreprovisioningNetworkDataName
if preprovNetworkData != "" {
foundBaremetalHost.Spec.PreprovisioningNetworkDataName = preprovNetworkData
}
foundBaremetalHost.Spec.PreprovisioningNetworkDataName = preProvNetworkData

//
// Ensure the image url is up to date unless already provisioned
Expand Down

0 comments on commit bf1610d

Please sign in to comment.