fleet/infrastructure/loadtesting/terraform/osquery_perf/enroll.sh
Jorge Falcon 75f79dc866
Loadtest osquery perf workflow wording and enroll.sh remainder updates (#43762)
- Updates wording in `.github/workflows/loadtest-osquery-perf.yml` 
  - `4098` -> `4096`
- Removes: `(should be a multiple of 8, if setting
loadtest_containers_starting_index)`
- Updates `infrastructure/loadtesting/terraform/osquery_perf/enroll.sh`
to handle values that are not multiples of 8. If the value is not a
multiple of 8, logic has been added to apply the remainder.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

## Release Notes

* **Documentation**
* Updated load testing workflow configuration input descriptions for
improved clarity of parameters and their usage examples.

* **Bug Fixes**
* Fixed container count allocation logic in the load testing process to
ensure the final target count is always properly applied, even when
using increment values that don't divide evenly into the specified total
range.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-04-20 12:01:23 -04:00

42 lines
1.3 KiB
Bash
Executable file

#!/bin/bash
set -e
# Script for enrolling osquery-perf hosts by `terraform apply`ing in increments of 8 `loadtest` containers.
# NOTE(lucas): This is the currently known configuration that won't tip the loadtest environment,
# but maybe in the future we can be more aggressive (and reduce enroll time).
#
# ./enroll.sh my-branch 8 240
BRANCH_NAME=$1
TASK_SIZE=${2:?}
START_INDEX=$3
END_INDEX=$4
SLEEP_TIME_SECONDS=${5:-60}
INCREMENT=${6:-8}
if [ -z "$BRANCH_NAME" ]; then
echo "Missing BRANCH_NAME"
fi
if [ -z "$START_INDEX" ]; then
echo "Missing START_INDEX"
fi
if [ -z "$END_INDEX" ]; then
echo "Missing END_INDEX"
fi
if [ -z "$TASK_SIZE" ]; then
echo "Missing TASK_SIZE"
fi
# We add this check to avoid terraform (error-prone) locking in case of typos.
# read -p "You will use BRANCH_NAME=$BRANCH_NAME. Continue? "
set -x
for (( c=$START_INDEX; c<=$END_INDEX; c+=$INCREMENT )); do
terraform apply -var git_tag_branch=$BRANCH_NAME -var task_size="$TASK_SIZE" -var loadtest_containers=$c -auto-approve
sleep $SLEEP_TIME_SECONDS
done
# Apply the remainder if the loop didn't land exactly on END_INDEX.
if (( $c - $INCREMENT != $END_INDEX )); then
terraform apply -var git_tag_branch=$BRANCH_NAME -var task_size="$TASK_SIZE" -var loadtest_containers=$END_INDEX -auto-approve
fi