Skip to content

Commit

Permalink
fix(e2e): ensure zetaclientd restarts on upgrade (#2686)
Browse files Browse the repository at this point in the history
* cancel context on reload signal

* remove unused restartChan
  • Loading branch information
gartnera authored Aug 12, 2024
1 parent f78ff55 commit 93a6489
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
4 changes: 0 additions & 4 deletions cmd/zetaclientd-supervisor/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ type zetaclientdSupervisor struct {
upgradesDir string
upgradePlanName string
enableAutoDownload bool
restartChan chan os.Signal
}

func newZetaclientdSupervisor(
Expand All @@ -83,15 +82,12 @@ func newZetaclientdSupervisor(
if err != nil {
return nil, fmt.Errorf("grpc dial: %w", err)
}
// these signals will result in the supervisor process only restarting zetaclientd
restartChan := make(chan os.Signal, 1)
return &zetaclientdSupervisor{
zetacoredConn: conn,
logger: logger,
reloadSignals: make(chan bool, 1),
upgradesDir: defaultUpgradesDir,
enableAutoDownload: enableAutoDownload,
restartChan: restartChan,
}, nil
}

Expand Down
5 changes: 1 addition & 4 deletions cmd/zetaclientd-supervisor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ func main() {
os.Exit(1)
}
supervisor.Start(ctx)
// listen for SIGHUP to trigger a restart of zetaclientd
signal.Notify(supervisor.restartChan, syscall.SIGHUP)

shouldRestart := true
for shouldRestart {
Expand Down Expand Up @@ -81,15 +79,14 @@ func main() {
})
eg.Go(func() error {
supervisor.WaitForReloadSignal(ctx)
cancel()
return nil
})
eg.Go(func() error {
for {
select {
case <-ctx.Done():
return nil
case sig := <-supervisor.restartChan:
logger.Info().Msgf("got signal %d, sending SIGINT to zetaclientd", sig)
case sig := <-shutdownChan:
logger.Info().Msgf("got signal %d, shutting down", sig)
shouldRestart = false
Expand Down

0 comments on commit 93a6489

Please sign in to comment.