You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by as...@apache.org on 2021/05/18 09:48:21 UTC

[airflow-ci-infra] branch main updated: Don't kill Runner.Listener when steps running (#30)

This is an automated email from the ASF dual-hosted git repository.

ash pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow-ci-infra.git


The following commit(s) were added to refs/heads/main by this push:
     new c5c38ee  Don't kill Runner.Listener when steps running (#30)
c5c38ee is described below

commit c5c38ee6c8fd68708016c92dfadb1f9ce49fbf91
Author: Ash Berlin-Taylor <as...@firemirror.com>
AuthorDate: Tue May 18 10:48:09 2021 +0100

    Don't kill Runner.Listener when steps running (#30)
    
    Because of the `--once` flag we already pass to the deamon, _if_ there
    were any jobs running, then the main actions-runner deamon (the
    Runner.Listener process) will shut it self down once it's _actually_
    finished.
    
    So we want to avoid the `pkill Runner.Listener` in the case when a step
    was executing, as otherwise we will likely kill the deamon before it has
    a chance to complete the job/report back to GitHub/run the next step.
---
 github-runner-ami/packer/files/stop-runner-if-no-job.sh | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/github-runner-ami/packer/files/stop-runner-if-no-job.sh b/github-runner-ami/packer/files/stop-runner-if-no-job.sh
index cfa2a7f..de95860 100644
--- a/github-runner-ami/packer/files/stop-runner-if-no-job.sh
+++ b/github-runner-ami/packer/files/stop-runner-if-no-job.sh
@@ -31,13 +31,17 @@ if pgrep --ns $MAINPID -a Runner.Worker > /dev/null; then
     # Job running -- just wait for it to exit
     sleep 10
   done
+
+else
+  # If there were _no_ Workers running, ask the main process to stop. If there
+  # were Workers running, then Runner.Listener would stop automatically because
+  # of the `--once`
+  pkill --ns $MAINPID Runner.Listener || true
 fi
 
-# Request shutdown if it's still alive -- because we are in "stop" state it should not restart
-if pkill --ns $MAINPID Runner.Listener; then
   # Wait for it to shut down
-  echo "Waiting for main Runner.Listener process to stop"
-  while pgrep --ns $MAINPID -a Runner.Listener; do
-    sleep 5
-  done
+echo "Waiting for main Runner.Listener process to stop"
+while pgrep --ns $MAINPID -a Runner.Listener; do
+  sleep 5
+done
 fi