Skip to content

Commit c71f738

Browse files
Merge pull request #772 from stuggi/tlse_envtest
[tls] adds conditions when custom issuer and custom service tls certs + adding envtests for scenarios
2 parents 47fcf16 + 03126b5 commit c71f738

5 files changed

Lines changed: 751 additions & 87 deletions

File tree

‎apis/core/v1beta1/conditions.go‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ const (
105105
// OpenStackControlPlaneCAReadyCondition Status=True condition which indicates if the CAs are configured and operational
106106
OpenStackControlPlaneCAReadyCondition condition.Type = "OpenStackControlPlaneCAReadyCondition"
107107

108+
// OpenStackControlPlaneCustomTLSReadyCondition Status=True condition which indicates if custom TLS certificate secrets are configured and operational
109+
OpenStackControlPlaneCustomTLSReadyCondition condition.Type = "OpenStackControlPlaneCustomTLSReadyCondition"
110+
108111
// OpenStackControlPlaneTelemetryReadyCondition Status=True condition which indicates if OpenStack Telemetry service is configured and operational
109112
OpenStackControlPlaneTelemetryReadyCondition condition.Type = "OpenStackControlPlaneTelemetryReady"
110113

@@ -420,6 +423,12 @@ const (
420423

421424
// OpenStackControlPlaneCAReadyErrorMessage
422425
OpenStackControlPlaneCAReadyErrorMessage = "OpenStackControlPlane CAs %s %s error occured %s"
426+
427+
// OpenStackControlPlaneCAReadyMessage
428+
OpenStackControlPlaneCustomTLSReadyMessage = "OpenStackControlPlane custom TLS cert secret available"
429+
430+
// OpenStackControlPlaneCAReadyErrorMessage
431+
OpenStackControlPlaneCustomTLSReadyErrorMessage = "OpenStackControlPlane custom TLS cert secret %s error occured %s"
423432
)
424433

425434
// Version Conditions used by API objects.

‎pkg/openstack/ca.go‎

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,26 @@ func ReconcileCAs(ctx context.Context, instance *corev1.OpenStackControlPlane, h
116116
return ctrlResult, nil
117117
}
118118
} else {
119+
customIssuer := *instance.Spec.TLS.Ingress.Ca.CustomIssuer
120+
119121
// add CA labelselector to issuer
120-
caCertSecretName, err := addIssuerLabel(ctx, helper, *instance.Spec.TLS.Ingress.Ca.CustomIssuer, instance.Namespace, issuerLabels)
122+
caCertSecretName, err := addIssuerLabel(ctx, helper, customIssuer, instance.Namespace, issuerLabels)
121123
if err != nil {
124+
instance.Status.Conditions.Set(condition.FalseCondition(
125+
corev1.OpenStackControlPlaneCAReadyCondition,
126+
condition.ErrorReason,
127+
condition.SeverityWarning,
128+
corev1.OpenStackControlPlaneCAReadyErrorMessage,
129+
"issuer",
130+
customIssuer,
131+
err.Error()))
132+
if k8s_errors.IsNotFound(err) {
133+
timeout := time.Second * 10
134+
Log.Info(fmt.Sprintf("Custom Issuer %s not found, reconcile in %s", customIssuer, timeout.String()))
135+
136+
return ctrl.Result{RequeueAfter: timeout}, nil
137+
}
138+
122139
return ctrlResult, err
123140
}
124141

@@ -131,7 +148,7 @@ func ReconcileCAs(ctx context.Context, instance *corev1.OpenStackControlPlane, h
131148

132149
ctrlResult, err = ensureCaBundles(
133150
instance,
134-
*instance.Spec.TLS.Ingress.Ca.CustomIssuer,
151+
customIssuer,
135152
caCert,
136153
bundle,
137154
caOnlyBundle,
@@ -163,9 +180,25 @@ func ReconcileCAs(ctx context.Context, instance *corev1.OpenStackControlPlane, h
163180
return ctrlResult, nil
164181
}
165182
} else {
183+
customIssuer := *instance.Spec.TLS.PodLevel.Internal.Ca.CustomIssuer
166184
// add CA labelselector to issuer
167-
caCertSecretName, err := addIssuerLabel(ctx, helper, *instance.Spec.TLS.PodLevel.Internal.Ca.CustomIssuer, instance.Namespace, issuerLabels)
185+
caCertSecretName, err := addIssuerLabel(ctx, helper, customIssuer, instance.Namespace, issuerLabels)
168186
if err != nil {
187+
instance.Status.Conditions.Set(condition.FalseCondition(
188+
corev1.OpenStackControlPlaneCAReadyCondition,
189+
condition.ErrorReason,
190+
condition.SeverityWarning,
191+
corev1.OpenStackControlPlaneCAReadyErrorMessage,
192+
"issuer",
193+
customIssuer,
194+
err.Error()))
195+
if k8s_errors.IsNotFound(err) {
196+
timeout := time.Second * 10
197+
Log.Info(fmt.Sprintf("Custom Issuer %s not found, reconcile in %s", customIssuer, timeout.String()))
198+
199+
return ctrl.Result{RequeueAfter: timeout}, nil
200+
}
201+
169202
return ctrlResult, err
170203
}
171204

@@ -178,7 +211,7 @@ func ReconcileCAs(ctx context.Context, instance *corev1.OpenStackControlPlane, h
178211

179212
ctrlResult, err = ensureCaBundles(
180213
instance,
181-
*instance.Spec.TLS.PodLevel.Internal.Ca.CustomIssuer,
214+
customIssuer,
182215
caCert,
183216
bundle,
184217
caOnlyBundle,
@@ -210,9 +243,25 @@ func ReconcileCAs(ctx context.Context, instance *corev1.OpenStackControlPlane, h
210243
return ctrlResult, nil
211244
}
212245
} else {
246+
customIssuer := *instance.Spec.TLS.PodLevel.Ovn.Ca.CustomIssuer
213247
// add CA labelselector to issuer
214-
caCertSecretName, err := addIssuerLabel(ctx, helper, *instance.Spec.TLS.PodLevel.Ovn.Ca.CustomIssuer, instance.Namespace, issuerLabels)
248+
caCertSecretName, err := addIssuerLabel(ctx, helper, customIssuer, instance.Namespace, issuerLabels)
215249
if err != nil {
250+
instance.Status.Conditions.Set(condition.FalseCondition(
251+
corev1.OpenStackControlPlaneCAReadyCondition,
252+
condition.ErrorReason,
253+
condition.SeverityWarning,
254+
corev1.OpenStackControlPlaneCAReadyErrorMessage,
255+
"issuer",
256+
customIssuer,
257+
err.Error()))
258+
if k8s_errors.IsNotFound(err) {
259+
timeout := time.Second * 10
260+
Log.Info(fmt.Sprintf("Custom Issuer %s not found, reconcile in %s", customIssuer, timeout.String()))
261+
262+
return ctrl.Result{RequeueAfter: timeout}, nil
263+
}
264+
216265
return ctrlResult, err
217266
}
218267

@@ -225,7 +274,7 @@ func ReconcileCAs(ctx context.Context, instance *corev1.OpenStackControlPlane, h
225274

226275
ctrlResult, err = ensureCaBundles(
227276
instance,
228-
*instance.Spec.TLS.PodLevel.Ovn.Ca.CustomIssuer,
277+
customIssuer,
229278
caCert,
230279
bundle,
231280
caOnlyBundle,

‎pkg/openstack/common.go‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,20 @@ func EnsureEndpointConfig(
243243
validateSecret := &tls.GenericService{SecretName: ed.Route.TLS.SecretName}
244244
_, ctrlResult, err := validateSecret.ValidateCertSecret(ctx, helper, instance.GetNamespace())
245245
if err != nil {
246+
instance.Status.Conditions.Set(condition.FalseCondition(
247+
corev1.OpenStackControlPlaneCustomTLSReadyCondition,
248+
condition.ErrorReason,
249+
condition.SeverityWarning,
250+
corev1.OpenStackControlPlaneCustomTLSReadyErrorMessage,
251+
ingressOverride.TLS.SecretName,
252+
err.Error()))
253+
246254
return endpoints, ctrlResult, err
247255
} else if (ctrlResult != ctrl.Result{}) {
248256
return endpoints, ctrlResult, nil
249257
}
258+
instance.Status.Conditions.MarkTrue(corev1.OpenStackControlPlaneCustomTLSReadyCondition,
259+
corev1.OpenStackControlPlaneCustomTLSReadyMessage)
250260
} else {
251261
ed.Route.TLS.IssuerName = instance.GetPublicIssuer()
252262
}
@@ -483,7 +493,10 @@ func (ed *EndpointDetail) CreateRoute(
483493
if err != nil {
484494
return ctrl.Result{}, err
485495
}
486-
enptRoute.OwnerReferences = append(enptRoute.OwnerReferences, owner)
496+
// in EnvTest the UID of the created service CRs are empty
497+
if owner.GetUID() != "" {
498+
enptRoute.OwnerReferences = append(enptRoute.OwnerReferences, owner)
499+
}
487500

488501
// if route TLS is disabled -> create the route
489502
// if TLS is enabled and the route does not yet exist -> create the route

0 commit comments

Comments
 (0)