Skip to content

Commit

Permalink
staging.kernelci.org: only restart API if there were changes
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
gctucker committed Aug 19, 2022
1 parent a6caad8 commit a1b346a
Showing 1 changed file with 26 additions and 14 deletions.
40 changes: 26 additions & 14 deletions staging.kernelci.org
Original file line number Diff line number Diff line change
Expand Up @@ -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 -
Expand Down

0 comments on commit a1b346a

Please sign in to comment.