Skip to content

Commit

Permalink
fix: schedule initial workload and filter on worker nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
marwanad committed Jan 4, 2025
1 parent 68f7748 commit db63b83
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 9 deletions.
4 changes: 2 additions & 2 deletions test/e2e/e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ source test/e2e/webhook_ready.sh
source test/e2e/no-rogue-finalizer/test.sh
source test/e2e/delete-chaperon/test.sh
source test/e2e/delete-delegate/test.sh
source test/e2e/plugin-config-scoring-strategy/test.sh
#source test/e2e/plugin-config-scoring-strategy/test.sh

argo_setup_once
cert_manager_setup_once
Expand Down Expand Up @@ -80,7 +80,7 @@ virtual-node-labels_test 1 2
cleanup_test 1
delete-chaperon_test 1
delete-delegate_test 1 2
plugin-config-scoring-strategy_test 1 2
#plugin-config-scoring-strategy_test 1 2
no-reservation_test

no-rogue-finalizer_test
Expand Down
1 change: 1 addition & 0 deletions test/e2e/kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ kind_setup() {
CLUSTER=cluster$i

if ! kind get clusters | grep $CLUSTER; then
# kind create cluster --name $CLUSTER --wait 5m --image "${kind_images["$K8S_VERSION"]}" --config test/e2e/kind-config.yaml
kind create cluster --name $CLUSTER --wait 5m --image "${kind_images["$K8S_VERSION"]}" --config test/e2e/kind-config.yaml
fi
NODE_IP=$(docker inspect "${CLUSTER}-control-plane" --format "{{ .NetworkSettings.Networks.kind.IPAddress }}")
Expand Down
15 changes: 15 additions & 0 deletions test/e2e/plugin-config-scoring-strategy/init-workload.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Pod
metadata:
name: init-workload
annotations:
multicluster.admiralty.io/elect: ""
spec:
nodeSelector:
a: b
containers:
- name: pause
image: gcr.io/google_containers/pause
resources:
requests:
cpu: 1
17 changes: 10 additions & 7 deletions test/e2e/plugin-config-scoring-strategy/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@ plugin-config-scoring-strategy_test() {
j=$2
k $j label node --all a=b --overwrite

# Find the node with the highest CPU utilization
nodes=$(k $j get nodes -o name | sed s/"node\/"//)
k $i apply -f test/e2e/plugin-config-scoring-strategy/init-workload.yaml
k $i wait pod init-workload --for=condition=PodScheduled

# Find the worker node with the highest CPU utilization
nodes=$(k $j get nodes -l '!node-role.kubernetes.io/control-plane' -o name | sed s/"node\/"//)
most_allocated=""
most_cpu_requests="0"
most_cpu_requests=0
for node in $nodes; do
cpu_requests=$(k $j describe node "$node" | grep -A5 "Allocated" | awk '{print $3}' | sed -n '5p' | tr -d '()%')
echo "node: $node, cpu requests: $cpu_requests"
if [[ "$cpu_requests" -ge "$most_cpu_requests" ]]
echo "node: $node, cpu allocated: $cpu_requests%"
if [[ $cpu_requests -ge $most_cpu_requests ]]
then
most_cpu_requests=$cpu_requests
most_allocated=$node
Expand All @@ -41,8 +44,8 @@ plugin-config-scoring-strategy_test() {
k $i apply -f test/e2e/plugin-config-scoring-strategy/test.yaml
k $i wait pod test-scoring-strategy --for=condition=PodScheduled

node_scheduled="$(k $j get pod -o json | jq -er '.items[0].spec.nodeName')"
k $i delete -f test/e2e/plugin-config-scoring-strategy/test.yaml
node_scheduled="$(k $j get pod -l multicluster.admiralty.io/app=test-scoring-strategy -o json | jq -er '.items[0].spec.nodeName')"
k $i delete -f test/e2e/plugin-config-scoring-strategy/test.yaml,test/e2e/plugin-config-scoring-strategy/init-workload.yaml
k $j label node --all a-
if [ "$node_scheduled" != "$most_allocated" ]
then
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/plugin-config-scoring-strategy/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ apiVersion: v1
kind: Pod
metadata:
name: test-scoring-strategy
labels:
app: test-scoring-strategy
annotations:
multicluster.admiralty.io/elect: ""
spec:
Expand Down

0 comments on commit db63b83

Please sign in to comment.