Skip to content

Commit

Permalink
Close immediate channel after writing to it to close wait group in me…
Browse files Browse the repository at this point in the history
…rge logic
  • Loading branch information
phillebaba committed May 16, 2024
1 parent 9794808 commit aa98f85
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 5 additions & 4 deletions pkg/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit aa98f85

Please sign in to comment.