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(" ") }}' diff --git a/rpmbuild/tests/test_mock.py b/rpmbuild/tests/test_mock.py index fe43e0bda..7c5915176 100644 --- a/rpmbuild/tests/test_mock.py +++ b/rpmbuild/tests/test_mock.py @@ -146,6 +146,7 @@ def test_mock_config(self, call, f_mock_calls): 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'] = '140g' config_opts['chroot_additional_packages'] = 'pkg1 pkg2 pkg3' @@ -164,6 +165,21 @@ def test_mock_config(self, call, f_mock_calls): """ # TODO: make the output nicer + @mock.patch("copr_rpmbuild.builders.mock.subprocess.call") + # pylint: disable-next=unused-argument, redefined-outer-name + def test_mock_config_hp_fs_size(self, call, f_mock_calls): + """ test that fs_size for performance builders is correctly set """ + self.task["tags"] = ["blabla_tag", "on_demand_powerful"] + MockBuilder(self.task, self.sourcedir, self.resultdir, + self.config).run() + + #config = open(self.child_config, 'r').readlines() + with open(self.child_config, "r", encoding="utf-8") as f: + config = f.readlines() + + config = ''.join(config) + assert "config_opts['plugin_conf']['tmpfs_opts']['max_fs_size'] = '280g'" in config + @mock.patch("copr_rpmbuild.builders.mock.MockBuilder.prepare_configs") @mock.patch("copr_rpmbuild.builders.mock.MockBuilder.archive_configs") def test_mock_options(self, archive_configs, prep_configs, f_mock_calls):