Skip to content

Commit

Permalink
Merge pull request #213 from cevich/mac_pw_pool_fix_pub_dns
Browse files Browse the repository at this point in the history
Fix 'Expecting pub_dns to be set/non-empty' error
  • Loading branch information
cevich authored Aug 5, 2024
2 parents 13be116 + 436dceb commit 3568a50
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions mac_pw_pool/SetupInstances.sh
Original file line number Diff line number Diff line change
Expand Up @@ -166,24 +166,6 @@ for _dhentry in "${_dhstate[@]}"; do
set_pw_status listener error
set_pw_status comment ""

# It's really important that instances have a defined and risk-relative
# short lifespan. Multiple mechanisms are in place to assist, but none
# are perfect. Ensure instances running for an excessive time are forcefully
# terminated as soon as possible from this script.
launch_epoch=$(date -u -d "$launch_time" +%s)
now_epoch=$(date -u +%s)
age_sec=$((now_epoch-launch_epoch))
hard_max_sec=$((PW_MAX_HOURS*60*60*2)) # double PW_MAX_HOURS
dbg "launch_epoch=$launch_epoch"
dbg " now_epoch=$now_epoch"
dbg " age_sec=$age_sec"
dbg "hard_max_sec=$hard_max_sec"
msg "Instance alive for $((age_sec/60/60)) hours (max $PW_MAX_HOURS)"
if [[ $age_sec -gt $hard_max_sec ]]; then
force_term "Excess instance lifetime (+$((age_sec-hard_max_sec))s)"
continue
fi

if ! $AWS ec2 describe-instances --instance-ids $instance_id &> "$instoutput"; then
pwst_warn "Could not query instance $instance_id $(ctx 0)."
continue
Expand Down Expand Up @@ -219,6 +201,24 @@ for _dhentry in "${_dhstate[@]}"; do
continue
fi

# It's really important that instances have a defined and risk-relative
# short lifespan. Multiple mechanisms are in place to assist, but none
# are perfect. Ensure instances running for an excessive time are forcefully
# terminated as soon as possible from this script.
launch_epoch=$(date -u -d "$launch_time" +%s)
now_epoch=$(date -u +%s)
age_sec=$((now_epoch-launch_epoch))
hard_max_sec=$((PW_MAX_HOURS*60*60*2)) # double PW_MAX_HOURS
dbg "launch_epoch=$launch_epoch"
dbg " now_epoch=$now_epoch"
dbg " age_sec=$age_sec"
dbg "hard_max_sec=$hard_max_sec"
msg "Instance alive for $((age_sec/60/60)) hours (max $PW_MAX_HOURS)"
if [[ $age_sec -gt $hard_max_sec ]]; then
force_term "Excess instance lifetime (+$((age_sec-hard_max_sec))s)"
continue
fi

dbg "Attempting to contact '$name' at $pub_dns"
if ! nc -z -w 13 $pub_dns 22 &> "$ncoutput"; then
pwst_warn "Could not connect to port 22 on '$pub_dns' $(ctx 0)."
Expand Down

0 comments on commit 3568a50

Please sign in to comment.