Skip to content

Commit

Permalink
revert all last changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Siarhei Harbuz committed Mar 11, 2024
1 parent 25547b4 commit c96b847
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 17 deletions.
41 changes: 24 additions & 17 deletions .buildkite/hooks/pre-command
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,27 @@

set -euo pipefail

source .buildkite/scripts/common.sh

AWS_SERVICE_ACCOUNT_SECRET_PATH="kv/ci-shared/platform-ingest/aws_account_auth"

retry() {
local retries=$1
shift
local count=0
until "$@"; do
exit=$?
wait=$((2 ** count))
count=$((count + 1))
if [ $count -lt "$retries" ]; then
>&2 echo "Retry $count/$retries exited $exit, retrying in $wait seconds..."
sleep $wait
else
>&2 echo "Retry $count/$retries exited $exit, no more retries left."
return $exit
fi
done
return 0
}

if [[ "$BUILDKITE_PIPELINE_SLUG" == "filebeat" || "$BUILDKITE_PIPELINE_SLUG" == "auditbeat" || "$BUILDKITE_PIPELINE_SLUG" == "heartbeat" ]]; then
source .buildkite/env-scripts/env.sh
source .buildkite/env-scripts/util.sh
Expand All @@ -24,19 +41,9 @@ if [[ "$BUILDKITE_PIPELINE_SLUG" == "beats-metricbeat" || "$BUILDKITE_PIPELINE_S
fi
fi

if [[ "$BUILDKITE_PIPELINE_SLUG" == "beats-xpack-metricbeat" ]]; then
if [[ "${BUILDKITE_STEP_KEY}" == "mandatory-int-test" || "${BUILDKITE_STEP_KEY}" == "mandatory-python-int-test" || "${BUILDKITE_STEP_KEY}" == "extended-cloud-test" ]]; then
# Configure MODULE env variable.
defineModuleFromTheChangeSet "${MODULE_DIR}"
fi
if [[ "${BUILDKITE_STEP_KEY}" == "extended-cloud-test" ]]; then
# Start the required services for the required
startCloudTestEnv "${MODULE_DIR}"

# export AWS masked credentials
BEATS_AWS_SECRET_KEY=$(retry 5 vault kv get -field secret_key ${AWS_SERVICE_ACCOUNT_SECRET_PATH})
export BEATS_AWS_SECRET_KEY
BEATS_AWS_ACCESS_KEY=$(retry 5 vault kv get -field access_key ${AWS_SERVICE_ACCOUNT_SECRET_PATH})
export BEATS_AWS_ACCESS_KEY
fi
if [[ "$BUILDKITE_PIPELINE_SLUG" == "beats-xpack-metricbeat" && "$BUILDKITE_STEP_KEY" == "extended-cloud-test" ]]; then
BEATS_AWS_SECRET_KEY=$(retry 5 vault kv get -field secret_key ${AWS_SERVICE_ACCOUNT_SECRET_PATH})
export BEATS_AWS_SECRET_KEY
BEATS_AWS_ACCESS_KEY=$(retry 5 vault kv get -field access_key ${AWS_SERVICE_ACCOUNT_SECRET_PATH})
export BEATS_AWS_ACCESS_KEY
fi
4 changes: 4 additions & 0 deletions .buildkite/scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -484,4 +484,8 @@ if are_paths_changed "${packaging_changeset[@]}" ; then
export PACKAGING_CHANGES="true"
fi

if [[ "$BUILDKITE_PIPELINE_SLUG" == "beats-xpack-metricbeat" ]]; then
defineModuleFromTheChangeSet "${MODULE_DIR}"
fi

check_and_set_beat_vars
4 changes: 4 additions & 0 deletions .buildkite/scripts/install_tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ with_dependencies
config_git
mage dumpVariables

if [[ "$BUILDKITE_PIPELINE_SLUG" == "beats-xpack-metricbeat" && "${BUILDKITE_STEP_KEY}" == "extended-cloud-test" ]]; then
startCloudTestEnv "${MODULE_DIR}"
fi

#sudo command doesn't work at the "pre-command" hook because of another user environment (root with strange permissions)
sudo chmod -R go-w "${BEATS_PROJECT_NAME}/" #TODO: Remove when the issue is solved https://github.com/elastic/beats/issues/37838

Expand Down

0 comments on commit c96b847

Please sign in to comment.