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

Reduce spam log generated by registry cache warmer #1538

Merged
merged 4 commits into from
Nov 21, 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
21 changes: 20 additions & 1 deletion registry/cache/warming.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,10 @@ func (w *Warmer) warm(ctx context.Context, now time.Time, logger log.Logger, id
awaitFetchers := &sync.WaitGroup{}
awaitFetchers.Add(len(toUpdate))

ctxc, cancel := context.WithCancel(context.Background())
squaremo marked this conversation as resolved.
Show resolved Hide resolved
var once sync.Once
defer cancel()

updates:
for _, up := range toUpdate {
select {
Expand All @@ -284,6 +288,12 @@ func (w *Warmer) warm(ctx context.Context, now time.Time, logger log.Logger, id
go func(update update) {
defer func() { awaitFetchers.Done(); <-fetchers }()

select {
case <-ctxc.Done():
return // terminate on error
default: // avoid blocking
squaremo marked this conversation as resolved.
Show resolved Hide resolved
}

imageID := update.ref

if w.Trace {
Expand All @@ -297,7 +307,16 @@ func (w *Warmer) warm(ctx context.Context, now time.Time, logger log.Logger, id
// This was due to a context timeout, don't bother logging
return
}
errorLogger.Log("err", err, "ref", imageID)

// abort the image tags fetching if we've been rate limited
if strings.Contains(err.Error(), "429") {
once.Do(func() {
errorLogger.Log("warn", "aborting image tag fetching due to rate limiting, will try again later")
})
cancel()
} else {
errorLogger.Log("err", err, "ref", imageID)
}
return
}

Expand Down