From 808d3151ad0e45755982c6e49c898c5408c03d11 Mon Sep 17 00:00:00 2001
From: Kristian Klausen <kristian@klausen.dk>
Date: Fri, 22 Jul 2022 17:55:15 +0200
Subject: [PATCH] gitlab_runner: Replace artifact workaround with better
 upstream solution

Upstream now provides a solution for setting the "staging dir" for
fastzip[1].

[1] https://gitlab.com/gitlab-org/gitlab-runner/-/merge_requests/3130
---
 roles/gitlab_runner/files/libvirt-executor   | 7 +------
 roles/gitlab_runner/templates/config.toml.j2 | 1 +
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/roles/gitlab_runner/files/libvirt-executor b/roles/gitlab_runner/files/libvirt-executor
index f7fbec967..d30f37a8a 100755
--- a/roles/gitlab_runner/files/libvirt-executor
+++ b/roles/gitlab_runner/files/libvirt-executor
@@ -129,12 +129,7 @@ prepare() {
 run() {
   vm_name="$(get_vm_name)"
   wait_for_ssh "${vm_name}"
-  # Upstream issue: https://gitlab.com/gitlab-org/gitlab-runner/-/issues/28189
-  if [[ "${2}" == *'_artifacts'* ]]; then
-    ssh 'TMPDIR=/var/tmp bash' < "${1}" || exit "${BUILD_FAILURE_EXIT_CODE:-1}"
-  else
-    ssh bash < "${1}" || exit "${BUILD_FAILURE_EXIT_CODE:-1}"
-  fi
+  ssh bash < "${1}" || exit "${BUILD_FAILURE_EXIT_CODE:-1}"
 }
 
 # https://docs.gitlab.com/runner/executors/custom.html#cleanup
diff --git a/roles/gitlab_runner/templates/config.toml.j2 b/roles/gitlab_runner/templates/config.toml.j2
index abe606213..57dba9dfa 100644
--- a/roles/gitlab_runner/templates/config.toml.j2
+++ b/roles/gitlab_runner/templates/config.toml.j2
@@ -33,6 +33,7 @@ listen_address = ":9252"
   builds_dir = "/builds"
   cache_dir = "/cache"
   limit = {{ (ansible_memtotal_mb * 0.9 / 1024) | round | int }}
+  environment = ["ARCHIVER_STAGING_DIR=/var/tmp"]
   [runners.custom]
     prepare_exec = "/usr/local/bin/libvirt-executor"
     prepare_args = [ "prepare" ]
-- 
GitLab