From a9e931f08eb29d01840921b23cf62e54dbc59f65 Mon Sep 17 00:00:00 2001 From: Jiri Kyjovsky Date: Mon, 9 Sep 2024 16:41:16 +0200 Subject: [PATCH] rpmbuilds: dynamically specify tmp_fs size This moves specifying tmp fs size to rpmbuild from [1] in order to be able to automatically generate its size for performance builders. [1] - https://pagure.io/fedora-infra/ansible/blob/main/f/roles/copr/backend/files/provision/files/mock/site-defaults.cfg#_18 See #3268 --- rpmbuild/copr_rpmbuild/builders/mock.py | 5 +++++ rpmbuild/copr_rpmbuild/providers/base.py | 6 +++++- rpmbuild/copr_rpmbuild/providers/custom.py | 1 + rpmbuild/mock-custom-build.cfg.j2 | 1 + rpmbuild/mock.cfg.j2 | 1 + 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/rpmbuild/copr_rpmbuild/builders/mock.py b/rpmbuild/copr_rpmbuild/builders/mock.py index b3cc31461..4204c1796 100644 --- a/rpmbuild/copr_rpmbuild/builders/mock.py +++ b/rpmbuild/copr_rpmbuild/builders/mock.py @@ -42,6 +42,10 @@ def __init__(self, task, sourcedir, resultdir, config): self.macros = macros_for_task(task, config) self.uniqueext = get_mock_uniqueext() self.allow_user_ssh = task.get("allow_user_ssh") + self.tags = task.get("tags", []) + self.max_fs_size = "140g" + if "on_demand_powerful" in self.tags: + self.max_fs_size = "280g" def run(self): open(self.logfile, 'w').close() # truncate logfile @@ -82,6 +86,7 @@ def render_config_template(self): copr_build_id=self.build_id, isolation=self.isolation, macros=self.macros, + max_fs_size=self.max_fs_size, ) def produce_srpm(self, spec, sources, resultdir): diff --git a/rpmbuild/copr_rpmbuild/providers/base.py b/rpmbuild/copr_rpmbuild/providers/base.py index 8250e4036..fdf062eaf 100644 --- a/rpmbuild/copr_rpmbuild/providers/base.py +++ b/rpmbuild/copr_rpmbuild/providers/base.py @@ -51,6 +51,10 @@ def __init__(self, source_dict, config, macros=None, task=None): if e.errno != errno.EEXIST: raise + self.max_fs_size = "140g" + if task is not None and "on_demand_powerful" in task.get("tags", []): + self.max_fs_size = "280g" + # Change home directory to workdir and create .rpmmacros there os.environ["HOME"] = self.workdir self.create_rpmmacros() @@ -130,7 +134,7 @@ def render_mock_config_template(self, template_name): """ jinja_env = Environment(loader=FileSystemLoader(CONF_DIRS)) template = jinja_env.get_template(template_name) - return template.render(macros=self.macros) + return template.render(macros=self.macros, max_fs_size=self.max_fs_size) def produce_srpm(self): """ diff --git a/rpmbuild/copr_rpmbuild/providers/custom.py b/rpmbuild/copr_rpmbuild/providers/custom.py index ce5469a62..95673dff2 100644 --- a/rpmbuild/copr_rpmbuild/providers/custom.py +++ b/rpmbuild/copr_rpmbuild/providers/custom.py @@ -51,6 +51,7 @@ def render_mock_config_template(self, *_args): chroot=self.chroot, repos=self.repos, macros=self.macros, + max_fs_size=self.max_fs_size, ) def produce_srpm(self): diff --git a/rpmbuild/mock-custom-build.cfg.j2 b/rpmbuild/mock-custom-build.cfg.j2 index c71e85609..aa8fb1ec0 100644 --- a/rpmbuild/mock-custom-build.cfg.j2 +++ b/rpmbuild/mock-custom-build.cfg.j2 @@ -15,6 +15,7 @@ config_opts["root"] = "copr-custom-" + config_opts["root"] # Important e.g. to keep '/script' file available across several # /bin/mock calls (when tmpfs_enable is on). config_opts['plugin_conf']['tmpfs_opts']['keep_mounted'] = True +config_opts['plugin_conf']['tmpfs_opts']['max_fs_size'] = '{{ max_fs_size }}' {%- for key, value in macros.items() %} config_opts['macros']['{{ key }}'] = '{{ value }}' diff --git a/rpmbuild/mock.cfg.j2 b/rpmbuild/mock.cfg.j2 index 25f3bbf19..f4bb7d9bc 100644 --- a/rpmbuild/mock.cfg.j2 +++ b/rpmbuild/mock.cfg.j2 @@ -3,6 +3,7 @@ include('/etc/mock/{{ chroot }}.cfg') config_opts.setdefault('plugin_conf', {}) config_opts['plugin_conf'].setdefault('tmpfs_opts', {}) config_opts['plugin_conf']['tmpfs_opts']['keep_mounted'] = True +config_opts['plugin_conf']['tmpfs_opts']['max_fs_size'] = '{{ max_fs_size }}' {% if buildroot_pkgs %} config_opts['chroot_additional_packages'] = '{{ buildroot_pkgs| join(" ") }}'