Skip to content

Commit 5a906ed

Browse files
committed
Guard other code path as in previous commits
Also log at WARN level
1 parent a7ae863 commit 5a906ed

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

maintain.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,19 @@ func (cfg *Config) updateARI(ctx context.Context, cert Certificate, logger *zap.
507507
if err == nil && gotNewARI {
508508
// great, storage has a newer one we can use
509509
cfg.certCache.mu.Lock()
510-
updatedCert = cfg.certCache.cache[cert.hash]
510+
var ok bool
511+
updatedCert, ok = cfg.certCache.cache[cert.hash]
512+
if !ok {
513+
// cert is no longer in the cache... why? what's the right thing to do here?
514+
cfg.certCache.mu.Unlock()
515+
updatedCert = cert // return input cert, not an empty one
516+
updatedCert.ari = newARI // might as well give it the new ARI for the benefit of our caller, but it won't be updated in the cache or in storage
517+
logger.Warn("loaded newer ARI from storage, but certificate is no longer in cache; newer ARI will be returned to caller, but not persisted in the cache",
518+
zap.Time("selected_time", newARI.SelectedTime),
519+
zap.Timep("next_update", newARI.RetryAfter),
520+
zap.String("explanation_url", newARI.ExplanationURL))
521+
return
522+
}
511523
updatedCert.ari = newARI
512524
cfg.certCache.cache[cert.hash] = updatedCert
513525
cfg.certCache.mu.Unlock()
@@ -558,7 +570,7 @@ func (cfg *Config) updateARI(ctx context.Context, cert Certificate, logger *zap.
558570
cfg.certCache.mu.Unlock()
559571
updatedCert = cert // return input cert, not an empty one
560572
updatedCert.ari = newARI // might as well give it the new ARI for the benefit of our caller, but it won't be updated in the cache or in storage
561-
logger.Debug("obtained ARI update, but certificate no longer in cache; ARI update will be returned to caller, but not stored",
573+
logger.Warn("obtained ARI update, but certificate no longer in cache; ARI update will be returned to caller, but not stored",
562574
zap.Time("selected_time", newARI.SelectedTime),
563575
zap.Timep("next_update", newARI.RetryAfter),
564576
zap.String("explanation_url", newARI.ExplanationURL))

0 commit comments

Comments
 (0)