mirror of
https://github.com/goharbor/harbor.git
synced 2025-02-27 09:12:07 +01:00
Fix the channel that never receives a value (#18139)
fix the channel that never receives a value 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>
This commit is contained in:
parent
bf7c82b9a8
commit
6a79de761b
@ -82,7 +82,7 @@ func GetAnyKey(digests map[digest.Digest]io.ReadSeeker) (d digest.Digest) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAnyKeys ...
|
// GetKeys ...
|
||||||
func GetKeys(digests map[digest.Digest]io.ReadSeeker) (ds []digest.Digest) {
|
func GetKeys(digests map[digest.Digest]io.ReadSeeker) (ds []digest.Digest) {
|
||||||
for d := range digests {
|
for d := range digests {
|
||||||
ds = append(ds, d)
|
ds = append(ds, d)
|
||||||
|
@ -57,6 +57,7 @@ func (s *RegistryCtl) Start() {
|
|||||||
TLSConfig: common_http.NewServerTLSConfig(),
|
TLSConfig: common_http.NewServerTLSConfig(),
|
||||||
}
|
}
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
shutdown := make(chan struct{})
|
||||||
regCtl.RegisterOnShutdown(tracelib.InitGlobalTracer(ctx))
|
regCtl.RegisterOnShutdown(tracelib.InitGlobalTracer(ctx))
|
||||||
// graceful shutdown
|
// graceful shutdown
|
||||||
go func() {
|
go func() {
|
||||||
@ -65,6 +66,8 @@ func (s *RegistryCtl) Start() {
|
|||||||
<-sig
|
<-sig
|
||||||
context, cancel := context.WithTimeout(ctx, 5*time.Second)
|
context, cancel := context.WithTimeout(ctx, 5*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
defer close(shutdown)
|
||||||
|
|
||||||
log.Infof("Got an interrupt, shutting down...")
|
log.Infof("Got an interrupt, shutting down...")
|
||||||
if err := regCtl.Shutdown(context); err != nil {
|
if err := regCtl.Shutdown(context); err != nil {
|
||||||
log.Fatalf("Failed to shutdown registry controller: %v", err)
|
log.Fatalf("Failed to shutdown registry controller: %v", err)
|
||||||
@ -81,7 +84,7 @@ func (s *RegistryCtl) Start() {
|
|||||||
} else {
|
} else {
|
||||||
err = regCtl.ListenAndServe()
|
err = regCtl.ListenAndServe()
|
||||||
}
|
}
|
||||||
<-ctx.Done()
|
<-shutdown
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user