Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Log more details on cache warming errors #898

Merged
merged 4 commits into from
Jan 26, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Log canonical name and credentials on warming error.
  • Loading branch information
marccarre committed Jan 26, 2018
commit 4c9633f9b5af22f06e6b7dcf5ee95a3c7cd8aefc
16 changes: 8 additions & 8 deletions registry/cache/warming.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,10 @@ func imageCredsToBacklog(imageCreds registry.ImageCreds) []backlogItem {
}

func (w *Warmer) warm(ctx context.Context, logger log.Logger, id image.Name, creds registry.Credentials) {
errorLogger := log.With(logger, "canonical_name", id.CanonicalName(), "auth", creds)
client, err := w.clientFactory.ClientFor(id.CanonicalName(), creds)
if err != nil {
logger.Log("err", err.Error())
errorLogger.Log("err", err.Error())
return
}

Expand All @@ -128,10 +129,9 @@ func (w *Warmer) warm(ctx context.Context, logger log.Logger, id image.Name, cre
}

if err != nil {
logger.Log("err", errors.Wrap(err, "fetching previous result from cache"))
errorLogger.Log("err", errors.Wrap(err, "fetching previous result from cache"))
return
}

// Save for comparison later
oldImages := repo.Images

Expand All @@ -144,14 +144,14 @@ func (w *Warmer) warm(ctx context.Context, logger log.Logger, id image.Name, cre
err = w.cache.SetKey(repoKey, bytes)
}
if err != nil {
logger.Log("err", errors.Wrap(err, "writing result to cache"))
errorLogger.Log("err", errors.Wrap(err, "writing result to cache"))
}
}()

tags, err := client.Tags(ctx)
if err != nil {
if !strings.Contains(err.Error(), context.DeadlineExceeded.Error()) && !strings.Contains(err.Error(), "net/http: request canceled") {
logger.Log("err", errors.Wrap(err, "requesting tags"))
errorLogger.Log("err", errors.Wrap(err, "requesting tags"))
repo.LastError = err.Error()
}
return
Expand Down Expand Up @@ -212,20 +212,20 @@ func (w *Warmer) warm(ctx context.Context, logger log.Logger, id image.Name, cre
// This was due to a context timeout, don't bother logging
return
}
logger.Log("err", errors.Wrap(err, "requesting manifests"))
errorLogger.Log("err", errors.Wrap(err, "requesting manifests"))
return
}

key := NewManifestKey(img.ID.CanonicalRef())
// Write back to memcached
val, err := json.Marshal(img)
if err != nil {
logger.Log("err", errors.Wrap(err, "serializing tag to store in cache"))
errorLogger.Log("err", errors.Wrap(err, "serializing tag to store in cache"))
return
}
err = w.cache.SetKey(key, val)
if err != nil {
logger.Log("err", errors.Wrap(err, "storing manifests in cache"))
errorLogger.Log("err", errors.Wrap(err, "storing manifests in cache"))
return
}
successMx.Lock()
Expand Down