Skip to content

Commit

Permalink
composer: Add yum metadata size to size estimate
Browse files Browse the repository at this point in the history
anaconda also writes the repo metadata to the disk, so take that into
account when estimating the required size.

Resolves: rhbz#1761337
  • Loading branch information
Christophe Besson committed Oct 18, 2019
1 parent f2f0a28 commit df3de2e
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/pylorax/api/compose.py
Expand Up @@ -404,6 +404,20 @@ def start_build(cfg, yumlock, 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)

with yumlock.lock:
repos = yumlock.yb.repos.listEnabled()
if not repos:
raise RuntimeError("No enabled repos, canceling build.")

# Anaconda also stores the metadata on the disk once it is partitioned, try to take this into account
metadata_size = 0
for repo in repos:
metadata_size += repo._getRepoXML().length
metadata_size += int(repo._getRepoXML().getData("group").size)
metadata_size += int(repo._getRepoXML().getData("primary_db").size)
metadata_size += int(repo._getRepoXML().getData("updateinfo").size)
log.info("installed_size = %d, template_size=%d, metadata_size=%d", installed_size, template_size, metadata_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))
log.debug("/ partition size = %d", installed_size)
Expand Down Expand Up @@ -437,11 +451,6 @@ def start_build(cfg, yumlock, gitlock, branch, recipe_name, compose_type, test_m
# Save a copy of the original kickstart
shutil.copy(ks_template_path, results_dir)

with yumlock.lock:
repos = yumlock.yb.repos.listEnabled()
if not repos:
raise RuntimeError("No enabled repos, canceling build.")

# Create the final kickstart with repos and package list
ks_path = joinpaths(results_dir, "final-kickstart.ks")
with open(ks_path, "w") as f:
Expand Down

0 comments on commit df3de2e

Please sign in to comment.