diff --git a/CHANGELOG.md b/CHANGELOG.md index 23c0e5ba..07e4a7b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [#483](https://github.com/XenitAB/spegel/pull/483) Update errcheck linter configuration and fix errors. - [#487](https://github.com/XenitAB/spegel/pull/487) Move mirror metrics code to mirror handler. - [#488](https://github.com/XenitAB/spegel/pull/488) Update existing registry errors and add more detail. +- [#490](https://github.com/XenitAB/spegel/pull/490) Close immediate channel after writing to it to close wait group in merge logic. ### Deprecated diff --git a/pkg/state/state.go b/pkg/state/state.go index a00d9136..5df6abb6 100644 --- a/pkg/state/state.go +++ b/pkg/state/state.go @@ -20,16 +20,17 @@ func Track(ctx context.Context, ociClient oci.Client, router routing.Router, res if err != nil { return err } - immediate := make(chan time.Time, 1) - immediate <- time.Now() + immediateCh := make(chan time.Time, 1) + immediateCh <- time.Now() + close(immediateCh) expirationTicker := time.NewTicker(routing.KeyTTL - time.Minute) defer expirationTicker.Stop() - ticker := channel.Merge(immediate, expirationTicker.C) + tickerCh := channel.Merge(immediateCh, expirationTicker.C) for { select { case <-ctx.Done(): return nil - case <-ticker: + case <-tickerCh: log.Info("running scheduled image state update") if err := all(ctx, ociClient, router, resolveLatestTag); err != nil { log.Error(err, "received errors when updating all images")