Skip to content

Commit

Permalink
engine: discard the first cache miss error (#364)
Browse files Browse the repository at this point in the history
* discard the first cache miss error

* explicitly check cache miss
  • Loading branch information
mxyng committed Sep 30, 2021
1 parent d06fb21 commit e383663
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions internal/engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ func Run(options Options) error {
})

timer := timer.Timer{}
certCacheMiss := 0
timer.Start(5, func() {
endpoint, err := k8s.Endpoint()
if err != nil {
Expand All @@ -307,6 +308,16 @@ func Run(options Options) error {

caBytes, err := manager.Cache.Get(context.TODO(), fmt.Sprintf("%s.crt", url.Hostname()))
if err != nil {
if err == autocert.ErrCacheMiss {
// first attempt to get the certificate on new service start will
// likely fail so a single cache miss is expected
certCacheMiss++
if certCacheMiss > 1 {
logging.L.Error(err.Error())
return
}
}

logging.L.Error(err.Error())
return
}
Expand Down

0 comments on commit e383663

Please sign in to comment.