mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[Ops] Fix kibana coverage copy (#176575)
## Summary My assumption was probably wrong about the access to the legacy coverage bucket. Any other account than the default Kibana CI gcloud account doesn't have write access to that bucket, so with the impersonation, the copy fails. This PR separates the copying to two parts, and localizes impersonations to the required operations not to be interfering with the legacy bucket accesses.
This commit is contained in:
parent
f07df418ec
commit
a90bd94ffc
5 changed files with 29 additions and 16 deletions
|
@ -25,5 +25,5 @@ steps:
|
|||
depends_on:
|
||||
- jest
|
||||
- jest-integration
|
||||
timeout_in_minutes: 30
|
||||
timeout_in_minutes: 50
|
||||
key: ingest
|
||||
|
|
|
@ -4,18 +4,18 @@ set -euo pipefail
|
|||
|
||||
source "$(dirname "${BASH_SOURCE[0]}")/vault_fns.sh"
|
||||
|
||||
BUCKET_OR_EMAIL="${1:-}"
|
||||
CALL_ARGUMENT="${1:-}"
|
||||
GCLOUD_EMAIL_POSTFIX="elastic-kibana-ci.iam.gserviceaccount.com"
|
||||
GCLOUD_SA_PROXY_EMAIL="kibana-ci-sa-proxy@$GCLOUD_EMAIL_POSTFIX"
|
||||
|
||||
if [[ -z "$BUCKET_OR_EMAIL" ]]; then
|
||||
if [[ -z "$CALL_ARGUMENT" ]]; then
|
||||
echo "Usage: $0 <bucket_name|email>"
|
||||
exit 1
|
||||
elif [[ "$BUCKET_OR_EMAIL" == "--unset-impersonation" ]]; then
|
||||
elif [[ "$CALL_ARGUMENT" == "--unset-impersonation" ]]; then
|
||||
echo "Unsetting impersonation"
|
||||
gcloud config unset auth/impersonate_service_account
|
||||
exit 0
|
||||
elif [[ "$BUCKET_OR_EMAIL" == "--logout-gcloud" ]]; then
|
||||
elif [[ "$CALL_ARGUMENT" == "--logout-gcloud" ]]; then
|
||||
echo "Logging out of gcloud"
|
||||
if [[ -x "$(command -v gcloud)" ]] && [[ "$(gcloud auth list 2>/dev/null | grep $GCLOUD_SA_PROXY_EMAIL)" != "" ]]; then
|
||||
gcloud auth revoke $GCLOUD_SA_PROXY_EMAIL --no-user-output-enabled
|
||||
|
@ -48,12 +48,12 @@ fi
|
|||
|
||||
# Check if the arg is a service account e-mail or a bucket name
|
||||
EMAIL=""
|
||||
if [[ "$BUCKET_OR_EMAIL" =~ ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$ ]]; then
|
||||
EMAIL="$BUCKET_OR_EMAIL"
|
||||
elif [[ "$BUCKET_OR_EMAIL" =~ ^gs://* ]]; then
|
||||
BUCKET_NAME="${BUCKET_OR_EMAIL:5}"
|
||||
if [[ "$CALL_ARGUMENT" =~ ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$ ]]; then
|
||||
EMAIL="$CALL_ARGUMENT"
|
||||
elif [[ "$CALL_ARGUMENT" =~ ^gs://* ]]; then
|
||||
BUCKET_NAME="${CALL_ARGUMENT:5}"
|
||||
else
|
||||
BUCKET_NAME="$BUCKET_OR_EMAIL"
|
||||
BUCKET_NAME="$CALL_ARGUMENT"
|
||||
fi
|
||||
|
||||
if [[ -z "$EMAIL" ]]; then
|
||||
|
|
|
@ -8,6 +8,7 @@ gsutil -m cp -r gs://elastic-bekitzur-kibana-coverage-live/previous_pointer/prev
|
|||
# TODO: Activate after the above is removed
|
||||
#.buildkite/scripts/common/activate_service_account.sh gs://elastic-kibana-coverage-live
|
||||
#gsutil -m cp -r gs://elastic-kibana-coverage-live/previous_pointer/previous.txt . || echo "### Previous Pointer NOT FOUND?"
|
||||
#.buildkite/scripts/common/activate_service_account.sh --unset-impersonation
|
||||
|
||||
if [ -e ./previous.txt ]; then
|
||||
mv previous.txt downloaded_previous.txt
|
||||
|
|
|
@ -14,3 +14,4 @@ gsutil cp previous.txt gs://elastic-bekitzur-kibana-coverage-live/previous_point
|
|||
|
||||
.buildkite/scripts/common/activate_service_account.sh gs://elastic-kibana-coverage-live
|
||||
gsutil cp previous.txt gs://elastic-kibana-coverage-live/previous_pointer/
|
||||
.buildkite/scripts/common/activate_service_account.sh --unset-impersonation
|
||||
|
|
|
@ -4,29 +4,40 @@ set -euo pipefail
|
|||
|
||||
xs=("$@")
|
||||
|
||||
# TODO: Safe to remove this after 2024-03-01 (https://github.com/elastic/kibana/issues/175904) - also clean up usages
|
||||
# TODO: Safe to remove this block after 2024-03-01 (https://github.com/elastic/kibana/issues/175904) - also clean up usages
|
||||
echo "--- Uploading static site (legacy)"
|
||||
uploadPrefix_old="gs://elastic-bekitzur-kibana-coverage-live/"
|
||||
uploadPrefixWithTimeStamp_old="${uploadPrefix_old}${TIME_STAMP}/"
|
||||
uploadBase_old() {
|
||||
for x in 'src/dev/code_coverage/www/index.html' 'src/dev/code_coverage/www/404.html'; do
|
||||
gsutil -m -q cp -r -a public-read -z js,css,html "${x}" "${uploadPrefix_old}"
|
||||
done
|
||||
}
|
||||
uploadRest_old() {
|
||||
for x in "${xs[@]}"; do
|
||||
gsutil -m -q cp -r -a public-read -z js,css,html "target/kibana-coverage/${x}-combined" "${uploadPrefixWithTimeStamp_old}"
|
||||
done
|
||||
}
|
||||
.buildkite/scripts/common/activate_service_account.sh --logout-gcloud
|
||||
uploadBase_old
|
||||
uploadRest_old
|
||||
|
||||
echo "--- Uploading static site"
|
||||
uploadPrefix="gs://elastic-kibana-coverage-live/"
|
||||
uploadPrefixWithTimeStamp="${uploadPrefix}${TIME_STAMP}/"
|
||||
|
||||
uploadBase() {
|
||||
for x in 'src/dev/code_coverage/www/index.html' 'src/dev/code_coverage/www/404.html'; do
|
||||
gsutil -m -q cp -r -z js,css,html "${x}" "${uploadPrefix}"
|
||||
gsutil -m -q cp -r -a public-read -z js,css,html "${x}" "${uploadPrefix_old}"
|
||||
done
|
||||
}
|
||||
|
||||
uploadRest() {
|
||||
for x in "${xs[@]}"; do
|
||||
gsutil -m -q cp -r -z js,css,html "target/kibana-coverage/${x}-combined" "${uploadPrefixWithTimeStamp}"
|
||||
gsutil -m -q cp -r -a public-read -z js,css,html "target/kibana-coverage/${x}-combined" "${uploadPrefixWithTimeStamp_old}"
|
||||
done
|
||||
}
|
||||
|
||||
echo "--- Uploading static site"
|
||||
|
||||
.buildkite/scripts/common/activate_service_account.sh gs://elastic-kibana-coverage-live
|
||||
uploadBase
|
||||
uploadRest
|
||||
.buildkite/scripts/common/activate_service_account.sh --unset-impersonation
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue