Skip to content

Commit 3e632b9

Browse files
authored
fix: Rainbow cleanup Github action fails when there are too many existing load balancer rules (#6427)
1 parent 9e4121b commit 3e632b9

File tree

2 files changed

+34
-16
lines changed

2 files changed

+34
-16
lines changed

.github/workflows/prod-rainbow-cleanup.yml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,23 @@ jobs:
7474
| jq -r '.[] | select(.Priority | tonumber > ${{ env.MAXIMUM_NUMBER_OF_RAINBOW_DEPLOYMENTS_TO_KEEP_ALIVE }}) | .RuleArn'
7575
))
7676
77-
if [ ${#arn_list[*]} -gt 0 ]; then
78-
deployment_ids=$(
79-
aws elbv2 describe-tags \
80-
--resource-arns "${arn_list[@]}" \
81-
| jq -r '[.TagDescriptions[].Tags[] | select(.Key == "Name") | .Value | sub("^rainbow-"; "")]'
82-
)
83-
84-
echo "ids=$(echo $deployment_ids | sed 's/ //g')" >> "$GITHUB_OUTPUT"
77+
if [ ${#arn_list[@]} -gt 0 ]; then
78+
deployment_ids=()
79+
80+
# Process ARNs in batches of 20
81+
for ((i=0; i<${#arn_list[@]}; i+=20)); do
82+
batch=("${arn_list[@]:i:20}")
83+
84+
batch_ids=$(aws elbv2 describe-tags \
85+
--resource-arns "${batch[@]}" \
86+
| jq -r '[.TagDescriptions[].Tags[] | select(.Key == "Name") | .Value | sub("^rainbow-"; "")][]')
87+
88+
deployment_ids+=($batch_ids)
89+
done
90+
91+
json_array=$(printf '%s\n' "${deployment_ids[@]}" | jq -R . | jq -s .)
92+
93+
echo "ids=$(echo $json_array | sed 's/ //g')" >> "$GITHUB_OUTPUT"
8594
fi
8695
8796
cleanup-schedule-2:

.github/workflows/staging-rainbow-cleanup.yml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
type: string
1313
required: true
1414
schedule:
15-
- cron: "0 4 * * *" # Nightly at 4am
15+
- cron: "0 5,17 * * *" # Every day at noon and midnight (EST)
1616

1717
env:
1818
AWS_ACCOUNT_ID: ${{ vars.STAGING_AWS_ACCOUNT_ID }}
@@ -74,14 +74,23 @@ jobs:
7474
| jq -r '.[] | select(.Priority | tonumber > ${{ env.MAXIMUM_NUMBER_OF_RAINBOW_DEPLOYMENTS_TO_KEEP_ALIVE }}) | .RuleArn'
7575
))
7676
77-
if [ ${#arn_list[*]} -gt 0 ]; then
78-
deployment_ids=$(
79-
aws elbv2 describe-tags \
80-
--resource-arns "${arn_list[@]}" \
81-
| jq -r '[.TagDescriptions[].Tags[] | select(.Key == "Name") | .Value | sub("^rainbow-"; "")]'
82-
)
77+
if [ ${#arn_list[@]} -gt 0 ]; then
78+
deployment_ids=()
8379
84-
echo "ids=$(echo $deployment_ids | sed 's/ //g')" >> "$GITHUB_OUTPUT"
80+
# Process ARNs in batches of 20
81+
for ((i=0; i<${#arn_list[@]}; i+=20)); do
82+
batch=("${arn_list[@]:i:20}")
83+
84+
batch_ids=$(aws elbv2 describe-tags \
85+
--resource-arns "${batch[@]}" \
86+
| jq -r '[.TagDescriptions[].Tags[] | select(.Key == "Name") | .Value | sub("^rainbow-"; "")][]')
87+
88+
deployment_ids+=($batch_ids)
89+
done
90+
91+
json_array=$(printf '%s\n' "${deployment_ids[@]}" | jq -R . | jq -s .)
92+
93+
echo "ids=$(echo $json_array | sed 's/ //g')" >> "$GITHUB_OUTPUT"
8594
fi
8695
8796
cleanup-schedule-2:

0 commit comments

Comments
 (0)