ci: fix image deploy (#4953)

The Influx deployment pipeline was changed so the an image push is used
as a signal for deployment (instead of a magic script that was used
before). So we need to adopt our CI to only push images when all tests
pass.

Old workflow:
- build release: builds docker images and push commit-based tags to
  registry
- deploy release: pulls built images from registry, adds+pushes branch
  tags, calls magic deploy script

New workflow:
- build release: builds docker image, saves them to disk
- deploy release: load image files, tags them, pushes tags

You may wonder why there are two steps if we could just use a single
one. The reason is: time-to-deploy. We can already build the image while we
are waiting for the tests. If the tests fail, the image will just not be
published.

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
pull/24376/head
Marco Neumann 2022-06-28 09:48:41 +02:00 committed by GitHub
parent bfddb032ce
commit 2ebb7b195b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 16 deletions

View File

@ -420,8 +420,6 @@ jobs:
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
steps:
- checkout
- run: |
echo "$QUAY_INFLUXDB_IOX_PASS" | docker login quay.io --username $QUAY_INFLUXDB_IOX_USER --password-stdin
- run:
name: Cargo release build with target arch set for CRoaring
command: |
@ -447,10 +445,17 @@ jobs:
docker run -it --rm quay.io/influxdb/iox:$COMMIT_SHA debug print-cpu
docker push quay.io/influxdb/iox:"$COMMIT_SHA"
docker push quay.io/influxdb/iox_data_generator:"$COMMIT_SHA"
mkdir /tmp/images
docker save quay.io/influxdb/iox:"$COMMIT_SHA" | gzip > /tmp/iox.tar.gz
docker save quay.io/influxdb/iox_data_generator:"$COMMIT_SHA" | gzip > /tmp/iox_data_generator.tar.gz
# linking might take a while and doesn't produce CLI output
no_output_timeout: 30m
- store_artifacts:
path: /tmp/images
- persist_to_workspace:
root: /tmp/images
paths:
- '*.tar.gz'
- cache_save
deploy_release:
@ -461,30 +466,29 @@ jobs:
version: 19.03.13
docker_layer_caching: true
- checkout
- run: |
echo "$QUAY_INFLUXDB_IOX_PASS" | docker login quay.io --username $QUAY_INFLUXDB_IOX_USER --password-stdin
- attach_workspace:
at: /tmp/images
- run:
name: Update docker branch tags
name: quay login
command: |
echo "$QUAY_INFLUXDB_IOX_PASS" | docker login quay.io --username $QUAY_INFLUXDB_IOX_USER --password-stdin
- run:
name: Upload images
command: |
COMMIT_SHA="$(git rev-parse --short HEAD)"
BRANCH="$(echo "$CIRCLE_BRANCH" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/_/g')"
docker pull quay.io/influxdb/iox:"$COMMIT_SHA"
docker pull quay.io/influxdb/iox_data_generator:"$COMMIT_SHA"
docker load -i /tmp/iox.tar.gz
docker load -i /tmp/iox_data_generator.tar.gz
docker tag quay.io/influxdb/iox:"$COMMIT_SHA" quay.io/influxdb/iox:"$BRANCH"
docker tag quay.io/influxdb/iox_data_generator:"$COMMIT_SHA" quay.io/influxdb/iox_data_generator:"$BRANCH"
docker push quay.io/influxdb/iox:"$COMMIT_SHA"
docker push quay.io/influxdb/iox_data_generator:"$COMMIT_SHA"
docker push quay.io/influxdb/iox:"$BRANCH"
docker push quay.io/influxdb/iox_data_generator:"$BRANCH"
echo "export COMMIT_SHA=${COMMIT_SHA}" >> $BASH_ENV
- run:
name: Deploy tags
command: |
echo "$QUAY_PASS" | docker login quay.io --username $QUAY_USER --password-stdin
./.circleci/get-deploy-tags.sh "${COMMIT_SHA}"
# Prepare the CI image used for other tasks.
#
# A nightly job (scheduled below in the `workflows` section) to build the CI