Skip to content

Commit

Permalink
fix: Make the logic around last_count working
Browse files Browse the repository at this point in the history
Did 2 changes here:

First is the important one where I removed `&& [[ $last_count -ge 0 ]]`
as that was blocking changing last_count, because it was initialized to
-1. Now it should work as expected.

Second I made sure warning is printed if we fail to obtain current count
value.
  • Loading branch information
jhutar committed Oct 17, 2024
1 parent 9645f39 commit 279f8e4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ci-scripts/rhdh-setup/create_resource.sh
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ clone_and_upload() {
return 1
fi

timeout=1800
timeout=300
timeout_timestamp=$(date -d "$timeout seconds" "+%s")
last_count=-1
while true; do
Expand All @@ -147,7 +147,8 @@ clone_and_upload() {
ACCESS_TOKEN=$(get_token "rhdh")
if [[ 'component-*.yaml' == "${1}" ]]; then b_count=$(curl -s -k "$(backstage_url)/api/catalog/entity-facets?facet=kind" --cookie "$COOKIE" --cookie-jar "$COOKIE" -H 'Content-Type: application/json' -H 'Authorization: Bearer '"$ACCESS_TOKEN" | tee -a "$TMP_DIR/get_component_count.log" | jq -r '.facets.kind[] | select(.value == "Component")| .count'); fi
if [[ 'api-*.yaml' == "${1}" ]]; then b_count=$(curl -s -k "$(backstage_url)/api/catalog/entity-facets?facet=kind" --cookie "$COOKIE" --cookie-jar "$COOKIE" -H 'Content-Type: application/json' -H 'Authorization: Bearer '"$ACCESS_TOKEN" | tee -a "$TMP_DIR/get_api_count.log" | jq -r '.facets.kind[] | select(.value == "API")| .count'); fi
if [[ "$last_count" != "$b_count" ]] && [[ $last_count -ge 0 ]]; then # reset the timeout if current count changes
if [[ -z "$b_count" ]]; then log_warn "Failed to get current count, maybe RHDH is down?"; b_count=0; fi
if [[ "$last_count" != "$b_count" ]]; then # reset the timeout if current count changes
log_info "The current count changed, resetting entity waiting timeout to $timeout seconds"
timeout_timestamp=$(date -d "$timeout seconds" "+%s")
last_count=$b_count
Expand Down

0 comments on commit 279f8e4

Please sign in to comment.