Skip to content

Commit

Permalink
Merge pull request openstack-k8s-operators#949 from fao89/OSPRH-8645
Browse files Browse the repository at this point in the history
Fix runtime error when CtlplaneGateway is nil
  • Loading branch information
openshift-merge-bot[bot] authored Jul 18, 2024
2 parents 781aff9 + 4c03e92 commit 12fdef2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
6 changes: 3 additions & 3 deletions apis/dataplane/v1beta1/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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."
Expand Down
6 changes: 5 additions & 1 deletion pkg/dataplane/baremetal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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
}

Expand Down
9 changes: 6 additions & 3 deletions pkg/dataplane/ipam.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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() {
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 12fdef2

Please sign in to comment.