diff --git a/app/post_upgrade.go b/app/post_upgrade.go index f56a19451b..d8e1510dfc 100644 --- a/app/post_upgrade.go +++ b/app/post_upgrade.go @@ -70,7 +70,11 @@ func postUpgrade(c *cli.Context) error { if err != nil { return errors.Wrap(err, "failed to create event broadcaster") } - defer eventBroadcaster.Shutdown() + defer func() { + eventBroadcaster.Shutdown() + // Allow a little time for the event to flush, but not greatly delay response to the calling job. + time.Sleep(5 * time.Second) + }() scheme := runtime.NewScheme() if err := longhorn.SchemeBuilder.AddToScheme(scheme); err != nil { diff --git a/app/pre_upgrade.go b/app/pre_upgrade.go index bb5b00c2ff..3dfd1ae8d4 100644 --- a/app/pre_upgrade.go +++ b/app/pre_upgrade.go @@ -1,6 +1,8 @@ package app import ( + "time" + "github.com/pkg/errors" "github.com/sirupsen/logrus" "github.com/urfave/cli" @@ -61,7 +63,11 @@ func preUpgrade(c *cli.Context) error { if err != nil { return errors.Wrap(err, "failed to create event broadcaster") } - defer eventBroadcaster.Shutdown() + defer func() { + eventBroadcaster.Shutdown() + // Allow a little time for the event to flush, but not greatly delay response to the calling job. + time.Sleep(5 * time.Second) + }() scheme := runtime.NewScheme() if err := longhorn.SchemeBuilder.AddToScheme(scheme); err != nil {