[node-patches] Change in ovirt-node[master]: Generate an initramfs as part of a pre-install hook for RHEV-M
rbarry at redhat.com
rbarry at redhat.com
Fri Oct 16 16:34:51 UTC 2015
Ryan Barry has uploaded a new change for review.
Change subject: Generate an initramfs as part of a pre-install hook for RHEV-M
......................................................................
Generate an initramfs as part of a pre-install hook for RHEV-M
RHEV-M upgrades will result in an initramfs for the wrong kernel.
Generate an initramfs as part of a pre-upgrade hook, then check
for it, remount /liveos, and copy it into the correct place if it
exists, so the initramfs matches the new kernel version.
Change-Id: I8b2da816cf288f666a7afe953d669b6ccab58242
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1270228
Signed-off-by: Ryan Barry <rbarry at redhat.com>
---
M hooks/Makefile.am
A hooks/pre-upgrade/04-copy-kernel-dracut
M scripts/ovirt-node-upgrade.py
3 files changed, 40 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/10/47410/1
diff --git a/hooks/Makefile.am b/hooks/Makefile.am
index f008d35..d89a637 100644
--- a/hooks/Makefile.am
+++ b/hooks/Makefile.am
@@ -16,7 +16,11 @@
# also available at http://www.gnu.org/copyleft/gpl.html.
onbootdir = $(libexecdir)/ovirt-node/hooks/on-boot
+preupgradedir = $(libexecdir)/ovirt-node/hooks/pre-upgrade
dist_onboot_SCRIPTS = \
on-boot/03-validate-owner-ssh-keys \
$(NULL)
+
+dist_preupgrade_SCRIPTS = \
+ pre-upgrade/04-copy-kernel-dracut
diff --git a/hooks/pre-upgrade/04-copy-kernel-dracut b/hooks/pre-upgrade/04-copy-kernel-dracut
new file mode 100755
index 0000000..8fe13f2
--- /dev/null
+++ b/hooks/pre-upgrade/04-copy-kernel-dracut
@@ -0,0 +1,27 @@
+#!/usr/bin/bash
+# -*- coding: utf-8 -*-
+#
+# 04-copy-kernel-dracut - Copyright (C) 2015 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+mkdir /tmp/newinitrd/
+rootfs=$(grep rootfs /proc/mounts | grep data | awk '{print $2}')
+for fs in dev proc sys tmp var/tmp; do
+ mount -o bind /${fs} ${rootfs}/${fs}
+done
+chroot ${rootfs} /usr/bin/bash -x <<'EOF'
+python -c "from ovirtnode import ovirtfunctions; ovirtfunctions.mount_liveos()"
+dracut -f --kver `rpm -q --qf "%{VERSION}-%{RELEASE}.%{ARCH}" kernel` /tmp/newinitrd/initrd0.img
+umount /liveos
+EOF
+for fs in dev proc sys tmp var/tmp; do
+ umount ${rootfs}/${fs}
+done
diff --git a/scripts/ovirt-node-upgrade.py b/scripts/ovirt-node-upgrade.py
index 533392d..7607ff9 100755
--- a/scripts/ovirt-node-upgrade.py
+++ b/scripts/ovirt-node-upgrade.py
@@ -34,6 +34,7 @@
OVIRT_UPGRADE_LOCK = "/tmp/.ovirt_upgrade.lock"
OVIRT_UPGRADED = "/tmp/ovirt_upgraded"
+
def which(file):
ret = None
if os.path.isabs(file) and os.path.exists(file):
@@ -254,6 +255,14 @@
self._logger.info("Installing Bootloader")
if not upgrade.ovirt_boot_setup():
raise RuntimeError("Bootloader Installation Failed")
+ # If an initramfs was generated as part of a pre-install hook,
+ # grab it and copy it in, because util.system.Initramfs will not
+ # do the right thing during ovirt_boot_setup
+ if os.path.exists("/tmp/newinitrd/initrd0.img"):
+ _functions_new.mount_liveos()
+ shutil.copy2("/tmp/newinitrd/initrd0.img", "/liveos/initrd0.img")
+ shutil.rmtree("/tmp/newinitrd")
+ self._system(which("umount"), "/liveos")
def _cleanup(self):
self._logger.info("Cleaning up temporary directory")
--
To view, visit https://gerrit.ovirt.org/47410
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8b2da816cf288f666a7afe953d669b6ccab58242
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Ryan Barry <rbarry at redhat.com>
More information about the node-patches
mailing list