From 1ff6edc05d0510a260afc7aa42fbc623eafa860e Mon Sep 17 00:00:00 2001 From: Peter Braun Date: Thu, 30 Jul 2026 13:43:47 +0200 Subject: [PATCH] fix: prefer scm_revision as the cache_id if available --- awx/main/models/projects.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/awx/main/models/projects.py b/awx/main/models/projects.py index e534ff2917..26084d9ce0 100644 --- a/awx/main/models/projects.py +++ b/awx/main/models/projects.py @@ -450,13 +450,14 @@ class Project(UnifiedJobTemplate, ProjectOptions, ResourceMixin, CustomVirtualEn @property def cache_id(self): - """This gives the folder name where collections and roles will be saved to so it does not re-download + # Prefer scm_revision as the cache key if available. This guarantees that project changes are tracked correctly + # even over multiple nodes. The scm_revision is a hex string and thus safe to be used as a directory name. + if self.scm_revision: + return self.scm_revision - Normally we want this to track with the last update, because every update should pull new content. - This does not count sync jobs, but sync jobs do not update last_job or current_job anyway. - If cleanup_jobs deletes the last jobs, then we can fallback to using any given heuristic related - to the last job ran. - """ + # If no scm_revision is available (e.g. non-scm projects), use these. current_job_id and last_job_id are global + # IDs in the database. This means that when a project sync runs on one node, all other nodes become outdated, + # resulting in unnecessary re-syncs. if self.current_job_id: return str(self.current_job_id) elif self.last_job_id: