From 76e31ccc617bc032effd3065391b6aec9b6ff8ab Mon Sep 17 00:00:00 2001
From: Jorge Camarero Vera <jorge.camarero@cern.ch>
Date: Fri, 7 Oct 2022 14:44:50 +0200
Subject: [PATCH] Resolve "CI runner randomly crashing in cta-tape-label"

---
 ReleaseNotes.md                                            | 2 ++
 continuousintegration/orchestration/tests/prepare_tests.sh | 6 ++++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/ReleaseNotes.md b/ReleaseNotes.md
index 2fc8747a30..6cef3b4ea2 100644
--- a/ReleaseNotes.md
+++ b/ReleaseNotes.md
@@ -5,6 +5,8 @@
 - cta/CTA#146 - Refactoring of operation tools cmd line parsing
 ### Building and Packaging
 - cta/CTA#107 - Check latest version of gtest suite
+### Bug fixes
+- cta/CTA#171 - CI runner randomly crashing in cta-tape-label
 
 # v4.7.12-1
 
diff --git a/continuousintegration/orchestration/tests/prepare_tests.sh b/continuousintegration/orchestration/tests/prepare_tests.sh
index d308178eb0..61739e1bc0 100755
--- a/continuousintegration/orchestration/tests/prepare_tests.sh
+++ b/continuousintegration/orchestration/tests/prepare_tests.sh
@@ -244,10 +244,12 @@ echo "Labeling tapes:"
   # add all tapes
   for ((i=0; i<${#TAPES[@]}; i++)); do
     VID=${TAPES[${i}]}
-    echo "  cta-tape-label --vid ${VID}"
+    echo "  cta-tape-label --vid ${VID} --force"
     # for debug use
       # kubectl --namespace ${NAMESPACE} exec tpsrv01 -c taped  -- cta-tape-label --vid ${VID} --debug
-    kubectl --namespace ${NAMESPACE} exec tpsrv01 -c taped  -- cta-tape-label --vid ${VID}
+    # The external tape format test leaves data inside of the tape, then the tapes for labeling are not empty between
+    # tests. That's why we need to force cta-tape-label, but only for CI testing.
+    kubectl --namespace ${NAMESPACE} exec tpsrv01 -c taped  -- cta-tape-label --vid ${VID} --force
     if [ $? -ne 0 ]; then
       echo "ERROR: failed to label the tape ${VID}"
       exit 1
-- 
GitLab