You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Addition of function to calculate rally point instance in AWS Auto Scaling Groups (#33)
* Dockerfiles have been updated to use Python 3 due to multiple issues with running under Python 2.
* A new function, aws_wrapper_get_asg_rally_point, has been added. This allows you to calculate a single 'rally point' instance that is part of an auto-scaling group, useful for executing bootstrapping commands once per ASG.
* Refactored new unit tests to include a custom setup function for each set, and split out public vs private hostname call scenarios to be consistent with other tests.
* The Dockerfiles for tests have been updated to include setting some encoding environment variables, which resolves some issues when running tests, as well as removing some un-necessary 'sudo' calls.
* Steps to install some new dependencies have been moved to the 'Install basic dependencies' section of the test Dockerfiles per comments from maintainer.
* The comment for the new function has been updated per maintainer comment.
* Variable usage and whitespace have been updated per comments from the maintainer.
* Additional tests have been added for the 'aws_wrapper_get_asg_rally_point' function to ensure that the function fails when the ASG does not contain the requisite number of instances after the given retry / wait period has elapsed.
* The Dockerfiles for the tests have been updated to include better comments / details around the use of the locale environment variables.
Copy file name to clipboardExpand all lines: modules/bash-commons/src/aws-wrapper.sh
+33
Original file line number
Diff line number
Diff line change
@@ -215,3 +215,36 @@ function aws_wrapper_get_hostname {
215
215
aws_get_instance_private_hostname
216
216
fi
217
217
}
218
+
219
+
# Calculates a "rally point" instance in an ASG and returns its hostname. This is a deterministic way for the instances in an ASG to all pick the same single instance to perform some action: e.g., this instance could become the leader in a cluster or run some initialization script that should only be run once for the entire ASG. Under the hood, this method picks the instance in the ASG with the earliest launch time; in the case of ties, the instance with the earliest instance ID (lexicographically) is returned. This method assumes jq is installed.
220
+
functionaws_wrapper_get_asg_rally_point {
221
+
local -r asg_name="$1"
222
+
local -r aws_region="$2"
223
+
local -r use_public_hostname="$3"
224
+
local -r retries="${4:-60}"
225
+
local -r sleep_between_retries="${5:-5}"
226
+
227
+
log_info "Calculating rally point for ASG $asg_name in $aws_region"
228
+
229
+
local instances
230
+
log_info "Waiting for all instances to be available..."
0 commit comments