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 authored and derekbit committed Oct 30, 2024
1 parent 58ec538 commit 235b1ae
Show file tree
Hide file tree
Showing 2 changed files with 12 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,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 {
Expand Down
8 changes: 7 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,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 {
Expand Down

0 comments on commit 235b1ae

Please sign in to comment.