storage node: Drain internal error's channel #878

Merged
fyrchik merged 1 commit from dstepanov-yadro/frostfs-node:fix/shutdown_panic into master 2023-12-19 16:38:06 +00:00
2 changed files with 14 additions and 1 deletions
Showing only changes of commit 484836b9f9 - Show all commits

View file

@ -1325,5 +1325,4 @@ func (c *cfg) shutdown() {
for i := range c.closers { for i := range c.closers {
c.closers[len(c.closers)-1-i].fn() c.closers[len(c.closers)-1-i].fn()
} }
close(c.internalErr)
} }

View file

@ -6,6 +6,7 @@ import (
"fmt" "fmt"
"log" "log"
"os" "os"
"sync"
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config" "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config"
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs" "git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
@ -155,9 +156,22 @@ func wait(c *cfg) {
<-c.done // graceful shutdown <-c.done // graceful shutdown
drain := &sync.WaitGroup{}
drain.Add(1)
go func() {
defer drain.Done()
for err := range c.internalErr {
c.log.Warn(logs.FrostFSNodeInternalApplicationError,
zap.String("message", err.Error()))
}
}()
c.log.Debug(logs.FrostFSNodeWaitingForAllProcessesToStop) c.log.Debug(logs.FrostFSNodeWaitingForAllProcessesToStop)
c.wg.Wait() c.wg.Wait()
close(c.internalErr)
drain.Wait()
} }
func (c *cfg) onShutdown(f func()) { func (c *cfg) onShutdown(f func()) {