Skip to content
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

fix(RHIDP-4394): implement re-attempting mechanism for uploading entities #101

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions ci-scripts/rhdh-setup/create_resource.sh
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,28 @@ clone_and_upload() {
for filename in "${files[@]}"; do
e_count=$(yq eval '.metadata.name | capture(".*-(?P<value>[0-9]+)").value' "$filename" | tail -n 1)
upload_url="${GITHUB_REPO%.*}/blob/${tmp_branch}/$(basename "$filename")"
log_info "Uploading entities from $upload_url"
ACCESS_TOKEN=$(get_token "rhdh")
curl -k "$(backstage_url)/api/catalog/locations" --cookie "$COOKIE" --cookie-jar "$COOKIE" -X POST -H 'Accept-Encoding: gzip, deflate, br' -H 'Authorization: Bearer '"$ACCESS_TOKEN" -H 'Content-Type: application/json' --data-raw '{"type":"url","target":"'"${upload_url}"'"}'
max_attempts=5
attempt=1
while ((attempt <= max_attempts)); do
log_info "Uploading entities from $upload_url"
ACCESS_TOKEN=$(get_token "rhdh")
response="$(curl -k "$(backstage_url)/api/catalog/locations" --cookie "$COOKIE" --cookie-jar "$COOKIE" \
-X POST \
-H 'Accept-Encoding: gzip, deflate, br' \
-H 'Authorization: Bearer '"$ACCESS_TOKEN" \
-H 'Content-Type: application/json' --data-raw '{"type":"url","target":"'"${upload_url}"'"}')"
if [ "${PIPESTATUS[0]}" -eq 0 ]; then
log_info "Entities from $upload_url uploaded"
break
else
log_warn "Unable to upload entities from $upload_url: [$response]. Trying again up to $max_attempts times."
((attempt++))
fi
done
if [[ $attempt -gt $max_attempts ]]; then
log_error "Unable to upload entities from $upload_url $max_attempts attempts, giving up!"
return 1
fi

timeout=1800
timeout_timestamp=$(date -d "$timeout seconds" "+%s")
Expand Down
32 changes: 16 additions & 16 deletions test.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
# To override system environment variables, uncomment the variables down bellow. It will be sourced by the ci-scripts.

## Scenario
# export SCENARIO=baseline-test
export SCENARIO=mvp
# export HOST=http://localhost
# export USERS=100
# export WORKERS=5
# export DURATION=1m
# export SPAWN_RATE=20
# export WAIT_FOR_SEARCH_INDEX=false
export USERS=100
export WORKERS=5
export DURATION=15m
export SPAWN_RATE=20
export WAIT_FOR_SEARCH_INDEX=false

## RHDH database population
# export PRE_LOAD_DB=true
# export BACKSTAGE_USER_COUNT=1
# export GROUP_COUNT=1
# export API_COUNT=1
# export COMPONENT_COUNT=1
export PRE_LOAD_DB=true
export BACKSTAGE_USER_COUNT=20000
export GROUP_COUNT=10000
export API_COUNT=1
export COMPONENT_COUNT=40000
# export KEYCLOAK_USER_PASS=changeme
# export AUTH_PROVIDER=keycloak
export AUTH_PROVIDER=keycloak
# export POPULATION_CONCURRENCY=10
# export COMPONENT_SHARD_SIZE=500

Expand All @@ -42,14 +42,14 @@
# export RHDH_OLM_CHANNEL=fast

## RHDH horizontal scaling
# export RHDH_DEPLOYMENT_REPLICAS=1
# export RHDH_DB_REPLICAS=1
# export RHDH_DB_STORAGE=1Gi
export RHDH_DEPLOYMENT_REPLICAS=1
export RHDH_DB_REPLICAS=1
export RHDH_DB_STORAGE=20Gi
# export RHDH_RESOURCES_CPU_REQUESTS=
# export RHDH_RESOURCES_CPU_LIMITS=
# export RHDH_RESOURCES_MEMORY_REQUESTS=
# export RHDH_RESOURCES_MEMORY_LIMITS=
# export RHDH_KEYCLOAK_REPLICAS=1
export RHDH_KEYCLOAK_REPLICAS=1

## Extras
# export LOCUST_EXTRA_CMD=--debug=true
Expand Down