Skip to content

Commit

Permalink
Fixes CR sync api reporting
Browse files Browse the repository at this point in the history
Signed-off-by: JoshVanL <vleeuwenjoshua@gmail.com>
  • Loading branch information
JoshVanL committed Jul 28, 2019
1 parent 59c70f0 commit ab43659
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion pkg/controller/certificaterequests/ca/ca.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (c *CA) Sign(ctx context.Context, cr *v1alpha1.CertificateRequest) (*issuer

// We are probably in a network error here so we should backoff and retry
reporter.Pending(err, "ErrorGettingIssuer",
fmt.Sprintf("Failed to get referenced Issuer %q", cr.Spec.Issuer.Name))
fmt.Sprintf("Failed to get referenced Issuer %q", cr.Spec.IssuerRef.Name))
return nil, err
}

Expand Down
32 changes: 15 additions & 17 deletions pkg/controller/certificaterequests/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"github.com/jetstack/cert-manager/pkg/apis/certmanager"
"github.com/jetstack/cert-manager/pkg/apis/certmanager/v1alpha1"
"github.com/jetstack/cert-manager/pkg/apis/certmanager/validation"
crutil "github.com/jetstack/cert-manager/pkg/controller/certificaterequests/util"
logf "github.com/jetstack/cert-manager/pkg/logs"
"github.com/jetstack/cert-manager/pkg/util/pki"
)
Expand Down Expand Up @@ -65,24 +64,23 @@ func (c *Controller) Sync(ctx context.Context, cr *v1alpha1.CertificateRequest)

dbg.Info("fetching issuer object referenced by CertificateRequest")

reporter := crutil.NewReporter(log, cr, c.recorder)
issuerObj, err := c.helper.GetGenericIssuer(crCopy.Spec.IssuerRef, crCopy.Namespace)
if k8sErrors.IsNotFound(err) {
apiutil.SetCertificateRequestCondition(crCopy, v1alpha1.CertificateRequestConditionReady,
v1alpha1.ConditionFalse, v1alpha1.CertificateRequestReasonPending,
fmt.Sprintf("Referenced %s not found", apiutil.IssuerKind(crCopy.Spec.IssuerRef)))

issuerObj, err := c.helper.GetGenericIssuer(cr.Spec.IssuerRef, cr.Namespace)
if err != nil {
log = log.WithValues(
logf.RelatedResourceNameKey, cr.Spec.IssuerRef.Name,
logf.RelatedResourceKindKey, cr.Spec.IssuerRef.Kind,
)

if k8sErrors.IsNotFound(err) {
reporter.WithLog(log).Pending(err, v1alpha1.CertificateRequestReasonPending,
fmt.Sprintf("Referenced %s not found", apiutil.IssuerKind(cr.Spec.IssuerRef)))
return nil
}
c.recorder.Eventf(crCopy, corev1.EventTypeWarning, v1alpha1.CertificateRequestReasonPending, err.Error())

// We are probably in a network error here so we should backoff and retry
reporter.Pending(err, "ErrorGettingIssuer",
fmt.Sprintf("Failed to get referenced Issuer %q", cr.Spec.IssuerRef.Name))
log.WithValues(
logf.RelatedResourceNameKey, crCopy.Spec.IssuerRef.Name,
logf.RelatedResourceKindKey, crCopy.Spec.IssuerRef.Kind,
).Error(err, "failed to find referenced issuer")

return nil
}

if err != nil {
return err
}

Expand Down

0 comments on commit ab43659

Please sign in to comment.