[OOM-CERT-SERVICE] Fix cmpv2 issuer error when CRD is removed 89/121789/2
authorTomasz Wrobel <tomasz.wrobel@nokia.com>
Thu, 10 Jun 2021 08:44:58 +0000 (10:44 +0200)
committerTomasz Wrobel <tomasz.wrobel@nokia.com>
Tue, 15 Jun 2021 06:58:57 +0000 (08:58 +0200)
Issue-ID: OOM-2771
Signed-off-by: Tomasz Wrobel <tomasz.wrobel@nokia.com>
Change-Id: I28f7a0d7fb3e7f6227b0a4ac64ca45c274956b8e

certServiceK8sExternalProvider/src/cmpv2controller/certificate_request_controller.go

index cb667bd..51d1359 100644 (file)
@@ -97,7 +97,7 @@ func (controller *CertificateRequestController) Reconcile(k8sRequest ctrl.Reques
        }
        if err := controller.Client.Get(ctx, issuerNamespaceName, &issuer); err != nil {
                controller.handleErrorGettingCMPv2Issuer(certUpdater, log, err, certificateRequest, issuerNamespaceName, k8sRequest)
-               return ctrl.Result{}, err
+               return ctrl.Result{}, client.IgnoreNotFound(err)
        }
 
        // 5. Check if CMPv2Issuer is ready to sing certificates
@@ -110,7 +110,7 @@ func (controller *CertificateRequestController) Reconcile(k8sRequest ctrl.Reques
        provisioner, ok := provisioners.Load(issuerNamespaceName)
        if !ok {
                err := controller.handleErrorCouldNotLoadCMPv2Provisioner(certUpdater, log, issuerNamespaceName)
-               return ctrl.Result{}, err
+               return ctrl.Result{}, client.IgnoreNotFound(err)
        }
 
        // 7. Get private key matching CertificateRequest
@@ -221,8 +221,9 @@ func (controller *CertificateRequestController) handleErrorFailedToDecodeCSR(upd
 func handleErrorResourceNotFound(log leveledlogger.Logger, err error) error {
        if apierrors.IsNotFound(err) {
                log.Error(err, "CertificateRequest resource not found")
+               return nil
        } else {
                log.Error(err, "Failed to retrieve CertificateRequest resource")
+               return err
        }
-       return err
 }