Merge pull request from mheon/no_error_on_dupe_handler

Do not error on installing duplicate shutdown handler
This commit is contained in:
OpenShift Merge Robot
2020-12-07 11:46:48 -05:00
committed by GitHub
2 changed files with 6 additions and 2 deletions
libpod

@ -190,7 +190,7 @@ func newRuntimeFromConfig(ctx context.Context, conf *config.Config, options ...R
if err := shutdown.Register("libpod", func(sig os.Signal) error { if err := shutdown.Register("libpod", func(sig os.Signal) error {
os.Exit(1) os.Exit(1)
return nil return nil
}); err != nil { }); err != nil && errors.Cause(err) != shutdown.ErrHandlerExists {
logrus.Errorf("Error registering shutdown handler for libpod: %v", err) logrus.Errorf("Error registering shutdown handler for libpod: %v", err)
} }

@ -10,6 +10,10 @@ import (
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
var (
ErrHandlerExists error = errors.New("handler with given name already exists")
)
var ( var (
stopped bool stopped bool
sigChan chan os.Signal sigChan chan os.Signal
@ -98,7 +102,7 @@ func Register(name string, handler func(os.Signal) error) error {
} }
if _, ok := handlers[name]; ok { if _, ok := handlers[name]; ok {
return errors.Errorf("handler with name %s already exists", name) return ErrHandlerExists
} }
handlers[name] = handler handlers[name] = handler