diff options
Diffstat (limited to 'patches/fuel-agent')
7 files changed, 481 insertions, 0 deletions
diff --git a/patches/fuel-agent/0001-Use-qemu-debootstrap-for-image-creation.patch b/patches/fuel-agent/0001-Use-qemu-debootstrap-for-image-creation.patch new file mode 100644 index 00000000..28ef2cff --- /dev/null +++ b/patches/fuel-agent/0001-Use-qemu-debootstrap-for-image-creation.patch @@ -0,0 +1,160 @@ +From: Stanislaw Kardach <stanislaw.kardach@caviumnetworks.com> +Date: Thu, 25 Feb 2016 13:38:14 +0100 +Subject: [PATCH] Use qemu-debootstrap for image creation + +This commit adds qemu-debootstrap support and a command line argument +`target_arch` which can be used for choosing the architecture to build +the image for. The architecture detection from environment settings is +not yet implemented. +--- + .../fuel_bootstrap_cli/fuel_bootstrap/commands/build.py | 8 ++++++++ + .../fuel_bootstrap/utils/bootstrap_image.py | 3 ++- + debian/control | 2 ++ + fuel_agent/manager.py | 13 ++++++++++++- + fuel_agent/tests/test_build_utils.py | 4 ++-- + fuel_agent/utils/build.py | 2 +- + specs/fuel-agent.spec | 2 ++ + 7 files changed, 29 insertions(+), 5 deletions(-) + +diff --git a/contrib/fuel_bootstrap/fuel_bootstrap_cli/fuel_bootstrap/commands/build.py b/contrib/fuel_bootstrap/fuel_bootstrap_cli/fuel_bootstrap/commands/build.py +index ca2d3e1..b0d410d 100644 +--- a/contrib/fuel_bootstrap/fuel_bootstrap_cli/fuel_bootstrap/commands/build.py ++++ b/contrib/fuel_bootstrap/fuel_bootstrap_cli/fuel_bootstrap/commands/build.py +@@ -166,6 +166,14 @@ class BuildCommand(command.Command): + " files", + action='append' + ) ++ parser.add_argument( ++ '--target_arch', ++ type=str, ++ choices=['arm64', 'amd64'], ++ help="Choose the target architecture for which image is built", ++ default="amd64" ++ ) ++ + return parser + + def take_action(self, parsed_args): +diff --git a/contrib/fuel_bootstrap/fuel_bootstrap_cli/fuel_bootstrap/utils/bootstrap_image.py b/contrib/fuel_bootstrap/fuel_bootstrap_cli/fuel_bootstrap/utils/bootstrap_image.py +index 0219961..1387cf9 100644 +--- a/contrib/fuel_bootstrap/fuel_bootstrap_cli/fuel_bootstrap/utils/bootstrap_image.py ++++ b/contrib/fuel_bootstrap/fuel_bootstrap_cli/fuel_bootstrap/utils/bootstrap_image.py +@@ -172,7 +172,8 @@ def make_bootstrap(data): + + LOG.info("Try to build image with data:\n%s", yaml.safe_dump(bootdata)) + +- opts = ['--data_driver', 'bootstrap_build_image'] ++ opts = ['--data_driver', 'bootstrap_build_image', ++ '--target_arch', data['target_arch']] + if data.get('image_build_dir'): + opts.extend(['--image_build_dir', data['image_build_dir']]) + +diff --git a/debian/control b/debian/control +index 0a6f947..189dc00 100644 +--- a/debian/control ++++ b/debian/control +@@ -36,6 +36,8 @@ Pre-Depends: dpkg (>= 1.15.6~) + Depends: bzip2, + cloud-utils, + debootstrap, ++ qemu-user-static, ++ binfmt-support, + dmidecode, + ethtool, + gdisk, +diff --git a/fuel_agent/manager.py b/fuel_agent/manager.py +index 15cc5d8..f613aef 100644 +--- a/fuel_agent/manager.py ++++ b/fuel_agent/manager.py +@@ -18,6 +18,7 @@ import shutil + import signal + + from oslo_config import cfg ++from oslo_config import types + import six + import yaml + +@@ -33,6 +34,8 @@ from fuel_agent.utils import md as mu + from fuel_agent.utils import partition as pu + from fuel_agent.utils import utils + ++ArchType = types.String(choices=['amd64', 'arm64']) ++ + opts = [ + cfg.StrOpt( + 'nc_template_path', +@@ -153,6 +156,13 @@ cli_opts = [ + default='/tmp', + help='Directory where the image is supposed to be built', + ), ++ cfg.Opt( ++ 'target_arch', ++ default='amd64', ++ type=ArchType, ++ help='Architecture for which image will be built using ' ++ 'debootstrap', ++ ), + ] + + CONF = cfg.CONF +@@ -551,7 +561,8 @@ class Manager(object): + LOG.debug('Preventing services from being get started') + bu.suppress_services_start(chroot) + LOG.debug('Installing base operating system using debootstrap') +- bu.run_debootstrap(uri=uri, suite=suite, chroot=chroot, ++ bu.run_debootstrap(uri=uri, suite=suite, arch=CONF.target_arch, ++ chroot=chroot, + attempts=CONF.fetch_packages_attempts, + proxies=proxies.proxies, + direct_repo_addr=proxies.direct_repo_addr_list) +diff --git a/fuel_agent/tests/test_build_utils.py b/fuel_agent/tests/test_build_utils.py +index 82c3462..ac5ae82 100644 +--- a/fuel_agent/tests/test_build_utils.py ++++ b/fuel_agent/tests/test_build_utils.py +@@ -42,7 +42,7 @@ class BuildUtilsTestCase(unittest2.TestCase): + def test_run_debootstrap(self, mock_exec, mock_environ): + bu.run_debootstrap('uri', 'suite', 'chroot', 'arch', attempts=2) + mock_exec.assert_called_once_with( +- 'debootstrap', '--include={0}' ++ 'qemu-debootstrap', '--include={0}' + .format(','.join(bu.ADDITIONAL_DEBOOTSTRAP_PACKAGES)), + '--verbose', '--no-check-gpg', '--arch=arch', + 'suite', 'chroot', 'uri', attempts=2, env_variables={}) +@@ -53,7 +53,7 @@ class BuildUtilsTestCase(unittest2.TestCase): + bu.run_debootstrap('uri', 'suite', 'chroot', 'arch', eatmydata=True, + attempts=2) + mock_exec.assert_called_once_with( +- 'debootstrap', '--include={0}' ++ 'qemu-debootstrap', '--include={0}' + .format(','.join(bu.ADDITIONAL_DEBOOTSTRAP_PACKAGES)), + '--verbose', '--no-check-gpg', '--arch=arch', + '--include=eatmydata', 'suite', +diff --git a/fuel_agent/utils/build.py b/fuel_agent/utils/build.py +index 7247965..af41b2b 100644 +--- a/fuel_agent/utils/build.py ++++ b/fuel_agent/utils/build.py +@@ -80,7 +80,7 @@ def run_debootstrap(uri, suite, chroot, arch='amd64', eatmydata=False, + env_vars['no_proxy'] = ','.join(direct_repo_addr) + LOG.debug('Setting no_proxy for: {0}'.format(env_vars['no_proxy'])) + +- cmds = ['debootstrap', ++ cmds = ['qemu-debootstrap', + '--include={0}'.format(",".join(ADDITIONAL_DEBOOTSTRAP_PACKAGES)), + '--verbose', '--no-check-gpg', + '--arch={0}'.format(arch)] +diff --git a/specs/fuel-agent.spec b/specs/fuel-agent.spec +index 5c37600..a43f693 100644 +--- a/specs/fuel-agent.spec ++++ b/specs/fuel-agent.spec +@@ -50,6 +50,8 @@ Requires: xfsprogs + Requires: pciutils + Requires: ethtool + Requires: debootstrap ++Requires: dpkg ++Requires: qemu-user-static + Requires: xz + Requires: coreutils + Requires: psmisc +-- +1.9.1 + diff --git a/patches/fuel-agent/0002-Add-FLASH_KERNEL_SKIP-true.patch b/patches/fuel-agent/0002-Add-FLASH_KERNEL_SKIP-true.patch new file mode 100644 index 00000000..260651c5 --- /dev/null +++ b/patches/fuel-agent/0002-Add-FLASH_KERNEL_SKIP-true.patch @@ -0,0 +1,24 @@ +From: Alexandru Avadanii <Alexandru.Avadanii@enea.com> +Date: Thu, 25 Feb 2016 16:01:18 +0100 +Subject: [PATCH] Add FLASH_KERNEL_SKIP=true. + +FIXME: Add nice description of the issue at hand. +--- + fuel_agent/utils/build.py | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/fuel_agent/utils/build.py b/fuel_agent/utils/build.py +index af41b2b..6f31732 100644 +--- a/fuel_agent/utils/build.py ++++ b/fuel_agent/utils/build.py +@@ -97,6 +97,7 @@ def set_apt_get_env(): + # NOTE(agordeev): disable any confirmations/questions from apt-get side + os.environ['DEBIAN_FRONTEND'] = 'noninteractive' + os.environ['DEBCONF_NONINTERACTIVE_SEEN'] = 'true' ++ os.environ['FLASH_KERNEL_SKIP'] = 'true' + os.environ['LC_ALL'] = os.environ['LANG'] = os.environ['LANGUAGE'] = 'C' + + +-- +1.9.1 + diff --git a/patches/fuel-agent/0003-Fix-qemu-user-static-replacement.patch b/patches/fuel-agent/0003-Fix-qemu-user-static-replacement.patch new file mode 100644 index 00000000..1ea93ba3 --- /dev/null +++ b/patches/fuel-agent/0003-Fix-qemu-user-static-replacement.patch @@ -0,0 +1,58 @@ +From: Stanislaw Kardach <stanislaw.kardach@caviumnetworks.com> +Date: Sun, 6 Mar 2016 16:09:39 +0100 +Subject: [PATCH] Fix qemu-user-static replacement + +--- + fuel_agent/manager.py | 6 ++++++ + fuel_agent/utils/build.py | 18 ++++++++++++++++++ + 2 files changed, 24 insertions(+) + +diff --git a/fuel_agent/manager.py b/fuel_agent/manager.py +index f613aef..6322a10 100644 +--- a/fuel_agent/manager.py ++++ b/fuel_agent/manager.py +@@ -587,6 +587,12 @@ class Manager(object): + fu.mount_bind(chroot, '/proc') + bu.populate_basic_dev(chroot) + ++ # we need to make sure that qemu-{target_arch}-static binary is ++ # not replaced inside chroot because we're possibly using it ++ # through qemu-debootstrap ++ LOG.debug('Preventing qemu-user-static replacement inside chroot') ++ bu.prevent_qemu_replacement(chroot, CONF.target_arch) ++ + def destroy_chroot(self, chroot): + # Umount chroot tree and remove images tmp files + if not bu.stop_chrooted_processes(chroot, signal=signal.SIGTERM): +diff --git a/fuel_agent/utils/build.py b/fuel_agent/utils/build.py +index 6f31732..abd762e 100644 +--- a/fuel_agent/utils/build.py ++++ b/fuel_agent/utils/build.py +@@ -312,6 +312,24 @@ def populate_basic_dev(chroot): + utils.execute('chroot', chroot, + 'ln', '-s', '/proc/self/fd', '/dev/fd') + ++def prevent_qemu_replacement(chroot, arch): ++ """Prevents qemu-user-static replacement inside chroot. ++ ++ Use dpkg-divert to prevent replacing qemu-user-static binary inside ++ chroot which is necessary for host-side qemu-debootstrap to work ++ properly.""" ++ if arch == 'arm64': ++ qemu = 'qemu-aarch64-static' ++ elif arch == 'amd64': ++ qemu = 'qemu-x86_64-static' ++ utils.execute('chroot', chroot, ++ 'dpkg-divert', '--divert', '/usr/bin/%s.orig' % qemu, ++ '/usr/bin/%s' % qemu) ++ utils.execute('chroot', chroot, ++ 'dpkg-divert', '--divert', '/usr/sbin/update-binfmts.orig', ++ '--rename', '/usr/sbin/update-binfmts') ++ utils.execute('chroot', chroot, 'ln', '-sf', '/bin/true', ++ '/usr/sbin/update-binfmts') + + def create_sparse_tmp_file(dir, suffix, size=8192): + """Creates sparse file. +-- +1.9.1 + diff --git a/patches/fuel-agent/0004-Prevent-common-cross-debootstrap-newaliases-issue.patch b/patches/fuel-agent/0004-Prevent-common-cross-debootstrap-newaliases-issue.patch new file mode 100644 index 00000000..1d044585 --- /dev/null +++ b/patches/fuel-agent/0004-Prevent-common-cross-debootstrap-newaliases-issue.patch @@ -0,0 +1,105 @@ +From: Alexandru Avadanii <Alexandru.Avadanii@enea.com> +Date: Tue, 8 Mar 2016 00:44:05 +0100 +Subject: [PATCH] Prevent common cross-debootstrap newaliases issue. + +While building target images for a different arch (using qemu-user-static), +the following issue prevents the succesful image build: +newaliases: fatal: inet_addr_local[getifaddrs]: +getifaddrs: Address family not supported by protocol + +For more information, see [1]. + +[1] https://bugs.launchpad.net/ubuntu/+source/postfix/+bug/1531299 +--- + fuel_agent/manager.py | 14 ++++++++++++++ + fuel_agent/utils/build.py | 24 ++++++++++++++++++++++++ + 2 files changed, 38 insertions(+) + +diff --git a/fuel_agent/manager.py b/fuel_agent/manager.py +index 6322a10..843c40b 100644 +--- a/fuel_agent/manager.py ++++ b/fuel_agent/manager.py +@@ -836,10 +836,15 @@ class Manager(object): + direct_repo_addrs=driver_os.proxies.direct_repo_addr_list) + self._update_metadata_with_repos( + metadata, driver_os.repos) ++ # Prevent common cross-debootstraping problem w/ newaliases & qemu ++ # inet_addr_local[getifaddrs]: getifaddrs: Address family not supp ++ LOG.debug('Preventing newaliases from running inside chroot') ++ bu.prevent_qemu_newaliases(chroot) + LOG.debug('Installing packages using apt-get: %s', + ' '.join(packages)) + # disable hosts/resolv files + bu.propagate_host_resolv_conf(chroot) ++ + if hasattr(bs_scheme, 'certs') and bs_scheme.certs: + bu.copy_update_certs(bs_scheme.certs, chroot) + bu.run_apt_get(chroot, packages=packages, +@@ -873,6 +878,7 @@ class Manager(object): + force_ipv4_file=CONF.force_ipv4_file) + # restore disabled hosts/resolv files + bu.restore_resolv_conf(chroot) ++ bu.restore_newaliases(chroot) + metadata['all_packages'] = bu.get_installed_packages(chroot) + # We need to recompress initramfs with new compression: + bu.recompress_initramfs( +@@ -964,6 +970,11 @@ class Manager(object): + self._update_metadata_with_repos( + metadata, driver_os.repos) + ++ # Prevent common cross-debootstraping problem w/ newaliases & qemu ++ # inet_addr_local[getifaddrs]: getifaddrs: Address family not supp ++ LOG.debug('Preventing newaliases from running inside chroot') ++ bu.prevent_qemu_newaliases(chroot) ++ + LOG.debug('Installing packages using apt-get: %s', + ' '.join(packages)) + bu.run_apt_get(chroot, packages=packages, +@@ -974,6 +985,9 @@ class Manager(object): + allow_unsigned_file=CONF.allow_unsigned_file, + force_ipv4_file=CONF.force_ipv4_file) + ++ LOG.debug('Restoring newaliases command inside chroot') ++ bu.restore_newaliases(chroot) ++ + LOG.debug('Making sure there are no running processes ' + 'inside chroot before trying to umount chroot') + if not bu.stop_chrooted_processes(chroot, signal=signal.SIGTERM): +diff --git a/fuel_agent/utils/build.py b/fuel_agent/utils/build.py +index abd762e..e11ceba 100644 +--- a/fuel_agent/utils/build.py ++++ b/fuel_agent/utils/build.py +@@ -331,6 +331,30 @@ def prevent_qemu_replacement(chroot, arch): + utils.execute('chroot', chroot, 'ln', '-sf', '/bin/true', + '/usr/sbin/update-binfmts') + ++def prevent_qemu_newaliases(chroot): ++ """Prevents running newaliases under qemu-user-static inside chroot. ++ ++ Use dpkg-divert to prevent running newaliases binary through qemu inside ++ chroot which is necessary to avoid a dpkg --configure error: ++ inet_addr_local[getifaddrs]: getifaddrs: Address family not supported ... ++ """ ++ utils.execute('chroot', chroot, ++ 'dpkg-divert', '--local', '--rename', '--add', ++ '/usr/bin/newaliases') ++ utils.execute('chroot', chroot, 'ln', '-sf', '/bin/true', ++ '/usr/bin/newaliases') ++ ++def restore_newaliases(chroot): ++ """Restores newaliases inside chroot after previous dpkg-divert. ++ ++ opposite to prevent_qemu_newaliases ++ """ ++ utils.execute('chroot', chroot, ++ 'rm', '-f', '/usr/bin/newaliases') ++ utils.execute('chroot', chroot, ++ 'dpkg-divert', '--local', '--rename', '--remove', ++ '/usr/bin/newaliases') ++ + def create_sparse_tmp_file(dir, suffix, size=8192): + """Creates sparse file. + +-- +1.9.1 + diff --git a/patches/fuel-agent/0005-FIXME-s-grub-pc-grub-efi-arm64.patch b/patches/fuel-agent/0005-FIXME-s-grub-pc-grub-efi-arm64.patch new file mode 100644 index 00000000..59fe0180 --- /dev/null +++ b/patches/fuel-agent/0005-FIXME-s-grub-pc-grub-efi-arm64.patch @@ -0,0 +1,31 @@ +From: Alexandru Avadanii <Alexandru.Avadanii@enea.com> +Date: Tue, 8 Mar 2016 01:06:56 +0100 +Subject: [PATCH] FIXME: s/grub-pc/grub-efi-arm64/ + +This hard replaced the previously hardcoded grub-pc req. + +Fuel 9.0 moved default package list to openstack.yaml fixture, see [1]. +TODO: At least make this arch-dependant for mos8 ... + +[1] https://github.com/openstack/fuel-web/commit/ + 4ee42effe27694bd231663e3d0f10c0c42877177 +--- + fuel_agent/drivers/nailgun.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/fuel_agent/drivers/nailgun.py b/fuel_agent/drivers/nailgun.py +index c2fef69..3807ca7 100644 +--- a/fuel_agent/drivers/nailgun.py ++++ b/fuel_agent/drivers/nailgun.py +@@ -684,7 +684,7 @@ class NailgunBuildImage(BaseDataDriver): + "daemonize", + "debconf-utils", + "gdisk", +- "grub-pc", ++ "grub-efi-arm64", + "hpsa-dkms", + "i40e-dkms", + "linux-firmware", +-- +1.9.1 + diff --git a/patches/fuel-agent/0006-Add-esp-partition-flag.patch b/patches/fuel-agent/0006-Add-esp-partition-flag.patch new file mode 100644 index 00000000..e180468f --- /dev/null +++ b/patches/fuel-agent/0006-Add-esp-partition-flag.patch @@ -0,0 +1,51 @@ +From: Alexandru Avadanii <Alexandru.Avadanii@enea.com> +Date: Tue, 8 Mar 2016 16:29:39 +0100 +Subject: [PATCH] Add <esp> partition flag. + +Parted flag <esp> (see [1]) will mark EFI system partition, allowing us +to properly format and mount it during do_partitioning deployment phase. + +[1] https://www.gnu.org/software/parted/manual/html_node/set.html +--- + fuel_agent/drivers/nailgun.py | 2 +- + fuel_agent/utils/partition.py | 4 ++-- + 2 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/fuel_agent/drivers/nailgun.py b/fuel_agent/drivers/nailgun.py +index 3807ca7..bc532b4 100644 +--- a/fuel_agent/drivers/nailgun.py ++++ b/fuel_agent/drivers/nailgun.py +@@ -324,7 +324,7 @@ class Nailgun(BaseDataDriver): + # uefi partition (for future use) + LOG.debug('Adding UEFI partition on disk %s: size=200' % + disk['name']) +- parted.add_partition(size=200) ++ parted.add_partition(size=200, flags=['esp']) + + LOG.debug('Looping over all volumes on disk %s' % disk['name']) + for volume in disk['volumes']: +diff --git a/fuel_agent/utils/partition.py b/fuel_agent/utils/partition.py +index acdd0b3..86349d2 100644 +--- a/fuel_agent/utils/partition.py ++++ b/fuel_agent/utils/partition.py +@@ -93,7 +93,7 @@ def set_partition_flag(dev, num, flag, state='on'): + :param dev: A device file, e.g. /dev/sda. + :param num: Partition number + :param flag: Flag name. Must be one of 'bios_grub', 'legacy_boot', +- 'boot', 'raid', 'lvm' ++ 'boot', 'raid', 'lvm', 'esp' + :param state: Desiable flag state. 'on' or 'off'. Default is 'on'. + + :returns: None +@@ -103,7 +103,7 @@ def set_partition_flag(dev, num, flag, state='on'): + # parted supports more flags but we are interested in + # setting only this subset of them. + # not all of these flags are compatible with one another. +- if flag not in ('bios_grub', 'legacy_boot', 'boot', 'raid', 'lvm'): ++ if flag not in ('bios_grub', 'legacy_boot', 'boot', 'raid', 'lvm', 'esp'): + raise errors.WrongPartitionSchemeError( + 'Unsupported partition flag: %s' % flag) + if state not in ('on', 'off'): +-- +1.9.1 + diff --git a/patches/fuel-agent/0007-Add-fs-for-efi-partition.patch b/patches/fuel-agent/0007-Add-fs-for-efi-partition.patch new file mode 100644 index 00000000..573ec133 --- /dev/null +++ b/patches/fuel-agent/0007-Add-fs-for-efi-partition.patch @@ -0,0 +1,52 @@ +From: Stanislaw Kardach <stanislaw.kardach@caviumnetworks.com> +Date: Tue, 8 Mar 2016 21:08:55 +0100 +Subject: [PATCH] Add fs for efi partition + +--- + debian/control | 1 + + fuel_agent/drivers/nailgun.py | 4 +++- + specs/fuel-agent.spec | 1 + + 3 files changed, 5 insertions(+), 1 deletion(-) + +diff --git a/debian/control b/debian/control +index 189dc00..acfda35 100644 +--- a/debian/control ++++ b/debian/control +@@ -39,6 +39,7 @@ Depends: bzip2, + qemu-user-static, + binfmt-support, + dmidecode, ++ dosfstools, + ethtool, + gdisk, + genisoimage, +diff --git a/fuel_agent/drivers/nailgun.py b/fuel_agent/drivers/nailgun.py +index bc532b4..24d0d64 100644 +--- a/fuel_agent/drivers/nailgun.py ++++ b/fuel_agent/drivers/nailgun.py +@@ -324,7 +324,9 @@ class Nailgun(BaseDataDriver): + # uefi partition (for future use) + LOG.debug('Adding UEFI partition on disk %s: size=200' % + disk['name']) +- parted.add_partition(size=200, flags=['esp']) ++ prt = parted.add_partition(size=200, flags=['esp']) ++ partition_scheme.add_fs(device=prt.name, mount='/boot/efi', ++ fs_type='vfat') + + LOG.debug('Looping over all volumes on disk %s' % disk['name']) + for volume in disk['volumes']: +diff --git a/specs/fuel-agent.spec b/specs/fuel-agent.spec +index a43f693..c2b9b51 100644 +--- a/specs/fuel-agent.spec ++++ b/specs/fuel-agent.spec +@@ -50,6 +50,7 @@ Requires: xfsprogs + Requires: pciutils + Requires: ethtool + Requires: debootstrap ++Requires: dosfstools + Requires: dpkg + Requires: qemu-user-static + Requires: xz +-- +1.9.1 + |