From a1b346a677e85153caea447737fe8f60bf05ccb2 Mon Sep 17 00:00:00 2001 From: Guillaume Tucker Date: Fri, 19 Aug 2022 21:24:30 +0200 Subject: [PATCH] staging.kernelci.org: only restart API if there were changes Create a temporary local integration branch to look for a diff with the current staging branch, then only restart the API if there are changes. That way, the API services don't need to be restarted at every staging job and client scripts running elsewhere can remain connected. They will need to reopen their connections if the API is restarted, but that's typically because of API changes so client-side changes are most likely required too anyway. Signed-off-by: Guillaume Tucker --- staging.kernelci.org | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/staging.kernelci.org b/staging.kernelci.org index b7207d8..297be57 100755 --- a/staging.kernelci.org +++ b/staging.kernelci.org @@ -244,29 +244,41 @@ cmd_rotate_tree() { } cmd_api_pipeline() { - echo "Stopping containers" + echo "Stopping pipeline containers" cd checkout/kernelci-pipeline docker-compose down cd - - cd checkout/kernelci-api - docker-compose down - cd - - echo "Updating API branch" - ./pending.py kernelci-api --push + echo "Creating local staging branch in tmp directory while API is running" + mkdir -p tmp + pending_api="../pending.py --settings=../data/staging.ini kernelci-api" + (cd tmp; $pending_api) + + echo "Looking for diff with current staging branch" + if (cd tmp; $pending_api --diff-only); then + echo "Stopping API containers" + cd checkout/kernelci-api + docker-compose down + cd - + + echo "Updating API branch" + ./pending.py kernelci-api --push + + echo "Starting API containers" + cd checkout/kernelci-api + REQUIREMENTS=requirements-dev.txt docker-compose build + docker-compose up -d + cd - + else + echo "No API changes, leaving it running" + fi echo "Updating pipeline branch" ./pending.py kernelci-pipeline --push - echo "Restarting containers" - cd checkout/kernelci-api - REQUIREMENTS=requirements-dev.txt \ - docker-compose build - docker-compose up -d - cd - + echo "Starting pipeline containers" cd checkout/kernelci-pipeline - REQUIREMENTS=requirements-dev.txt \ - docker-compose build + REQUIREMENTS=requirements-dev.txt docker-compose build SETTINGS=/home/kernelci/config/staging.kernelci.org.conf \ docker-compose up -d cd -