mirror of
https://github.com/goharbor/harbor.git
synced 2025-02-27 01:02:34 +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
|
||||
}
|
||||
|
||||
// GetAnyKeys ...
|
||||
// GetKeys ...
|
||||
func GetKeys(digests map[digest.Digest]io.ReadSeeker) (ds []digest.Digest) {
|
||||
for d := range digests {
|
||||
ds = append(ds, d)
|
||||
|
@ -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() {
|
||||
@ -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)
|
||||
@ -81,7 +84,7 @@ func (s *RegistryCtl) Start() {
|
||||
} else {
|
||||
err = regCtl.ListenAndServe()
|
||||
}
|
||||
<-ctx.Done()
|
||||
<-shutdown
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user