Skip to content

Commit

Permalink
fix the channel that never receives a value
Browse files Browse the repository at this point in the history
fix the code with the linter's recommendation by https://github.com/goharbor/harbor/blob/main/CONTRIBUTING.md#develop-build-and-test

Signed-off-by: iAklis <chenpinwei@gmail.com>
  • Loading branch information
iAklis authored and chlins committed May 19, 2023
1 parent bf7c82b commit 52bceae
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/registryctl/api/registry/test/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func GetAnyKey(digests map[digest.Digest]io.ReadSeeker) (d digest.Digest) {
return
}

// GetAnyKeys ...
// GetKeys ...
func GetKeys(digests map[digest.Digest]io.ReadSeeker) (ds []digest.Digest) {
for d := range digests {
ds = append(ds, d)
Expand Down
5 changes: 4 additions & 1 deletion src/registryctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func (s *RegistryCtl) Start() {
TLSConfig: common_http.NewServerTLSConfig(),
}
ctx := context.Background()
shutdown := make(chan struct{})
regCtl.RegisterOnShutdown(tracelib.InitGlobalTracer(ctx))
// graceful shutdown
go func() {
Expand All @@ -65,6 +66,8 @@ func (s *RegistryCtl) Start() {
<-sig
context, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
defer close(shutdown)

log.Infof("Got an interrupt, shutting down...")
if err := regCtl.Shutdown(context); err != nil {
log.Fatalf("Failed to shutdown registry controller: %v", err)
Expand All @@ -81,7 +84,7 @@ func (s *RegistryCtl) Start() {
} else {
err = regCtl.ListenAndServe()
}
<-ctx.Done()
<-shutdown
if err != nil {
log.Fatal(err)
}
Expand Down

0 comments on commit 52bceae

Please sign in to comment.