Skip to content

Commit

Permalink
introduce reboot cleanup function as an alternative to a third reboot…
Browse files Browse the repository at this point in the history
… mode
  • Loading branch information
anpep committed Sep 11, 2024
1 parent 371e0a2 commit 5c691f4
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions internals/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ type Options struct {
// OverlordExtension is an optional interface used to extend the capabilities
// of the Overlord.
OverlordExtension overlord.Extension

// RebootCleanup runs when a system reboot has been requested, before calling the actual
// reboot handler.
RebootCleanup func() error
}

// A Daemon listens for requests and routes them to the right command
Expand All @@ -104,6 +108,7 @@ type Daemon struct {

// set to what kind of restart was requested (if any)
requestedRestart restart.RestartType
rebootCleanup func() error

// degradedErr is set when the daemon is in degraded mode
degradedErr error
Expand Down Expand Up @@ -681,6 +686,11 @@ func (d *Daemon) doReboot(sigCh chan<- os.Signal, waitTimeout time.Duration) err
if err != nil {
return err
}

if err := d.rebootCleanup(); err != nil {
return err
}

// ask for shutdown and wait for it to happen.
// if we exit, pebble will be restarted by systemd
if err := rebootHandler(rebootDelay); err != nil {
Expand Down Expand Up @@ -833,6 +843,7 @@ func New(opts *Options) (*Daemon, error) {
pebbleDir: opts.Dir,
normalSocketPath: opts.SocketPath,
httpAddress: opts.HTTPAddress,
rebootCleanup: opts.RebootCleanup,
}

ovldOptions := overlord.Options{
Expand Down

0 comments on commit 5c691f4

Please sign in to comment.