Skip to content

Commit 7b32be0

Browse files
akrzoschaitanyaenr
authored andcommitted
Adjust scale workload to handle 1 to 4 availability zones and multiple cloud hosting environments
1 parent 9058107 commit 7b32be0

File tree

2 files changed

+43
-17
lines changed

2 files changed

+43
-17
lines changed

docs/scale.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
The scale workload playbook is `workloads/scale.yml` and will scale a cluster with or without tooling.
44

5-
The scale workload can scale a cluster both with more or less worker nodes provisioned across the 4 availability zones. If scaling down it is best to use the workload node to host the workload job as the nodes chosen to host the workload Pod could also be a node that is removed.
5+
The scale workload can scale a cluster both with more or less worker nodes provisioned across 1-4 availability zones. If scaling down it is best to use the workload node to host the workload job as the nodes chosen to host the workload Pod could also be a node that is removed.
66

77
Running from CLI:
88

workloads/files/workload-scale-script-cm.yml

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,29 +68,55 @@ data:
6868
workload_log "Test Analysis: Passed"
6969
workload.sh: |
7070
#!/bin/sh
71-
set -eo pipefail
7271
7372
result_dir=/tmp
7473
if [ "${PBENCH_INSTRUMENTATION}" = "true" ]; then
7574
result_dir=${benchmark_results_dir}
7675
fi
77-
cluster_name=$(oc get machineset -n openshift-machine-api -o=go-template='{{(index (index .items 0).metadata.labels "'${SCALE_METADATA_PREFIX}'/cluster-api-cluster")}}')
78-
cluster_region=$(oc get machineset -n openshift-machine-api -o=go-template='{{(index .items 0 ).spec.template.spec.providerSpec.value.placement.region }}')
79-
80-
az_a_count=$(((${SCALE_WORKER_COUNT}+3)/4))
81-
az_b_count=$(((${SCALE_WORKER_COUNT}+2)/4))
82-
az_c_count=$(((${SCALE_WORKER_COUNT}+1)/4))
83-
az_d_count=$((${SCALE_WORKER_COUNT}/4))
76+
machinesets=$(oc get machineset -n openshift-machine-api | egrep "\-worker\-|\-w\-" | awk '{print $1}')
77+
IFS=$'\n' read -rd '' -a ms_arr <<<"$machinesets"
8478
8579
start_time=$(date +%s)
86-
workload_log "Scaling ${cluster_region}a to ${az_a_count}"
87-
oc patch machineset ${cluster_name}-worker-${cluster_region}a --type=merge -n openshift-machine-api -p '{"spec": {"replicas": '${az_a_count}' }}'
88-
workload_log "Scaling ${cluster_region}b to ${az_b_count}"
89-
oc patch machineset ${cluster_name}-worker-${cluster_region}b --type=merge -n openshift-machine-api -p '{"spec": {"replicas": '${az_b_count}' }}'
90-
workload_log "Scaling ${cluster_region}c to ${az_c_count}"
91-
oc patch machineset ${cluster_name}-worker-${cluster_region}c --type=merge -n openshift-machine-api -p '{"spec": {"replicas": '${az_c_count}' }}'
92-
workload_log "Scaling ${cluster_region}d to ${az_d_count}"
93-
oc patch machineset ${cluster_name}-worker-${cluster_region}d --type=merge -n openshift-machine-api -p '{"spec": {"replicas": '${az_d_count}' }}'
80+
if [ "${#ms_arr[@]}" == "1" ]; then
81+
workload_log "Scaling ${ms_arr[0]} to ${SCALE_WORKER_COUNT}"
82+
oc patch machineset ${ms_arr[0]} --type=merge -n openshift-machine-api -p '{"spec": {"replicas": '${SCALE_WORKER_COUNT}' }}'
83+
elif [ "${#ms_arr[@]}" == "2" ]; then
84+
az_a_count=$(((${SCALE_WORKER_COUNT}+1)/2))
85+
az_b_count=$(((${SCALE_WORKER_COUNT})/2))
86+
87+
workload_log "Scaling ${ms_arr[0]} to ${az_a_count}"
88+
oc patch machineset ${ms_arr[0]} --type=merge -n openshift-machine-api -p '{"spec": {"replicas": '${az_a_count}' }}'
89+
workload_log "Scaling ${ms_arr[1]} to ${az_b_count}"
90+
oc patch machineset ${ms_arr[1]} --type=merge -n openshift-machine-api -p '{"spec": {"replicas": '${az_b_count}' }}'
91+
elif [ "${#ms_arr[@]}" == "3" ]; then
92+
az_a_count=$(((${SCALE_WORKER_COUNT}+2)/3))
93+
az_b_count=$(((${SCALE_WORKER_COUNT}+1)/3))
94+
az_c_count=$((${SCALE_WORKER_COUNT}/3))
95+
96+
workload_log "Scaling ${ms_arr[0]} to ${az_a_count}"
97+
oc patch machineset ${ms_arr[0]} --type=merge -n openshift-machine-api -p '{"spec": {"replicas": '${az_a_count}' }}'
98+
workload_log "Scaling ${ms_arr[1]} to ${az_b_count}"
99+
oc patch machineset ${ms_arr[1]} --type=merge -n openshift-machine-api -p '{"spec": {"replicas": '${az_b_count}' }}'
100+
workload_log "Scaling ${ms_arr[2]} to ${az_c_count}"
101+
oc patch machineset ${ms_arr[2]} --type=merge -n openshift-machine-api -p '{"spec": {"replicas": '${az_c_count}' }}'
102+
elif [ "${#ms_arr[@]}" == "4" ]; then
103+
az_a_count=$(((${SCALE_WORKER_COUNT}+3)/4))
104+
az_b_count=$(((${SCALE_WORKER_COUNT}+2)/4))
105+
az_c_count=$(((${SCALE_WORKER_COUNT}+1)/4))
106+
az_d_count=$((${SCALE_WORKER_COUNT}/4))
107+
108+
workload_log "Scaling ${ms_arr[0]} to ${az_a_count}"
109+
oc patch machineset ${ms_arr[0]} --type=merge -n openshift-machine-api -p '{"spec": {"replicas": '${az_a_count}' }}'
110+
workload_log "Scaling ${ms_arr[1]} to ${az_b_count}"
111+
oc patch machineset ${ms_arr[1]} --type=merge -n openshift-machine-api -p '{"spec": {"replicas": '${az_b_count}' }}'
112+
workload_log "Scaling ${ms_arr[2]} to ${az_c_count}"
113+
oc patch machineset ${ms_arr[2]} --type=merge -n openshift-machine-api -p '{"spec": {"replicas": '${az_c_count}' }}'
114+
workload_log "Scaling ${ms_arr[3]} to ${az_d_count}"
115+
oc patch machineset ${ms_arr[3]} --type=merge -n openshift-machine-api -p '{"spec": {"replicas": '${az_d_count}' }}'
116+
else
117+
workload_log "Unhandled number of machinesets: ${#ms_arr[@]}"
118+
exit 1
119+
fi
94120
95121
retries=0
96122
while [ ${retries} -le ${SCALE_POLL_ATTEMPTS} ] ; do

0 commit comments

Comments
 (0)