From 0bf44407908787b1c13f92678f6c408491834b35 Mon Sep 17 00:00:00 2001 From: Gary Pennington Date: Fri, 15 Sep 2023 14:16:45 +0100 Subject: [PATCH] Check if docker images and helm charts exist before creating them (#3825) This improves the resilience of our pipeline. fixes: #3663 --- **Checklist** Complete the checklist (and note appropriate exceptions) before the PR is marked ready-for-review. - [x] Changes are compatible[^1] **Exceptions** *Note any exceptions here* **Notes** [^1]: It may be appropriate to bring upcoming changes to the attention of other (impacted) groups. Please endeavour to do this before seeking PR approval. The mechanism for doing this will vary considerably, so use your judgement as to how and when to do this. [^2]: Configuration is an important part of many changes. Where applicable please try to document configuration examples. [^3]: Tick whichever testing boxes are applicable. If you are adding Manual Tests, please document the manual testing (extensively) in the Exceptions. --- .changesets/maint_garypen_3663_no_overwrites.md | 5 +++++ .circleci/config.yml | 8 ++++++++ 2 files changed, 13 insertions(+) create mode 100644 .changesets/maint_garypen_3663_no_overwrites.md diff --git a/.changesets/maint_garypen_3663_no_overwrites.md b/.changesets/maint_garypen_3663_no_overwrites.md new file mode 100644 index 0000000000..1a155f7353 --- /dev/null +++ b/.changesets/maint_garypen_3663_no_overwrites.md @@ -0,0 +1,5 @@ +### Check if docker images and helm charts exist before creating them ([Issue #3663](https://github.com/apollographql/router/issues/3663)) + +This improves the resilience of our pipeline. + +By [@garypen](https://github.com/garypen) in https://github.com/apollographql/router/pull/3825 \ No newline at end of file diff --git a/.circleci/config.yml b/.circleci/config.yml index 840e33a254..63decfa09b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -761,6 +761,10 @@ jobs: docker buildx inspect --bootstrap # Note: GH Token owned by apollo-bot2, no expire echo ${GITHUB_OCI_TOKEN} | docker login ghcr.io -u apollo-bot2 --password-stdin + # To prevent overwrite, check to see if our images already exists + # If the manifest command succeeds, the images already exist + docker manifest inspect ${ROUTER_TAG}:${VERSION} > /dev/null && exit 1 + docker manifest inspect ${ROUTER_TAG}:${VERSION}-debug > /dev/null && exit 1 # Build and push debug image docker buildx build --platform linux/amd64,linux/arm64 --push --build-arg DEBUG_IMAGE="true" --build-arg ROUTER_RELEASE=${VERSION} -f dockerfiles/Dockerfile.router -t ${ROUTER_TAG}:${VERSION}-debug . # Build and push release image @@ -776,6 +780,10 @@ jobs: CHART=$(ls -t router*.tgz| head -1) # Note: GH Token owned by apollo-bot2, no expire echo ${GITHUB_OCI_TOKEN} | helm registry login -u apollo-bot2 --password-stdin ghcr.io + # To prevent overwrite, check to see if our chart already exists + # If the show all command succeeds, the chart already exists + VERSION=$(basename ${CHART} .tgz) + helm show all oci://ghcr.io/apollographql/helm-charts/router --version ${VERSION} > /dev/null && exit 1 # Push chart to repository helm push ${CHART} oci://ghcr.io/apollographql/helm-charts