From 5f33462dae41e90603bb3062c3c6d7faebfb77b4 Mon Sep 17 00:00:00 2001 From: rabi Date: Tue, 6 Aug 2024 18:16:37 +0530 Subject: [PATCH] Allow users to override baremetal provisioning images Jira: https://issues.redhat.com/browse/OSPRH-9093 Signed-off-by: rabi --- .../openstackdataplanenodeset_controller.go | 12 +----------- pkg/dataplane/baremetal.go | 13 +++++++++++++ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/controllers/dataplane/openstackdataplanenodeset_controller.go b/controllers/dataplane/openstackdataplanenodeset_controller.go index 8b6d1670a..fc0677bbe 100644 --- a/controllers/dataplane/openstackdataplanenodeset_controller.go +++ b/controllers/dataplane/openstackdataplanenodeset_controller.go @@ -368,18 +368,8 @@ func (r *OpenStackDataPlaneNodeSetReconciler) Reconcile(ctx context.Context, req instance.Status.Conditions.MarkUnknown(dataplanev1.NodeSetBareMetalProvisionReadyCondition, condition.InitReason, condition.InitReason) - // Set Images - if containerImages.OsContainerImage != nil { - instance.Spec.BaremetalSetTemplate.OSContainerImageURL = *containerImages.OsContainerImage - } - if containerImages.AgentImage != nil { - instance.Spec.BaremetalSetTemplate.AgentImageURL = *containerImages.AgentImage - } - if containerImages.ApacheImage != nil { - instance.Spec.BaremetalSetTemplate.ApacheImageURL = *containerImages.ApacheImage - } isReady, err := deployment.DeployBaremetalSet(ctx, helper, instance, - allIPSets, dnsDetails.ServerAddresses) + allIPSets, dnsDetails.ServerAddresses, containerImages) if err != nil || !isReady { return ctrl.Result{}, err } diff --git a/pkg/dataplane/baremetal.go b/pkg/dataplane/baremetal.go index 504bdf387..a91d5d47b 100644 --- a/pkg/dataplane/baremetal.go +++ b/pkg/dataplane/baremetal.go @@ -30,6 +30,7 @@ import ( "github.com/openstack-k8s-operators/lib-common/modules/common/helper" utils "github.com/openstack-k8s-operators/lib-common/modules/common/util" baremetalv1 "github.com/openstack-k8s-operators/openstack-baremetal-operator/api/v1beta1" + openstackv1 "github.com/openstack-k8s-operators/openstack-operator/apis/core/v1beta1" dataplanev1 "github.com/openstack-k8s-operators/openstack-operator/apis/dataplane/v1beta1" ) @@ -38,6 +39,7 @@ func DeployBaremetalSet( ctx context.Context, helper *helper.Helper, instance *dataplanev1.OpenStackDataPlaneNodeSet, ipSets map[string]infranetworkv1.IPSet, dnsAddresses []string, + containerImages openstackv1.ContainerImages, ) (bool, error) { baremetalSet := &baremetalv1.OpenStackBaremetalSet{ ObjectMeta: metav1.ObjectMeta{ @@ -52,6 +54,17 @@ func DeployBaremetalSet( utils.LogForObject(helper, "Reconciling BaremetalSet", instance) _, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), baremetalSet, func() error { instance.Spec.BaremetalSetTemplate.DeepCopyInto(&baremetalSet.Spec) + // Set Images + if containerImages.OsContainerImage != nil && instance.Spec.BaremetalSetTemplate.OSContainerImageURL == "" { + baremetalSet.Spec.OSContainerImageURL = *containerImages.OsContainerImage + } + if containerImages.AgentImage != nil && instance.Spec.BaremetalSetTemplate.AgentImageURL == "" { + baremetalSet.Spec.AgentImageURL = *containerImages.AgentImage + } + if containerImages.ApacheImage != nil && instance.Spec.BaremetalSetTemplate.ApacheImageURL == "" { + baremetalSet.Spec.ApacheImageURL = *containerImages.ApacheImage + } + for _, node := range instance.Spec.Nodes { hostName := node.HostName ipSet, ok := ipSets[hostName]