From 4c03e922540f98137d9d280787aa432d09fd4c0a Mon Sep 17 00:00:00 2001 From: Fabricio Aguiar Date: Thu, 18 Jul 2024 10:25:50 +0100 Subject: [PATCH] Fix runtime error when CtlplaneGateway is nil - provide more details on nodeset error statuses closes OSPRH-8645 Signed-off-by: Fabricio Aguiar --- apis/dataplane/v1beta1/conditions.go | 6 +++--- pkg/dataplane/baremetal.go | 6 +++++- pkg/dataplane/ipam.go | 9 ++++++--- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/apis/dataplane/v1beta1/conditions.go b/apis/dataplane/v1beta1/conditions.go index 89c0ffbad..e290c2b79 100644 --- a/apis/dataplane/v1beta1/conditions.go +++ b/apis/dataplane/v1beta1/conditions.go @@ -54,7 +54,7 @@ const ( NodeSetBaremetalProvisionReadyWaitingMessage = "NodeSetBaremetalProvisionReady not yet ready" // NodeSetBaremetalProvisionErrorMessage error - NodeSetBaremetalProvisionErrorMessage = "NodeSetBaremetalProvisionReady error occurred" + NodeSetBaremetalProvisionErrorMessage = "NodeSetBaremetalProvisionReady error occurred %s" // NodeSetIPReservationReadyCondition Status=True condition indicates // IPSets reserved for all nodes in a NodeSet. @@ -67,7 +67,7 @@ const ( NodeSetIPReservationReadyWaitingMessage = "NodeSetIPReservationReady not yet ready" // NodeSetIPReservationReadyErrorMessage error - NodeSetIPReservationReadyErrorMessage = "NodeSetIPReservationReady error occurred" + NodeSetIPReservationReadyErrorMessage = "NodeSetIPReservationReady error occurred %s" // NodeSetDNSDataReadyCondition Status=True condition indicates // DNSData created for the NodeSet. @@ -80,7 +80,7 @@ const ( NodeSetDNSDataReadyWaitingMessage = "NodeSetDNSDataReady not yet ready" // NodeSetDNSDataReadyErrorMessage error - NodeSetDNSDataReadyErrorMessage = "NodeSetDNSDataReady error occurred" + NodeSetDNSDataReadyErrorMessage = "NodeSetDNSDataReady error occurred %s" // NodeSetDNSDataMultipleDNSMasqErrorMessage error NodeSetDNSDataMultipleDNSMasqErrorMessage = "NodeSet DNSData error occurred. Multiple DNSMasq resources exist." diff --git a/pkg/dataplane/baremetal.go b/pkg/dataplane/baremetal.go index 87ce2a465..504bdf387 100644 --- a/pkg/dataplane/baremetal.go +++ b/pkg/dataplane/baremetal.go @@ -71,6 +71,9 @@ func DeployBaremetalSet( } ipPrefix, _ := ipNet.Mask.Size() instanceSpec.CtlPlaneIP = fmt.Sprintf("%s/%d", res.Address, ipPrefix) + if res.Gateway == nil { + return fmt.Errorf("%s gateway is missing", CtlPlaneNetwork) + } baremetalSet.Spec.CtlplaneGateway = *res.Gateway baremetalSet.Spec.BootstrapDNS = dnsAddresses baremetalSet.Spec.DNSSearchDomains = []string{res.DNSDomain} @@ -89,7 +92,8 @@ func DeployBaremetalSet( instance.Status.Conditions.MarkFalse( dataplanev1.NodeSetBareMetalProvisionReadyCondition, condition.ErrorReason, condition.SeverityError, - dataplanev1.NodeSetBaremetalProvisionErrorMessage) + dataplanev1.NodeSetBaremetalProvisionErrorMessage, + err.Error()) return false, err } diff --git a/pkg/dataplane/ipam.go b/pkg/dataplane/ipam.go index 1428118f1..f4493f67a 100644 --- a/pkg/dataplane/ipam.go +++ b/pkg/dataplane/ipam.go @@ -198,7 +198,8 @@ func EnsureDNSData(ctx context.Context, helper *helper.Helper, instance.Status.Conditions.MarkFalse( dataplanev1.NodeSetDNSDataReadyCondition, condition.ErrorReason, condition.SeverityError, - dataplanev1.NodeSetDNSDataReadyErrorMessage) + dataplanev1.NodeSetDNSDataReadyErrorMessage, + err.Error()) return dnsDetails, err } @@ -214,7 +215,8 @@ func EnsureDNSData(ctx context.Context, helper *helper.Helper, instance.Status.Conditions.MarkFalse( dataplanev1.NodeSetDNSDataReadyCondition, condition.ErrorReason, condition.SeverityError, - dataplanev1.NodeSetDNSDataReadyErrorMessage) + dataplanev1.NodeSetDNSDataReadyErrorMessage, + err.Error()) return dnsDetails, err } if !dnsData.IsReady() { @@ -242,7 +244,8 @@ func EnsureIPSets(ctx context.Context, helper *helper.Helper, instance.Status.Conditions.MarkFalse( dataplanev1.NodeSetIPReservationReadyCondition, condition.ErrorReason, condition.SeverityError, - dataplanev1.NodeSetIPReservationReadyErrorMessage) + dataplanev1.NodeSetIPReservationReadyErrorMessage, + err.Error()) return nil, false, err }