-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enabled instance_refresh for the ASG
Added additional script to the user data scripts to handle waiting for an available volume Enabled always running the user data scripts (reboot, stop/start) Fixed type-o Changed lb_health_check_path to /protocol fixed issue with creating new disks when disk was already attached. Updated README.md Added checks for cluster quorum. Moved the logic for disk mounting so there are no redundant operations. Moved instance_refresh_checkpoint_delay and enable_userdata_scripts_on_reboot variables to top level. Renamed 08_node_rejoin.sh.tpl to 08_node_join.sh.tpl and removed unnecessary logic. Refactored 01_disk_management.sh.tpl Updated 02_dns_provisioning.sh.tpl node naming Added tagging for EC2 instances AWS module upgrade to 5.49.0
- Loading branch information
1 parent
7d1a7d7
commit 226dc4e
Showing
16 changed files
with
404 additions
and
248 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This script performs the following actions: | ||
# * Waits for ASG EC2 count to match the expected node count | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
# This handles instance refreshing where new and old nodes are both present. | ||
# Waiting until the ASG nodes are equal to the expected node count and proceeding with the provisioning afterwards. | ||
IMDS_TOKEN=$(curl -Ss -H "X-aws-ec2-metadata-token-ttl-seconds: 6000" -XPUT 169.254.169.254/latest/api/token) | ||
AZ=$(curl -Ss -H "X-aws-ec2-metadata-token: $IMDS_TOKEN" 169.254.169.254/latest/meta-data/placement/availability-zone) | ||
ASG_NAME=${name} | ||
|
||
instance_refresh_status=$(aws autoscaling describe-instance-refreshes --auto-scaling-group-name "$ASG_NAME" --query 'InstanceRefreshes[?Status==`InProgress`]' --output json) | ||
|
||
if [ "$instance_refresh_status" != "[]" ]; then | ||
echo "An instance refresh is currently in progress for the ASG: $ASG_NAME" | ||
echo "$instance_refresh_status" | jq '.' | ||
|
||
IMDS_TOKEN=$(curl -Ss -H "X-aws-ec2-metadata-token-ttl-seconds: 6000" -XPUT 169.254.169.254/latest/api/token) | ||
INSTANCE_ID=$(curl -Ss -H "X-aws-ec2-metadata-token: $IMDS_TOKEN" 169.254.169.254/latest/meta-data/instance-id) | ||
|
||
echo "Waiting for default EC2 status check to pass for instance $INSTANCE_ID..." | ||
|
||
# Loop until the default status check passes | ||
while true; do | ||
# Get the status of the default status checks for the instance | ||
instance_status=$(aws ec2 describe-instance-status --instance-ids $INSTANCE_ID --query 'InstanceStatuses[0].InstanceStatus.Status' --output text) | ||
system_status=$(aws ec2 describe-instance-status --instance-ids $INSTANCE_ID --query 'InstanceStatuses[0].SystemStatus.Status' --output text) | ||
|
||
# Check if the status is "ok" | ||
if [[ "$instance_status" == "ok" && $system_status == "ok" ]]; then | ||
echo "Default EC2 status check passed for instance $INSTANCE_ID." | ||
break | ||
fi | ||
|
||
# Sleep for a while before checking again | ||
sleep 5 | ||
done | ||
|
||
echo "Waiting for an available volume in $AZ" | ||
# TODO This will hang forever when scaling out. | ||
while true; do | ||
# Get the list of volumes in the current availability zone | ||
available_volumes=$(aws ec2 describe-volumes --filters "Name=availability-zone,Values=$AZ Name=status,Values=available Name=volume-type,Values=gp3" --query "Volumes[*].VolumeId" --output text) | ||
|
||
# Check if any volumes are available | ||
if [ -n "$available_volumes" ]; then | ||
echo "Found an available volume in $AZ." | ||
break | ||
fi | ||
|
||
sleep 5 | ||
done | ||
else | ||
echo "No instance refresh is currently in progress for the ASG: $ASG_NAME" | ||
fi |
Oops, something went wrong.