summaryrefslogtreecommitdiff
diff options
authorPhilip Meulengracht <philip.meulengracht@canonical.com>2023-07-31 09:14:13 +0200
committerMichael Vogt <michael.vogt@gmail.com>2023-08-01 15:00:37 +0200
commitd0c82ebb3b952adcada9c93593f2b6aef0de59d6 (patch)
tree91933f9f6016464ad2d9eeebd0f576eea794c09c
parentf1de83ce44abec42faa8d294018f8ffbea29d702 (diff)
daemon: allow nil stored rebootInfo
Otherwise this causes getRebootArguments to try to resolve a bootloader when even when there is no RebootInfo set as a part of HandleRestart.
-rw-r--r--daemon/daemon.go9
-rw-r--r--daemon/daemon_test.go4
2 files changed, 5 insertions, 8 deletions
diff --git a/daemon/daemon.go b/daemon/daemon.go
index 13e57c5bc9..1fa97cc822 100644
--- a/daemon/daemon.go
+++ b/daemon/daemon.go
@@ -79,7 +79,7 @@ type Daemon struct {
// set to what kind of restart was requested (if any)
requestedRestart restart.RestartType
// reboot info needed to handle reboots
- rebootInfo boot.RebootInfo
+ rebootInfo *boot.RebootInfo
// set to remember that we need to exit the daemon in a way that
// prevents systemd from restarting it
restartSocket bool
@@ -397,10 +397,7 @@ func (d *Daemon) HandleRestart(t restart.RestartType, rebootInfo *boot.RebootInf
logger.Noticef("%s", err)
}
}
- d.rebootInfo = boot.RebootInfo{}
- if rebootInfo != nil {
- d.rebootInfo = *rebootInfo
- }
+ d.rebootInfo = rebootInfo
// die when asked to restart (systemd should get us back up!) etc
switch t {
@@ -578,7 +575,7 @@ func (d *Daemon) Stop(sigCh chan<- os.Signal) error {
}
if needsFullShutdown {
- return d.doReboot(sigCh, d.requestedRestart, &rebootInfo, immediateShutdown, rebootWaitTimeout)
+ return d.doReboot(sigCh, d.requestedRestart, rebootInfo, immediateShutdown, rebootWaitTimeout)
}
if d.restartSocket {
diff --git a/daemon/daemon_test.go b/daemon/daemon_test.go
index 41e28707c2..438128534c 100644
--- a/daemon/daemon_test.go
+++ b/daemon/daemon_test.go
@@ -1147,7 +1147,7 @@ func (s *daemonSuite) TestRestartShutdownWithSigtermInBetween(c *check.C) {
c.Check(ri, check.IsNil)
case 2:
c.Check(d, check.Equals, 1*time.Minute)
- c.Check(ri, check.DeepEquals, &boot.RebootInfo{})
+ c.Check(ri, check.IsNil)
default:
c.Error("reboot called more times than expected")
}
@@ -1200,7 +1200,7 @@ func (s *daemonSuite) TestRestartShutdown(c *check.C) {
c.Check(ri, check.IsNil)
case 2:
c.Check(d, check.Equals, 1*time.Minute)
- c.Check(ri, check.DeepEquals, &boot.RebootInfo{})
+ c.Check(ri, check.IsNil)
default:
c.Error("reboot called more times than expected")
}