From e867e0fc9b28d0bb033a5680791ebdc71b9e44d2 Mon Sep 17 00:00:00 2001 From: Eric Frias Date: Fri, 19 Dec 2025 16:32:15 -0500 Subject: [PATCH 1/3] Switch to fetch strategy with full clone for reduced GitLab load --- .gitlab-ci.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0f7ff585f..66a22341c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,6 +12,15 @@ variables: DOCKER_BUILDER_TAG: "$CI_COMMON_JOB_VERSION" DOCKER_DIND_TAG: "$CI_COMMON_JOB_VERSION" IMAGE_REMOVER_TAG: "$CI_COMMON_JOB_VERSION" + # Git configuration + # Fetch strategy reuses workspace between jobs, reducing GitLab server load. + # Full clone (depth 0) enables efficient incremental fetches - shallow clones + # don't reduce server CPU and make fetch less effective. + GIT_STRATEGY: fetch + GIT_DEPTH: 0 + # Temporary: separate clone path prevents clone-strategy jobs from erasing + # fetch workspaces during transition. Remove once all projects use fetch. + GIT_CLONE_PATH: $CI_BUILDS_DIR/fetch/$CI_RUNNER_SHORT_TOKEN/$CI_CONCURRENT_ID/$CI_PROJECT_PATH include: - template: Workflows/Branch-Pipelines.gitlab-ci.yml -- GitLab From e488a83258668c14766617be1a5279466d48dcca Mon Sep 17 00:00:00 2001 From: Eric Frias Date: Sat, 20 Dec 2025 19:11:58 -0500 Subject: [PATCH 2/3] Add pre_get_sources_script hook for submodule corruption recovery Fix corrupt git state left by cancelled pipelines when using fetch strategy. The hook runs before git operations and cleans up corrupted submodules that would otherwise cause "Unable to find current revision" errors. See GitLab #296638, #4600 --- .gitlab-ci.yml | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 66a22341c..af8d6513f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -28,6 +28,56 @@ include: ref: d4e29410ea168096e1a822f77c7ce741d9cfb57a # develop file: "/templates/docker_image_jobs.gitlab-ci.yml" +default: + hooks: + pre_get_sources_script: + # Clean corrupt git state left by cancelled pipelines (see GitLab #296638, #4600) + # Wrapped in subshell to avoid changing working directory for subsequent git operations + - | + ( + cd "${CI_PROJECT_DIR:-/builds}" 2>/dev/null || exit 0 + echo "pre_get_sources: checking $(pwd) for corrupt git state" + if [ -d ".git" ]; then + # Remove stale lock files that block git operations + find .git -name "*.lock" -delete 2>/dev/null || true + + # Check if main repo is corrupt - if so, remove .git to force fresh clone + if ! git rev-parse HEAD >/dev/null 2>&1; then + echo "pre_get_sources: main repository corrupt, forcing fresh clone" + rm -rf .git + else + # Main repo OK - check and clean corrupt submodules + # Check both the working dir and .git/modules/ since either can be corrupt + if [ -f ".gitmodules" ]; then + git config --file .gitmodules --get-regexp path 2>/dev/null | awk '{print $2}' | while read submod; do + needs_clean=false + [ -z "$submod" ] && continue + # Check if submodule working directory exists but is corrupt + if [ -d "$submod" ] && [ -f "$submod/.git" ]; then + if ! git -C "$submod" rev-parse HEAD >/dev/null 2>&1; then + needs_clean=true + fi + fi + # Check if .git/modules exists but is corrupt (even if working dir is gone) + if [ -d ".git/modules/$submod" ]; then + if ! git --git-dir=".git/modules/$submod" rev-parse HEAD >/dev/null 2>&1; then + echo "pre_get_sources: $submod corrupt (rev-parse failed)" + needs_clean=true + fi + fi + if [ "$needs_clean" = true ]; then + echo "pre_get_sources: cleaning corrupt submodule: $submod" + rm -rf "$submod" ".git/modules/$submod" + fi + done + fi + echo "pre_get_sources: existing repo OK" + fi + else + echo "pre_get_sources: no .git directory (fresh workspace)" + fi + ) + docker-build: extends: .docker_image_builder_job_template stage: build -- GitLab From a80ea9279e3f994607294ec2ab3877000a68a63d Mon Sep 17 00:00:00 2001 From: Dan Notestein Date: Mon, 29 Dec 2025 23:28:24 -0500 Subject: [PATCH 3/3] Fix CI_COMMON_JOB_VERSION to use latest tag The commit SHA tag doesn't exist in the registry. Use 'latest' which is the tag published by common-ci-configuration on default branch builds. --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index af8d6513f..e0d51de8e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,7 +8,7 @@ stages: variables: # Variables required by Common CI jobs - CI_COMMON_JOB_VERSION: "d4e29410ea168096e1a822f77c7ce741d9cfb57a" + CI_COMMON_JOB_VERSION: "latest" DOCKER_BUILDER_TAG: "$CI_COMMON_JOB_VERSION" DOCKER_DIND_TAG: "$CI_COMMON_JOB_VERSION" IMAGE_REMOVER_TAG: "$CI_COMMON_JOB_VERSION" -- GitLab