Skip to content

Commit

Permalink
fix(upgrade): add short sleep to allow shutdown and event to flush be…
Browse files Browse the repository at this point in the history
…fore panic

Signed-off-by: James Munson <james.munson@suse.com>
  • Loading branch information
james-munson committed Oct 25, 2024
1 parent e7db6e7 commit d1b2d32
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion app/post_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
7 changes: 6 additions & 1 deletion app/pre_upgrade.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package app

import (
"time"

"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit d1b2d32

Please sign in to comment.