From 96fe7a38f7f4a5ef07d5ef4aaeb51f79bad486b0 Mon Sep 17 00:00:00 2001 From: rabi Date: Wed, 21 Aug 2024 08:59:42 +0530 Subject: [PATCH] Give preference to PreprovisioningNetworkDataName metal3 passes PreprovisioningNetworkDataName to the Config Drive during provisioning if not overridden by specifying NetworkData. Let's honor that and not overwrite with our own generated network data. Signed-off-by: rabi --- pkg/openstackbaremetalset/baremetalhost.go | 31 +++++++++++----------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/pkg/openstackbaremetalset/baremetalhost.go b/pkg/openstackbaremetalset/baremetalhost.go index 27f8ffe..9773c51 100644 --- a/pkg/openstackbaremetalset/baremetalhost.go +++ b/pkg/openstackbaremetalset/baremetalhost.go @@ -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) @@ -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. @@ -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