-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #850 from Mirantis/ivan4th/add-circle-dump
Add CircleCI dump script [ci skip]
- Loading branch information
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/bash | ||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
set -o errtrace | ||
|
||
DIND_SCRIPT="${DIND_SCRIPT:-$HOME/dind-cluster-v1.12.sh}" | ||
circle_token_file="$HOME/.circle-token" | ||
|
||
job_num="${1:-}" | ||
if [[ ! ${job_num} ]]; then | ||
echo >&2 "Usage: ${0} job_number" | ||
echo >&2 | ||
echo >&2 "You need to have kubeadm-dind-cluster script pointed" | ||
echo >&2 "to by DIND_SCRIPT environment variable" | ||
echo >&2 "(defaults to ${DIND_SCRIPT})." | ||
echo >&2 "Besides, you need to specify your CircleCI token via" | ||
echo >&2 "CIRCLE_TOKEN environment variable or have it stored" | ||
echo >&2 "using base64 encoding in ${circle_token_file}." | ||
exit 1 | ||
fi | ||
|
||
if [[ ! ${CIRCLE_TOKEN:-} && ! -e ${circle_token_file} ]]; then | ||
echo >&2 "You need to specify CIRCLE_TOKEN or store base64-encoded CircleCI token in ${circle_token_file}" | ||
exit 1 | ||
fi | ||
|
||
CIRCLE_TOKEN="${CIRCLE_TOKEN:-"$(base64 --decode "${circle_token_file}")"}" | ||
|
||
if [[ ! -e "${DIND_SCRIPT}" ]]; then | ||
echo >&2 "Please specify the path to kubeadm-dind-cluster script with DIND_SCRIPT" | ||
exit 1 | ||
fi | ||
|
||
base_url="https://circleci.com/api/v1.1/project/github/Mirantis/virtlet" | ||
|
||
rm -rf virtlet-circle-dump | ||
mkdir virtlet-circle-dump | ||
cd virtlet-circle-dump | ||
|
||
url="$(curl -sSL -u "${CIRCLE_TOKEN}:" "${base_url}/${job_num}/artifacts" | | ||
jq -r '.[]|select(.path=="tmp/cluster_state/kdc-dump.gz")|.url')" | ||
echo >&2 "Getting cluster dump from ${url}" | ||
curl -sSL "${url}" | gunzip | ~/dind-cluster-v1.12.sh split-dump | ||
|
||
url="$(curl -sSL -u "${CIRCLE_TOKEN}:" "${base_url}/${job_num}/artifacts" | | ||
jq -r '.[]|select(.path=="tmp/cluster_state/virtlet-dump.json.gz")|.url')" | ||
echo >&2 "Getting virtlet dump from ${url}" | ||
curl -sSL "${url}" | gunzip | virtletctl diag unpack virtlet/ |