add apt_reboot_if_required to reboot if required
If an upgrade or package installation forced a reboot (such as a kernel upgrade), then we can optionally reboot at that point. This allows the user to not be into the newest available kernel without needing a reboot on their own.
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
0.7.0:
|
0.7.0:
|
||||||
|
- add apt_reboot_if_required to reboot if an upgrade or package installation
|
||||||
|
forced the need for one (LP: #1038108)
|
||||||
- allow distro mirror selection to include availability-zone (LP: #1037727)
|
- allow distro mirror selection to include availability-zone (LP: #1037727)
|
||||||
- allow arch specific mirror selection (select ports.ubuntu.com on arm)
|
- allow arch specific mirror selection (select ports.ubuntu.com on arm)
|
||||||
LP: #1028501
|
LP: #1028501
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
import glob
|
import glob
|
||||||
import os
|
import os
|
||||||
|
import time
|
||||||
|
|
||||||
from cloudinit import templater
|
from cloudinit import templater
|
||||||
from cloudinit import util
|
from cloudinit import util
|
||||||
@@ -125,6 +126,20 @@ def handle(name, cfg, cloud, log, _args):
|
|||||||
util.logexc(log, "Failed to install packages: %s ", pkglist)
|
util.logexc(log, "Failed to install packages: %s ", pkglist)
|
||||||
errors.append(e)
|
errors.append(e)
|
||||||
|
|
||||||
|
# kernel and openssl (possibly some other packages)
|
||||||
|
# write a file /var/run/reboot-required after upgrading.
|
||||||
|
# if that file exists and configured, then just stop right now and reboot
|
||||||
|
# TODO(smoser): handle this less voilently
|
||||||
|
reboot_file = "/var/run/reboot-required"
|
||||||
|
if ((upgrade or pkglist) and cfg.get("apt_reboot_if_required", False) and
|
||||||
|
os.path.isfile(reboot_file)):
|
||||||
|
log.warn("rebooting after upgrade or install per %s" % reboot_file)
|
||||||
|
time.sleep(1) # give the warning time to get out
|
||||||
|
util.subp(["/sbin/reboot"])
|
||||||
|
time.sleep(60)
|
||||||
|
log.warn("requested reboot did not happen!")
|
||||||
|
errors.append(Exception("requested reboot did not happen!"))
|
||||||
|
|
||||||
if len(errors):
|
if len(errors):
|
||||||
log.warn("%s failed with exceptions, re-raising the last one",
|
log.warn("%s failed with exceptions, re-raising the last one",
|
||||||
len(errors))
|
len(errors))
|
||||||
|
|||||||
Reference in New Issue
Block a user