Skip to content

Commit

Permalink
ci: add retry for getting rancher api key
Browse files Browse the repository at this point in the history
Signed-off-by: Yang Chiu <[email protected]>
  • Loading branch information
yangchiu authored and khushboo-rancher committed Apr 2, 2024
1 parent 7ba43f7 commit fefc991
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
11 changes: 7 additions & 4 deletions pipelines/utilities/longhorn_rancher_chart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@ install_rancher() {


get_rancher_api_key() {
TOKEN=$(curl -X POST -s -k "https://${RANCHER_HOSTNAME}/v3-public/localproviders/local?action=login" -H 'Content-Type: application/json' -d "{\"username\":\"admin\", \"password\":\"${RANCHER_BOOTSTRAP_PASSWORD}\", \"responseType\": \"json\"}" | jq -r '.token' | tr -d '"')
ARR=(${TOKEN//:/ })
RANCHER_ACCESS_KEY=${ARR[0]}
RANCHER_SECRET_KEY=${ARR[1]}
while [[ -z "${TOKEN}" ]]; do
TOKEN=$(curl -X POST -s -k "https://${RANCHER_HOSTNAME}/v3-public/localproviders/local?action=login" -H 'Content-Type: application/json' -d "{\"username\":\"admin\", \"password\":\"${RANCHER_BOOTSTRAP_PASSWORD}\", \"responseType\": \"json\"}" | jq -r '.token' | tr -d '"')
ARR=(${TOKEN//:/ })
RANCHER_ACCESS_KEY=${ARR[0]}
RANCHER_SECRET_KEY=${ARR[1]}
sleep 3s
done
}


Expand Down
11 changes: 7 additions & 4 deletions test_framework/scripts/longhorn-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,13 @@ install_rancher() {


get_rancher_api_key() {
TOKEN=$(curl -X POST -s -k "https://${RANCHER_HOSTNAME}/v3-public/localproviders/local?action=login" -H 'Content-Type: application/json' -d "{\"username\":\"admin\", \"password\":\"${RANCHER_BOOTSTRAP_PASSWORD}\", \"responseType\": \"json\"}" | jq -r '.token' | tr -d '"')
ARR=(${TOKEN//:/ })
RANCHER_ACCESS_KEY=${ARR[0]}
RANCHER_SECRET_KEY=${ARR[1]}
while [[ -z "${TOKEN}" ]]; do
TOKEN=$(curl -X POST -s -k "https://${RANCHER_HOSTNAME}/v3-public/localproviders/local?action=login" -H 'Content-Type: application/json' -d "{\"username\":\"admin\", \"password\":\"${RANCHER_BOOTSTRAP_PASSWORD}\", \"responseType\": \"json\"}" | jq -r '.token' | tr -d '"')
ARR=(${TOKEN//:/ })
RANCHER_ACCESS_KEY=${ARR[0]}
RANCHER_SECRET_KEY=${ARR[1]}
sleep 3s
done
}


Expand Down

0 comments on commit fefc991

Please sign in to comment.