aboutsummaryrefslogtreecommitdiff
path: root/kolla
diff options
context:
space:
mode:
authorMichal Nasiadka <mnasiadka@gmail.com>2026-06-18 17:16:08 +0200
committerMichal Nasiadka <mnasiadka@gmail.com>2026-06-24 15:00:26 +0200
commita1a3fdc1b54baf62f234ddc9dac4906e30eb5d11 (patch)
treea4f88789a9ac039db65f9491751c75ca59cebb74 /kolla
parenta437f0bd5f406bf1f82dfdf05c4dac16c02573ff (diff)
downloadkolla-a1a3fdc1b54baf62f234ddc9dac4906e30eb5d11.tar.gz
kolla-a1a3fdc1b54baf62f234ddc9dac4906e30eb5d11.zip
kolla-build: fix build-date LABEL invalidating Docker layer cache
The build-date label was rendered into a LABEL instruction on line 3 of every Dockerfile template, immediately after FROM. Because Docker invalidates the cache for a changed instruction and all subsequent layers, a date change caused a full rebuild of every image on each new calendar day, even when nothing else had changed. Fix this by removing build-date from the Dockerfile templates and applying it as a --label argument at build time via image.labels. Labels passed on the build command line are not part of the Dockerfile cache key, so the date is still recorded in the image metadata without affecting layer caching. Change-Id: I8ef0d85bab1a999a4d09f7cbf0c088ca00fdcf77 Signed-off-by: Michal Nasiadka <mnasiadka@gmail.com>
Diffstat (limited to 'kolla')
-rw-r--r--kolla/image/kolla_worker.py4
-rw-r--r--kolla/image/tasks.py1
-rw-r--r--kolla/tests/test_build.py2
3 files changed, 3 insertions, 4 deletions
diff --git a/kolla/image/kolla_worker.py b/kolla/image/kolla_worker.py
index b60f0558f..1c704d1cf 100644
--- a/kolla/image/kolla_worker.py
+++ b/kolla/image/kolla_worker.py
@@ -362,9 +362,6 @@ class KollaWorker(object):
for path in self.docker_build_paths:
template_name = "Dockerfile.j2"
image_name = path.split("/")[-1]
- ts = time.time()
- build_date = datetime.datetime.fromtimestamp(ts).strftime(
- '%Y%m%d')
values = {'base_distro': self.base,
'base_image': self.conf.base_image,
'base_distro_tag': self.base_tag,
@@ -390,7 +387,6 @@ class KollaWorker(object):
'users': self.get_users(),
'distro_package_manager': self.distro_package_manager,
'rpm_setup': self.rpm_setup,
- 'build_date': build_date,
'clean_package_cache': self.clean_package_cache,
'patches_path': self.patches_path}
env = jinja2.sandbox.SandboxedEnvironment(
diff --git a/kolla/image/tasks.py b/kolla/image/tasks.py
index 757197ef4..93ba91835 100644
--- a/kolla/image/tasks.py
+++ b/kolla/image/tasks.py
@@ -379,6 +379,7 @@ class BuildTask(EngineTask):
image.status = Status.BUILDING
image.start = datetime.datetime.now()
+ image.labels['build-date'] = image.start.strftime('%Y%m%d')
self.logger.info('Building started at %s' % image.start)
if image.source and 'source' in image.source:
diff --git a/kolla/tests/test_build.py b/kolla/tests/test_build.py
index e072860ab..e4e4d2839 100644
--- a/kolla/tests/test_build.py
+++ b/kolla/tests/test_build.py
@@ -82,6 +82,8 @@ class TasksTest(base.TestCase):
# Existing tests exercise the docker-py SDK path; disable BuildKit so
# they are not routed through _build_buildkit.
self.conf.set_override('buildkit', False)
+ # Mock build-date
+ self.build_kwargs['labels'] = {'build-date': mock.ANY}
@mock.patch.dict(os.environ, clear=True)
@mock.patch(engine_client)