diff --git a/concourse/pipelines/template/bosh-precompile-pipeline.yml.erb b/concourse/pipelines/template/bosh-precompile-pipeline.yml.erb index cdd446d4..14c2f340 100644 --- a/concourse/pipelines/template/bosh-precompile-pipeline.yml.erb +++ b/concourse/pipelines/template/bosh-precompile-pipeline.yml.erb @@ -526,11 +526,27 @@ jobs: args: - -ec - | + set -o pipefail STEMCELL_INFO=$(bosh inspect-local-stemcell --json stemcell/*.tgz | jq '.Tables|.[0]|.Rows|.[0]') export STEMCELL_OS=$(echo ${STEMCELL_INFO} | jq -r '.["os"]') export STEMCELL_VERSION=$(echo ${STEMCELL_INFO} | jq -r '.["version"]') echo "Exporting ${RELEASE_NAME}/${RELEASE_VERSION} - ${STEMCELL_OS}/${STEMCELL_VERSION}" - bosh export-release "${RELEASE_NAME}/${RELEASE_VERSION}" "${STEMCELL_OS}/${STEMCELL_VERSION}" --dir=exported-release + TIMESTAMP=$(date +'%Y-%m-%d-%H-%M-%S') + if ! bosh export-release "${RELEASE_NAME}/${RELEASE_VERSION}" "${STEMCELL_OS}/${STEMCELL_VERSION}" --dir=exported-release --tty|tee exported-release/${RELEASE_NAME}-${RELEASE_VERSION}-${TIMESTAMP}.log;then + BLOBSTORE_ERROR_COUNT=$(grep "blobstore" exported-release/${RELEASE_NAME}-${RELEASE_VERSION}-${TIMESTAMP}.log |wc -l) + if [ $BLOBSTORE_ERROR_COUNT -gt 0 ];then + echo "COA - Blobstore error detected, cleaning deployment and release" + bosh delete-deployment --non-interactive + bosh delete-release ${RELEASE_NAME}/${RELEASE_VERSION} --non-interactive + else + echo "" # new line + echo "COA - No blobstore error detected, retry without cleaning." + fi + exit 1 + else + echo "" # new line + echo "COA - Bosh export-release successful" + fi params: BOSH_DEPLOYMENT: <%= release %>-deployment BOSH_ENVIRONMENT: ((bosh-target)) diff --git a/spec/scripts/generate-depls/fixtures/references/simple-depls-bosh-precompile-ref.yml b/spec/scripts/generate-depls/fixtures/references/simple-depls-bosh-precompile-ref.yml index ea6b411e..709ad281 100644 --- a/spec/scripts/generate-depls/fixtures/references/simple-depls-bosh-precompile-ref.yml +++ b/spec/scripts/generate-depls/fixtures/references/simple-depls-bosh-precompile-ref.yml @@ -339,11 +339,27 @@ jobs: args: - -ec - | + set -o pipefail STEMCELL_INFO=$(bosh inspect-local-stemcell --json stemcell/*.tgz | jq '.Tables|.[0]|.Rows|.[0]') export STEMCELL_OS=$(echo ${STEMCELL_INFO} | jq -r '.["os"]') export STEMCELL_VERSION=$(echo ${STEMCELL_INFO} | jq -r '.["version"]') echo "Exporting ${RELEASE_NAME}/${RELEASE_VERSION} - ${STEMCELL_OS}/${STEMCELL_VERSION}" - bosh export-release "${RELEASE_NAME}/${RELEASE_VERSION}" "${STEMCELL_OS}/${STEMCELL_VERSION}" --dir=exported-release + TIMESTAMP=$(date +'%Y-%m-%d-%H-%M-%S') + if ! bosh export-release "${RELEASE_NAME}/${RELEASE_VERSION}" "${STEMCELL_OS}/${STEMCELL_VERSION}" --dir=exported-release --tty|tee exported-release/${RELEASE_NAME}-${RELEASE_VERSION}-${TIMESTAMP}.log;then + BLOBSTORE_ERROR_COUNT=$(grep "blobstore" exported-release/${RELEASE_NAME}-${RELEASE_VERSION}-${TIMESTAMP}.log |wc -l) + if [ $BLOBSTORE_ERROR_COUNT -gt 0 ];then + echo "COA - Blobstore error detected, cleaning deployment and release" + bosh delete-deployment --non-interactive + bosh delete-release ${RELEASE_NAME}/${RELEASE_VERSION} --non-interactive + else + echo "" # new line + echo "COA - No blobstore error detected, retry without cleaning." + fi + exit 1 + else + echo "" # new line + echo "COA - Bosh export-release successful" + fi params: BOSH_DEPLOYMENT: ntp_boshrelease-deployment BOSH_ENVIRONMENT: ((bosh-target)) @@ -454,11 +470,27 @@ jobs: args: - -ec - | + set -o pipefail STEMCELL_INFO=$(bosh inspect-local-stemcell --json stemcell/*.tgz | jq '.Tables|.[0]|.Rows|.[0]') export STEMCELL_OS=$(echo ${STEMCELL_INFO} | jq -r '.["os"]') export STEMCELL_VERSION=$(echo ${STEMCELL_INFO} | jq -r '.["version"]') echo "Exporting ${RELEASE_NAME}/${RELEASE_VERSION} - ${STEMCELL_OS}/${STEMCELL_VERSION}" - bosh export-release "${RELEASE_NAME}/${RELEASE_VERSION}" "${STEMCELL_OS}/${STEMCELL_VERSION}" --dir=exported-release + TIMESTAMP=$(date +'%Y-%m-%d-%H-%M-%S') + if ! bosh export-release "${RELEASE_NAME}/${RELEASE_VERSION}" "${STEMCELL_OS}/${STEMCELL_VERSION}" --dir=exported-release --tty|tee exported-release/${RELEASE_NAME}-${RELEASE_VERSION}-${TIMESTAMP}.log;then + BLOBSTORE_ERROR_COUNT=$(grep "blobstore" exported-release/${RELEASE_NAME}-${RELEASE_VERSION}-${TIMESTAMP}.log |wc -l) + if [ $BLOBSTORE_ERROR_COUNT -gt 0 ];then + echo "COA - Blobstore error detected, cleaning deployment and release" + bosh delete-deployment --non-interactive + bosh delete-release ${RELEASE_NAME}/${RELEASE_VERSION} --non-interactive + else + echo "" # new line + echo "COA - No blobstore error detected, retry without cleaning." + fi + exit 1 + else + echo "" # new line + echo "COA - Bosh export-release successful" + fi params: BOSH_DEPLOYMENT: zookeeper_boshrelease-deployment BOSH_ENVIRONMENT: ((bosh-target))