Skip to content

Commit 0a81220

Browse files
committed
[cert] Also cleanup cert when service annotation gets removed
When the service annotation to expose it via route gets changed, the route get cleaned up, but its certificate remains. This change will also delete the corresponding certificated. Signed-off-by: Martin Schuppert <[email protected]>
1 parent b0944fc commit 0a81220

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pkg/openstack/common.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,15 @@ func (ed *EndpointDetail) ensureRoute(
451451
// Delete any other owner refs from ref list to not block deletion until owners are gone
452452
r.SetOwnerReferences([]metav1.OwnerReference{instanceRef})
453453

454+
// Delete certificate for the route
455+
if ed.Service.TLS.Enabled {
456+
err = DeleteCertificate(ctx, helper, instance.Namespace, ed.Route.TLS.CertName)
457+
if err != nil && !k8s_errors.IsNotFound(err) {
458+
err = fmt.Errorf("Error deleting route certificate %s: %w", ed.Route.TLS.CertName, err)
459+
return ctrl.Result{}, err
460+
}
461+
}
462+
454463
// Delete route
455464
err := helper.GetClient().Delete(ctx, &r)
456465
if err != nil && !k8s_errors.IsNotFound(err) {

0 commit comments

Comments
 (0)