From 45a550e741e45f04e5c426b5f67acaccdf56bb38 Mon Sep 17 00:00:00 2001 From: Santosh Kumar Gajawada Date: Thu, 22 Feb 2024 17:30:40 +0530 Subject: [PATCH] PB-5815: clean image secrets during data export and resource export cleanup --- pkg/controllers/dataexport/reconcile.go | 5 +++++ pkg/controllers/resourceexport/reconcile.go | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/pkg/controllers/dataexport/reconcile.go b/pkg/controllers/dataexport/reconcile.go index bcba057fb..082756fd6 100644 --- a/pkg/controllers/dataexport/reconcile.go +++ b/pkg/controllers/dataexport/reconcile.go @@ -1531,6 +1531,11 @@ func (c *Controller) cleanUp(driver drivers.Interface, de *kdmpapi.DataExport) e logrus.Errorf(errMsg) return fmt.Errorf(errMsg) } + if err := core.Instance().DeleteSecret(utils.GetImageSecretName(jobName), namespace); err != nil && !k8sErrors.IsNotFound(err) { + errMsg := fmt.Sprintf("deletion of image secret %s failed: %v", jobName, err) + logrus.Errorf(errMsg) + return fmt.Errorf(errMsg) + } } if err := core.Instance().DeleteSecret(utils.GetCredSecretName(de.Name), namespace); err != nil && !k8sErrors.IsNotFound(err) { diff --git a/pkg/controllers/resourceexport/reconcile.go b/pkg/controllers/resourceexport/reconcile.go index cf6d6072e..56fb7b4a9 100644 --- a/pkg/controllers/resourceexport/reconcile.go +++ b/pkg/controllers/resourceexport/reconcile.go @@ -280,6 +280,11 @@ func (c *Controller) cleanupResources(resourceExport *kdmpapi.ResourceExport) er logrus.Errorf(errMsg) return fmt.Errorf(errMsg) } + if err := core.Instance().DeleteSecret(utils.GetImageSecretName(rbName), rbNamespace); err != nil && !k8sErrors.IsNotFound(err) { + errMsg := fmt.Sprintf("deletion of image secret %s failed: %v", rbName, err) + logrus.Errorf(errMsg) + return fmt.Errorf(errMsg) + } return nil }