Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(upgrade): add sleep to allow event to flush before panic (backport #3234) #3244

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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