From d1b2d321106be390f7777343dc46f70f0a9f4884 Mon Sep 17 00:00:00 2001 From: James Munson Date: Wed, 23 Oct 2024 21:17:14 -0600 Subject: [PATCH] fix(upgrade): add short sleep to allow shutdown and event to flush before panic Signed-off-by: James Munson --- app/post_upgrade.go | 6 +++++- app/pre_upgrade.go | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/post_upgrade.go b/app/post_upgrade.go index 6e69e958d6..1281a46c09 100644 --- a/app/post_upgrade.go +++ b/app/post_upgrade.go @@ -70,7 +70,10 @@ 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() + time.Sleep(5 * time.Second) + }() scheme := runtime.NewScheme() if err := longhorn.SchemeBuilder.AddToScheme(scheme); err != nil { @@ -87,6 +90,7 @@ func postUpgrade(c *cli.Context) error { err = newPostUpgrader(namespace, kubeClient, eventRecorder).Run() if err != nil { logrus.Warnf("Done with Run() ... err is %v", err) + time.Sleep(5 * time.Minute) } return err diff --git a/app/pre_upgrade.go b/app/pre_upgrade.go index 8bb26527d1..4f01f2b533 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,10 @@ 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() + time.Sleep(5 * time.Second) + }() scheme := runtime.NewScheme() if err := longhorn.SchemeBuilder.AddToScheme(scheme); err != nil {