mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-02-02 20:59:06 +08:00
MockModuleBuilder: manage timestamps on mock config files
The mod time for the mock configuration file is used to determine whether the root cache is out-of-date or not, so we want to avoid changing the configuration timestamps when we don't change content when we're just writing a per-thread mock configuration file again with no substantive changes. We do this by only updating the master mock.cfg file when we're actually adding content, and propagating its mod time to the per-thread configuration files.
This commit is contained in:
@@ -468,7 +468,7 @@ class MockModuleBuilder(GenericBuilder):
|
||||
self.enabled_modules = config_opts["module_enable"]
|
||||
self.releasever = config_opts["releasever"]
|
||||
|
||||
def _write_mock_config(self):
|
||||
def _write_mock_config(self, update_main=False):
|
||||
"""
|
||||
Writes Mock config file to local file.
|
||||
"""
|
||||
@@ -483,11 +483,15 @@ class MockModuleBuilder(GenericBuilder):
|
||||
config = config.replace("$enabled_modules", str(self.enabled_modules))
|
||||
config = config.replace("$releasever", str(self.releasever))
|
||||
|
||||
# We write the most recent config to "mock.cfg", so thread-related
|
||||
# configs can be later (re-)generated from it using _load_mock_config.
|
||||
outfile = os.path.join(self.configdir, "mock.cfg")
|
||||
with open(outfile, "w") as f:
|
||||
f.write(config)
|
||||
|
||||
mock_cfg_path = os.path.join(self.configdir, "mock.cfg")
|
||||
if update_main or not os.path.exists(mock_cfg_path):
|
||||
# We write a config to "mock.cfg", so thread-related
|
||||
# configs can be later (re-)generated from it using _load_mock_config.
|
||||
with open(mock_cfg_path, "w") as f:
|
||||
f.write(config)
|
||||
|
||||
mtime = os.path.getmtime(mock_cfg_path)
|
||||
|
||||
# Write the config to thread-related configuration file.
|
||||
outfile = os.path.join(
|
||||
@@ -495,6 +499,8 @@ class MockModuleBuilder(GenericBuilder):
|
||||
with open(outfile, "w") as f:
|
||||
f.write(config)
|
||||
|
||||
os.utime(outfile, (mtime, mtime))
|
||||
|
||||
def buildroot_connect(self, groups):
|
||||
self._load_mock_config()
|
||||
self.groups = list(set().union(groups["build"], self.groups))
|
||||
@@ -525,7 +531,7 @@ class MockModuleBuilder(GenericBuilder):
|
||||
if artifact and artifact.startswith("module-build-macros"):
|
||||
self._load_mock_config()
|
||||
self.groups.append("module-build-macros")
|
||||
self._write_mock_config()
|
||||
self._write_mock_config(update_main=True)
|
||||
|
||||
events.scheduler.add(repos_done_handler, ("fake_msg", self.tag_name + "-build"))
|
||||
|
||||
@@ -586,7 +592,7 @@ class MockModuleBuilder(GenericBuilder):
|
||||
baseurl = "file://" + repo_dir
|
||||
|
||||
self._add_repo(repo_name, baseurl)
|
||||
self._write_mock_config()
|
||||
self._write_mock_config(update_main=True)
|
||||
|
||||
def _send_build_change(self, state, source, build_id):
|
||||
from module_build_service.scheduler.handlers.components import (
|
||||
|
||||
Reference in New Issue
Block a user