Skip to content

Commit

Permalink
rpmbuilds: dynamically specify tmp_fs size
Browse files Browse the repository at this point in the history
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 fedora-copr#3268
  • Loading branch information
nikromen committed Sep 9, 2024
1 parent 2bdec45 commit a9e931f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions rpmbuild/copr_rpmbuild/builders/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
6 changes: 5 additions & 1 deletion rpmbuild/copr_rpmbuild/providers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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):
"""
Expand Down
1 change: 1 addition & 0 deletions rpmbuild/copr_rpmbuild/providers/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
1 change: 1 addition & 0 deletions rpmbuild/mock-custom-build.cfg.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}'
Expand Down
1 change: 1 addition & 0 deletions rpmbuild/mock.cfg.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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(" ") }}'
Expand Down

0 comments on commit a9e931f

Please sign in to comment.