When canceling but not appending to standard out, script does not cancel
Summary
after_script
runs when the canceling
status is sent over but the script
does not terminate.
Steps to reproduce
Setup the GitLab CI yaml configuration:
.gitlab-ci.yml
stages: # List of stages for jobs, and their order of execution
- build
- test
build-job: # This job runs in the build stage, which runs first.
stage: build
script:
- echo "Compiling the code..."
- echo "Compile complete."
unit-test-job: # This job runs in the test stage.
stage: test # It only starts when the job in the build stage completes successfully.
script:
- sleep 90
after_script: echo $CI_JOB_STATUS
Actual behavior
Run a pipeline and cancel within the first 10 seconds of the 90 second sleep. The after_script
runs but the script
will take another ~80 seconds finishing the work in the script
.
Expected behavior
Run a pipeline and cancel within the first 10 seconds of the 90 second sleep. The script
ends immediately and the after_script
runs.
Relevant logs and/or screenshots
job log
Running with gitlab-runner 16.10.0 (81ab07f6)
on Allisons-MBP.fios-router.home ti6Pqbzpa, system ID: s_4de5f54e6021
Resolving secrets
00:00
Preparing the "shell" executor
00:00
Using Shell (bash) executor...
Preparing environment
00:00
Running on Allisons-MBP.fios-router.home...
Getting source from Git repository
00:01
Fetching changes with git depth set to 20...
Reinitialized existing Git repository in /Users/allisonbrowne/builds/ti6Pqbzpa/0/root/test-canceling/.git/
Checking out fe566a4b as detached HEAD (ref is main)...
Skipping Git submodules setup
Executing "step_script" stage of the job script
01:30
$ sleep 90
Running after_script
00:00
Running after script...
$ echo $CI_JOB_STATUS
success
Job succeeded
Environment description
Used GitLab Runner version
gitlab/gdk/gitlab master ✔ 17h3m ⍉
▶ gitlab-runner -v
Version: HEAD-698b7cd
Git revision: 698b7cda
Git branch: HEAD--stable
GO version: go1.22.2
Built: 2024-04-11T09:07:30+00:00
OS/Arch: darwin/arm64
Pulled the latest bleeding-edge runner yesterday. Also tested this in a staging project and saw the same issue.
https://zoom.us/clips/share/rkBw9KqsGEvmBWo3RIjGrOVkhFG-KIMoz8qe8AnDZhNrouBUIP4Hn1RbCseHY73ILPZjaA4fNnHAgqqMUKxE7j5U.R93uml70e35-cvWI Passcode: =1G5K8P7
https://zoom.us/clips/share/bqs1hbq4fGUKA1TTC5Ck41oFX4_wSix3qMXWVylHHIcTgLztc0oYXaqEQYbYQvZ-ynrJ669CjfU9aRjuukv_tuga.zWzJuZoD5511EE0C Passcode: G*+1&zn6
Possible fixes
Send the Job-Status
header on the update endpoint.