Skip to content

Include GITALY_SERVER_VERSION in cache prefix

What does this MR do and why?

Closes gitlab-org/quality/engineering-productivity/master-broken-incidents#45 (closed) Closes #381244 (closed)

Fix for gitlab-org/quality/engineering-productivity/master-broken-incidents#45 (closed) (this comment in particular):

qmnguyen0711 has found out that this is very likely a caching issue. We have never in fact updated the GITALY_SERVER_VERSION file in the Rails project to contain the changed Gitaly code that causes the breakage. But the Gitaly binaries cache did contain the changed code regardless, which indicates that the cache is reused improperly.

Given that the Gitaly binary cache is already keyed by the GITALY_SERVER_VERSION file it should always be invalidated whenever the version changes. This means that something else must be going on. And to the best of my knowledge it is possible to override the file via a GITALY_SERVER_VERSION CI variable. So while we continue to be keyed by the on-disk file, it's in fact not payed any attention to but overridden by that variable. Which means that the cache key is wrong and may thus lead to invalid cache reuse.

We should likely take the CI variable into account for the cache key to fix this problem:

diff --git a/.gitlab/ci/global.gitlab-ci.yml b/.gitlab/ci/global.gitlab-ci.yml
index c4cd6cb611d6..3ea90d980160 100644
--- a/.gitlab/ci/global.gitlab-ci.yml
+++ b/.gitlab/ci/global.gitlab-ci.yml
@@ -46,7 +46,7 @@
     files:
       - GITALY_SERVER_VERSION
       - lib/gitlab/setup_helper.rb
-    prefix: "gitaly-binaries-debian-${DEBIAN_VERSION}-ruby-${RUBY_VERSION}"
+    prefix: "gitaly-binaries-${GITALY_SERVER_VERSION}-debian-${DEBIAN_VERSION}-ruby-${RUBY_VERSION}"
   paths:
     - ${TMP_TEST_FOLDER}/gitaly/_build/bin/
     - ${TMP_TEST_FOLDER}/gitaly/_build/deps/git/install/

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by David Dieulivol

Merge request reports