From 3974a4e479c5ca65aabfde0343dc399e3c68bea4 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Wed, 9 May 2018 15:48:12 -0700 Subject: [PATCH] Adjust the disk size estimates to match Anaconda First is Anaconda uses 6k blocks per file for its estimate, and it fudges by 10% so adjust for those with an extra 10% of headroom just in case. Second is an Anaconda bug that won't allow it to do a kickstart install to a disk smaller than 3000 MB. There is a PR to fix it upstream, but for now the minimum size has to be 3000e9 --- src/pylorax/api/compose.py | 10 ++++++---- src/pylorax/api/projects.py | 2 +- src/pylorax/installer.py | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/pylorax/api/compose.py b/src/pylorax/api/compose.py index 171651c9..87fea690 100644 --- a/src/pylorax/api/compose.py +++ b/src/pylorax/api/compose.py @@ -44,7 +44,7 @@ from pyanaconda.simpleconfig import SimpleConfigFile # Use pykickstart to calculate disk image size from pykickstart.parser import KickstartParser -from pykickstart.version import makeVersion, RHEL7 +from pykickstart.version import makeVersion from pylorax.api.projects import projects_depsolve_with_size, dep_nevra from pylorax.api.projects import ProjectsError @@ -239,7 +239,7 @@ def start_build(cfg, dnflock, gitlock, branch, recipe_name, compose_type, test_m ks_template = open(ks_template_path, "r").read() # How much space will the packages in the default template take? - ks_version = makeVersion(RHEL7) + ks_version = makeVersion() ks = KickstartParser(ks_version, errorsAreFatal=False, missingIncludeIsFatal=False) ks.readKickstartFromString(ks_template+"\n%end\n") try: @@ -251,8 +251,10 @@ def start_build(cfg, dnflock, gitlock, branch, recipe_name, compose_type, test_m raise RuntimeError("Problem depsolving %s: %s" % (recipe["name"], str(e))) log.debug("installed_size = %d, template_size=%d", installed_size, template_size) - # Minimum LMC disk size is 1GiB, and anaconda bumps the estimated size up by 35% (which doesn't always work). - installed_size = max(1024**3, int((installed_size+template_size) * 1.4)) + # Minimum LMC disk size is 1GiB, and anaconda bumps the estimated size up by 10% (which doesn't always work). + # XXX BUT Anaconda has a bug, it won't execute a kickstart on a disk smaller than 3000 MB + # XXX There is an upstream patch pending, but until then, use that as the minimum + installed_size = max(3e9, int((installed_size+template_size))) * 1.2 log.debug("/ partition size = %d", installed_size) # Create the results directory diff --git a/src/pylorax/api/projects.py b/src/pylorax/api/projects.py index 862b7bb0..80ca351b 100644 --- a/src/pylorax/api/projects.py +++ b/src/pylorax/api/projects.py @@ -209,7 +209,7 @@ def projects_depsolve(dbo, project_names): return sorted(map(pkg_to_dep, dbo.transaction.install_set), key=lambda p: p["name"].lower()) -def estimate_size(packages, block_size=4096): +def estimate_size(packages, block_size=6144): """Estimate the installed size of a package list :param packages: The packages to be installed diff --git a/src/pylorax/installer.py b/src/pylorax/installer.py index 1b7d305e..45ec8af9 100644 --- a/src/pylorax/installer.py +++ b/src/pylorax/installer.py @@ -333,7 +333,7 @@ def novirt_install(opts, disk_img, disk_size): if os.path.isdir(path): shutil.rmtree(path) - args = ["--kickstart", opts.ks[0], "--cmdline"] + args = ["--kickstart", opts.ks[0], "--cmdline", "--loglevel", "debug"] if opts.anaconda_args: for arg in opts.anaconda_args: args += arg.split(" ", 1)