diff --git a/app/post_upgrade.go b/app/post_upgrade.go index 6e69e958d6..21d3971236 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 8bb26527d1..e304351dbd 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 {