1
0
mirror of https://github.com/rancher/os.git synced 2025-07-31 06:32:09 +00:00

Merge pull request #785 from joshwget/kexec-upgrade

Kexec upgrade
This commit is contained in:
Darren Shepherd 2016-02-28 23:28:44 -07:00
commit 0f263d570b
3 changed files with 24 additions and 8 deletions

View File

@ -1,6 +1,6 @@
FROM debian:jessie
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y grub2 parted
RUN apt-get update && apt-get install -y grub2 parted kexec-tools
COPY ./scripts/installer /scripts
COPY ./build.conf /scripts/

View File

@ -50,6 +50,10 @@ func osSubcommands() []cli.Command {
Name: "no-reboot",
Usage: "do not reboot after upgrade",
},
cli.BoolFlag{
Name: "kexec",
Usage: "reboot using kexec",
},
},
},
{
@ -149,7 +153,7 @@ func osUpgrade(c *cli.Context) {
if c.Args().Present() {
log.Fatalf("invalid arguments %v", c.Args())
}
if err := startUpgradeContainer(image, c.Bool("stage"), c.Bool("force"), !c.Bool("no-reboot")); err != nil {
if err := startUpgradeContainer(image, c.Bool("stage"), c.Bool("force"), !c.Bool("no-reboot"), c.Bool("kexec")); err != nil {
log.Fatal(err)
}
}
@ -168,21 +172,28 @@ func yes(in *bufio.Reader, question string) bool {
return strings.ToLower(line[0:1]) == "y"
}
func startUpgradeContainer(image string, stage, force, reboot bool) error {
func startUpgradeContainer(image string, stage, force, reboot, kexec bool) error {
in := bufio.NewReader(os.Stdin)
command := []string{
"-t", "rancher-upgrade",
"-r", config.VERSION,
}
if kexec {
command = append(command, "-k")
}
container, err := compose.CreateService(nil, "os-upgrade", &project.ServiceConfig{
LogDriver: "json-file",
Privileged: true,
Net: "host",
Pid: "host",
Image: image,
Labels: project.NewSliceorMap(map[string]string{
config.SCOPE: config.SYSTEM,
}),
Command: project.NewCommand(
"-t", "rancher-upgrade",
"-r", config.VERSION,
),
Command: project.NewCommand(command...),
})
if err != nil {
return err

View File

@ -6,7 +6,7 @@ SCRIPTS_DIR=$(dirname ${0})
. "${SCRIPTS_DIR}/build.conf"
VERSION=${VERSION:?"VERSION not set"}
while getopts "i:f:c:d:t:r:o:p:" OPTION
while getopts "i:f:c:d:t:r:o:p:k" OPTION
do
case ${OPTION} in
i) DIST="$OPTARG" ;;
@ -16,6 +16,7 @@ do
o) OEM="$OPTARG" ;;
p) PARTITION="$OPTARG" ;;
r) ROLLBACK_VERSION="$OPTARG" ;;
k) KEXEC=y ;;
t) ENV="$OPTARG" ;;
*) exit 1 ;;
esac
@ -187,3 +188,7 @@ fi
grub2_config "${KERNEL_ARGS}"
pvgrub_config "${KERNEL_ARGS}"
install_rancher
if [ "$KEXEC" = "y" ]; then
kexec -l ${DIST}/vmlinuz --initrd=${DIST}/initrd -f
fi