Skip to content

Commit 29ed31b

Browse files
committed
add additional debug logging
Signed-off-by: James Munnelly <[email protected]>
1 parent 2e36109 commit 29ed31b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

manager/manager.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,8 +499,10 @@ func (m *Manager) handleRequest(ctx context.Context, volumeID string, meta metad
499499
// Poll every 200ms for the CertificateRequest to be ready
500500
lastFailureReason := ""
501501
if err := wait.PollUntilWithContext(ctx, time.Millisecond*200, func(ctx context.Context) (done bool, err error) {
502+
log.V(4).Info("Reading CertificateRequest from lister cache")
502503
updatedReq, err := m.lister.CertificateRequests(req.Namespace).Get(req.Name)
503504
if apierrors.IsNotFound(err) {
505+
log.V(4).Info("Failed to read CertificateRequest from lister cache", "error", err)
504506
// A NotFound error implies something deleted the resource - fail
505507
// early to allow a retry to occur at a later time if needed.
506508
return false, err
@@ -524,6 +526,7 @@ func (m *Manager) handleRequest(ctx context.Context, volumeID string, meta metad
524526

525527
isApproved := apiutil.CertificateRequestIsApproved(updatedReq)
526528
if !isApproved {
529+
log.V(4).Info("CertificateRequest is not explicitly approved - continuing to check if the request has been issued anyway")
527530
lastFailureReason = fmt.Sprintf("request %q has not yet been approved by approval plugin", updatedReq.Name)
528531
// we don't stop execution here, as some versions of cert-manager (and some external issuer plugins)
529532
// may not be aware/utilise approval.
@@ -533,6 +536,7 @@ func (m *Manager) handleRequest(ctx context.Context, volumeID string, meta metad
533536

534537
readyCondition := apiutil.GetCertificateRequestCondition(updatedReq, cmapi.CertificateRequestConditionReady)
535538
if readyCondition == nil {
539+
log.V(4).Info("Ready condition not found - will recheck...")
536540
// only overwrite the approval failure message if the request is actually approved
537541
// otherwise we may hide more useful information from the user by accident.
538542
if isApproved {
@@ -543,10 +547,12 @@ func (m *Manager) handleRequest(ctx context.Context, volumeID string, meta metad
543547

544548
switch readyCondition.Reason {
545549
case cmapi.CertificateRequestReasonIssued:
550+
log.V(4).Info("CertificateRequest has been issued!")
546551
break
547552
case cmapi.CertificateRequestReasonFailed:
548553
return false, fmt.Errorf("request %q has failed: %s", updatedReq.Name, readyCondition.Message)
549554
case cmapi.CertificateRequestReasonPending:
555+
log.V(4).Info("CertificateRequest is still pending...")
550556
if isApproved {
551557
lastFailureReason = fmt.Sprintf("request %q is pending: %v", updatedReq.Name, readyCondition.Message)
552558
}
@@ -578,6 +584,7 @@ func (m *Manager) handleRequest(ctx context.Context, volumeID string, meta metad
578584
return fmt.Errorf("calculating next issuance time: %w", err)
579585
}
580586
meta.NextIssuanceTime = &renewalPoint
587+
log.V(4).Info("Persisting next issuance time to metadata store", "next_issuance_time", renewalPoint)
581588

582589
if err := m.writeKeypair(meta, key, req.Status.Certificate, req.Status.CA); err != nil {
583590
return fmt.Errorf("writing keypair: %w", err)
@@ -589,6 +596,7 @@ func (m *Manager) handleRequest(ctx context.Context, volumeID string, meta metad
589596
// Without this, the renewal would pick up the existing issued certificate and re-issue, rather than requesting
590597
// a new certificate.
591598
m.deletePendingRequestPrivateKey(req.UID)
599+
log.V(4).Info("Removed pending request private key from internal cache")
592600

593601
return nil
594602
}

0 commit comments

Comments
 (0)