Skip to content

Commit

Permalink
infra: let CI nodes sleep at night (#17150)
Browse files Browse the repository at this point in the history
Instead of always having all the nodes up, this tweaks the CI
infrastructure to reduce the number of nodes "at night" and over the
weekend.
  • Loading branch information
garyverhaegen-da authored Jul 19, 2023
1 parent 03a2d33 commit a9e579e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
14 changes: 8 additions & 6 deletions infra/azure.tf
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ echo "$(date -Is -u) start"
AZURE_PAT=${secret_resource.vsts-token.value}
scale_sets="$(az vmss list | jq -c '[.[] | {name, size: .sku.capacity}]')"
target="$1"
echo "$(date -Is -u) Shutting down all machines"
for set in $(echo $scale_sets | jq -r '.[] | .name'); do
for set in du1 du2 dw1 dw2; do
echo "$(date -Is -u) - Setting scale set $set size to 0"
az vmss scale -n $set --new-capacity 0 >/dev/null
done
Expand All @@ -134,9 +134,9 @@ done
echo "$(date -Is -u) Bringing scale sets back up"
for set in $(echo $scale_sets | jq -r '.[] | .name'); do
size=$(echo $scale_sets | jq --arg set $set -r '.[] | select (.name == $set) | .size')
echo "$(date -Is -u) - Setting scale set $set size back to $size"
for set in du1 du2 dw1 dw2; do
size=$(echo "$target" | jq --arg name $set -r '.[$name]')
echo "$(date -Is -u) - Setting scale set $set size to $size"
az vmss scale -n $set --new-capacity $size >/dev/null
done
Expand All @@ -146,7 +146,9 @@ CRON
chmod +x /root/daily-reset.sh
cat <<CRONTAB >> /etc/crontab
0 4 * * * root /root/daily-reset.sh >> /root/log 2>&1
30 5 * * 1-5 root /root/daily-reset.sh '{"du1":10,"du2":0,"dw1":5,"dw2":0}' >> /root/log 2>&1
30 18 * * 1-5 root /root/daily-reset.sh '{"du1":2,"du2":0,"dw1":1,"dw2":0}' >> /root/log 2>&1
30 5 * * 6,7 root /root/daily-reset.sh '{"du1":2,"du2":0,"dw1":1,"dw2":0}' >> /root/log 2>&1
CRONTAB
tail -f /root/log
Expand Down
2 changes: 1 addition & 1 deletion infra/ubuntu.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ locals {
{
name = "du1",
disk_size = 400,
size = 15,
size = 10,
assignment = "default",
},
{
Expand Down
2 changes: 1 addition & 1 deletion infra/windows.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ locals {
azure = [
{
name = "dw1",
size = 6,
size = 5,
assignment = "default",
disk_size = 400,
},
Expand Down

0 comments on commit a9e579e

Please sign in to comment.