@@ -38,27 +38,30 @@ func ReconcileOVN(ctx context.Context, instance *corev1beta1.OpenStackControlPla
3838 }
3939
4040 // Create TLS certificate for OVN metrics services when TLS is enabled
41+ var ovnMetricsCertName string
4142 if instance .Spec .Ovn .Enabled && instance .Spec .TLS .PodLevel .Enabled {
42- if err := EnsureOVNMetricsCert (ctx , instance , helper ); err != nil {
43+ var err error
44+ ovnMetricsCertName , err = EnsureOVNMetricsCert (ctx , instance , helper )
45+ if err != nil {
4346 Log .Error (err , "Failed to ensure OVN metrics certificate" )
4447 setOVNReadyError (instance , err )
4548 return ctrl.Result {}, err
4649 }
4750 }
4851
49- OVNDBClustersReady , OVNDBClustersConditions , err := ReconcileOVNDbClusters (ctx , instance , version , helper )
52+ OVNDBClustersReady , OVNDBClustersConditions , err := ReconcileOVNDbClusters (ctx , instance , version , helper , ovnMetricsCertName )
5053 if err != nil {
5154 Log .Error (err , "Failed to reconcile OVNDBClusters" )
5255 setOVNReadyError (instance , err )
5356 }
5457
55- OVNNorthdReady , OVNNorthdConditions , err := ReconcileOVNNorthd (ctx , instance , version , helper )
58+ OVNNorthdReady , OVNNorthdConditions , err := ReconcileOVNNorthd (ctx , instance , version , helper , ovnMetricsCertName )
5659 if err != nil {
5760 Log .Error (err , "Failed to reconcile OVNNorthd" )
5861 setOVNReadyError (instance , err )
5962 }
6063
61- OVNControllerReady , OVNControllerConditions , err := ReconcileOVNController (ctx , instance , version , helper )
64+ OVNControllerReady , OVNControllerConditions , err := ReconcileOVNController (ctx , instance , version , helper , ovnMetricsCertName )
6265 if err != nil {
6366 Log .Error (err , "Failed to reconcile OVNController" )
6467 setOVNReadyError (instance , err )
@@ -120,7 +123,7 @@ func ReconcileOVN(ctx context.Context, instance *corev1beta1.OpenStackControlPla
120123}
121124
122125// ReconcileOVNDbClusters reconciles the OVN database clusters for the OpenStack control plane
123- func ReconcileOVNDbClusters (ctx context.Context , instance * corev1beta1.OpenStackControlPlane , version * corev1beta1.OpenStackVersion , helper * helper.Helper ) (bool , condition.Conditions , error ) {
126+ func ReconcileOVNDbClusters (ctx context.Context , instance * corev1beta1.OpenStackControlPlane , version * corev1beta1.OpenStackVersion , helper * helper.Helper , ovnMetricsCertName string ) (bool , condition.Conditions , error ) {
124127 Log := GetLogger (ctx )
125128 dnsSuffix := clusterdns .GetDNSClusterDomain ()
126129 conditions := condition.Conditions {}
@@ -199,6 +202,12 @@ func ReconcileOVNDbClusters(ctx context.Context, instance *corev1beta1.OpenStack
199202 dbcluster .TLS .SecretName = & certSecret .Name
200203 }
201204
205+ // Set MetricsTLS configuration if TLS is enabled and metrics cert is available
206+ if instance .Spec .TLS .PodLevel .Enabled && ovnMetricsCertName != "" {
207+ dbcluster .MetricsTLS .SecretName = & ovnMetricsCertName
208+ dbcluster .MetricsTLS .CaBundleSecretName = instance .Status .TLS .CaBundleSecretName
209+ }
210+
202211 if dbcluster .NodeSelector == nil {
203212 dbcluster .NodeSelector = & instance .Spec .NodeSelector
204213 }
@@ -259,7 +268,7 @@ func ReconcileOVNDbClusters(ctx context.Context, instance *corev1beta1.OpenStack
259268}
260269
261270// ReconcileOVNNorthd reconciles the OVN Northd service for the OpenStack control plane
262- func ReconcileOVNNorthd (ctx context.Context , instance * corev1beta1.OpenStackControlPlane , version * corev1beta1.OpenStackVersion , helper * helper.Helper ) (bool , condition.Conditions , error ) {
271+ func ReconcileOVNNorthd (ctx context.Context , instance * corev1beta1.OpenStackControlPlane , version * corev1beta1.OpenStackVersion , helper * helper.Helper , ovnMetricsCertName string ) (bool , condition.Conditions , error ) {
263272 Log := GetLogger (ctx )
264273 conditions := condition.Conditions {}
265274
@@ -334,6 +343,12 @@ func ReconcileOVNNorthd(ctx context.Context, instance *corev1beta1.OpenStackCont
334343 }
335344 ovnNorthdSpec .TLS .CaBundleSecretName = instance .Status .TLS .CaBundleSecretName
336345
346+ // Set MetricsTLS configuration if TLS is enabled and metrics cert is available
347+ if instance .Spec .TLS .PodLevel .Enabled && ovnMetricsCertName != "" {
348+ ovnNorthdSpec .MetricsTLS .SecretName = & ovnMetricsCertName
349+ ovnNorthdSpec .MetricsTLS .CaBundleSecretName = instance .Status .TLS .CaBundleSecretName
350+ }
351+
337352 if ovnNorthdSpec .NodeSelector == nil {
338353 ovnNorthdSpec .NodeSelector = & instance .Spec .NodeSelector
339354 }
@@ -386,7 +401,7 @@ func ReconcileOVNNorthd(ctx context.Context, instance *corev1beta1.OpenStackCont
386401}
387402
388403// ReconcileOVNController reconciles the OVN Controller service for the OpenStack control plane
389- func ReconcileOVNController (ctx context.Context , instance * corev1beta1.OpenStackControlPlane , version * corev1beta1.OpenStackVersion , helper * helper.Helper ) (bool , condition.Conditions , error ) {
404+ func ReconcileOVNController (ctx context.Context , instance * corev1beta1.OpenStackControlPlane , version * corev1beta1.OpenStackVersion , helper * helper.Helper , ovnMetricsCertName string ) (bool , condition.Conditions , error ) {
390405 Log := GetLogger (ctx )
391406 conditions := condition.Conditions {}
392407
@@ -473,6 +488,12 @@ func ReconcileOVNController(ctx context.Context, instance *corev1beta1.OpenStack
473488 }
474489 ovnControllerSpec .TLS .CaBundleSecretName = instance .Status .TLS .CaBundleSecretName
475490
491+ // Set MetricsTLS configuration if TLS is enabled and metrics cert is available
492+ if instance .Spec .TLS .PodLevel .Enabled && ovnMetricsCertName != "" {
493+ ovnControllerSpec .MetricsTLS .SecretName = & ovnMetricsCertName
494+ ovnControllerSpec .MetricsTLS .CaBundleSecretName = instance .Status .TLS .CaBundleSecretName
495+ }
496+
476497 if ovnControllerSpec .NodeSelector == nil {
477498 ovnControllerSpec .NodeSelector = & instance .Spec .NodeSelector
478499 }
@@ -568,7 +589,7 @@ func OVNNorthImageMatch(ctx context.Context, controlPlane *corev1beta1.OpenStack
568589}
569590
570591// EnsureOVNMetricsCert creates TLS certificate for OVN metrics services
571- func EnsureOVNMetricsCert (ctx context.Context , instance * corev1beta1.OpenStackControlPlane , helper * helper.Helper ) error {
592+ func EnsureOVNMetricsCert (ctx context.Context , instance * corev1beta1.OpenStackControlPlane , helper * helper.Helper ) ( string , error ) {
572593 Log := GetLogger (ctx )
573594
574595 dnsSuffix := clusterdns .GetDNSClusterDomain ()
@@ -606,12 +627,12 @@ func EnsureOVNMetricsCert(ctx context.Context, instance *corev1beta1.OpenStackCo
606627 certRequest ,
607628 nil )
608629 if err != nil {
609- return err
630+ return "" , err
610631 } else if (ctrlResult != ctrl.Result {}) {
611632 Log .Info ("OVN metrics certificate creation in progress" , "certificate" , certRequest .CertName )
612- return fmt .Errorf ("OVN metrics certificate creation in progress" )
633+ return "" , fmt .Errorf ("OVN metrics certificate creation in progress" )
613634 }
614635
615636 Log .Info ("OVN metrics certificate ensured" , "secret" , certSecret .Name , "certificate" , certRequest .CertName )
616- return nil
637+ return certSecret . Name , nil
617638}
0 commit comments