-
Couldn't load subscription status.
- Fork 128
Review buildkite scripts cleanup process #1487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f25127f
546e3ea
3b35cbf
c41d68c
75e3de3
bb92179
cc2dd51
e3329be
8ea365e
265ce2a
34c0375
006c194
d6f3908
3f7207e
26018f2
0e07078
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| #!/bin/bash | ||
|
|
||
| source .buildkite/scripts/tooling.sh | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| unset_secrets | ||
|
|
||
| # integrations-parallel-gcp | ||
| unset GOOGLE_CREDENTIALS | ||
| unset GCP_PROJECT_ID | ||
|
|
||
| # integrations-parallel-aws and intregrations-parallel-aws_logs | ||
| unset ELASTIC_PACKAGE_AWS_ACCESS_KEY | ||
| unset ELASTIC_PACKAGE_AWS_SECRET_KEY | ||
| unset AWS_ACCESS_KEY_ID | ||
| unset AWS_SECRET_ACCESS_KEY |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,10 +5,21 @@ WORKSPACE="$(pwd)" | |
| TMP_FOLDER_TEMPLATE_BASE="tmp.elastic-package" | ||
|
|
||
| cleanup() { | ||
| local error_code=$? | ||
|
|
||
| if [ $error_code != 0 ] ; then | ||
| # if variable is defined run the logout | ||
| if [ -n "${GOOGLE_APPLICATION_CREDENTIALS+x}" ]; then | ||
| google_cloud_logout_active_account | ||
| fi | ||
| fi | ||
|
|
||
| echo "Deleting temporal files..." | ||
| cd ${WORKSPACE} | ||
| rm -rf "${TMP_FOLDER_TEMPLATE_BASE}.*" | ||
| echo "Done." | ||
|
|
||
| exit $error_code | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
|
|
@@ -67,14 +78,12 @@ if [[ "${TARGET}" == "" ]]; then | |
| fi | ||
|
|
||
| google_cloud_auth_safe_logs() { | ||
| local gsUtilLocation=$(mktemp -d -p . -t ${TMP_FOLDER_TEMPLATE}) | ||
| local gsUtilLocation=$(mktemp -d -p ${WORKSPACE} -t ${TMP_FOLDER_TEMPLATE}) | ||
| local secretFileLocation=${gsUtilLocation}/${GOOGLE_CREDENTIALS_FILENAME} | ||
|
|
||
| echo "${PRIVATE_CI_GCS_CREDENTIALS_SECRET}" > ${secretFileLocation} | ||
|
|
||
| google_cloud_auth "${secretFileLocation}" | ||
|
|
||
| echo "${gsUtilLocation}" | ||
| } | ||
|
|
||
| upload_safe_logs() { | ||
|
|
@@ -87,12 +96,11 @@ upload_safe_logs() { | |
| return | ||
| fi | ||
|
|
||
| local gsUtilLocation=$(google_cloud_auth_safe_logs) | ||
| google_cloud_auth_safe_logs | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Calling this function as |
||
|
|
||
| gsutil cp ${source} "gs://${bucket}/buildkite/${REPO_BUILD_TAG}/${target}" | ||
|
|
||
| rm -rf "${gsUtilLocation}" | ||
| unset GOOGLE_APPLICATION_CREDENTIALS | ||
| google_cloud_logout_active_account | ||
| } | ||
|
|
||
| add_bin_path | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,10 +8,21 @@ source .buildkite/scripts/install_deps.sh | |
| source .buildkite/scripts/tooling.sh | ||
|
|
||
| cleanup() { | ||
| local error_code=$? | ||
|
|
||
| if [ $error_code != 0 ] ; then | ||
| # if variable is defined, run the logout | ||
| if [ -n "${GOOGLE_APPLICATION_CREDENTIALS+x}" ]; then | ||
| google_cloud_logout_active_account | ||
| fi | ||
| fi | ||
|
|
||
|
Comment on lines
+11
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps it's better to move the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wanted to avoid that in this PR at least, I added a comment about this in this other thread: |
||
| echo "Deleting temporal files..." | ||
| cd ${WORKSPACE} | ||
| rm -rf ${TMP_FOLDER_TEMPLATE_BASE}.* | ||
| echo "Done." | ||
|
|
||
| exit $error_code | ||
| } | ||
|
|
||
| trap cleanup EXIT | ||
|
|
@@ -55,32 +66,28 @@ PACKAGE_STORAGE_INTERNAL_BUCKET_QUEUE_PUBLISHING_PATH="gs://elastic-bekitzur-pac | |
|
|
||
|
|
||
| google_cloud_auth_signing() { | ||
| local gsUtilLocation=$(mktemp -d -p . -t ${TMP_FOLDER_TEMPLATE}) | ||
| local gsUtilLocation=$(mktemp -d -p ${WORKSPACE} -t ${TMP_FOLDER_TEMPLATE}) | ||
|
|
||
| local secretFileLocation=${gsUtilLocation}/${GOOGLE_CREDENTIALS_FILENAME} | ||
| echo "${SIGNING_PACKAGES_GCS_CREDENTIALS_SECRET}" > ${secretFileLocation} | ||
|
|
||
| google_cloud_auth "${secretFileLocation}" | ||
|
|
||
| echo "${gsUtilLocation}" | ||
| } | ||
|
|
||
| google_cloud_auth_publishing() { | ||
| local gsUtilLocation=$(mktemp -d -p . -t ${TMP_FOLDER_TEMPLATE}) | ||
| local gsUtilLocation=$(mktemp -d -p ${WORKSPACE} -t ${TMP_FOLDER_TEMPLATE}) | ||
|
|
||
| local secretFileLocation=${gsUtilLocation}/${GOOGLE_CREDENTIALS_FILENAME} | ||
| echo "${PACKAGE_UPLOADER_GCS_CREDENTIALS_SECRET}" > ${secretFileLocation} | ||
|
|
||
| google_cloud_auth "${secretFileLocation}" | ||
|
|
||
| echo "${gsUtilLocation}" | ||
| } | ||
|
|
||
| sign_package() { | ||
| local package=${1} | ||
| local packageZip=$(basename ${package}) | ||
|
|
||
| local gsUtilLocation=$(google_cloud_auth_signing) | ||
| google_cloud_auth_signing | ||
|
|
||
| # upload zip package (trailing forward slashes are required) | ||
| echo "Upload package .zip file for signing ${package} to ${INFRA_SIGNING_BUCKET_ARTIFACTS_PATH}" | ||
|
|
@@ -106,16 +113,15 @@ sign_package() { | |
|
|
||
| ls -l "${BUILD_PACKAGES_PATH}" | ||
|
|
||
| echo "Removing temporal location ${gsUtilLocation}" | ||
| rm -r "${gsUtilLocation}" | ||
| google_cloud_logout_active_account | ||
| } | ||
|
|
||
| publish_package() { | ||
| local package=$1 | ||
| local packageZip=$(basename ${package}) | ||
|
|
||
| # create file with credentials | ||
| local gsUtilLocation=$(google_cloud_auth_publishing) | ||
| google_cloud_auth_publishing | ||
|
|
||
| # upload files (trailing forward slashes are required) | ||
| echo "Upload package .zip file ${package} to ${PACKAGE_STORAGE_INTERNAL_BUCKET_QUEUE_PUBLISHING_PATH}" | ||
|
|
@@ -135,8 +141,7 @@ publish_package() { | |
|
|
||
| popd > /dev/null | ||
|
|
||
| echo "Removing temporal location ${gsUtilLocation}" | ||
| rm -r "${gsUtilLocation}" | ||
| google_cloud_logout_active_account | ||
| } | ||
|
|
||
| add_bin_path | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure that the temporal folder is created under WORKSPACE