mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-28 16:27:50 +00:00
Merge pull request #11141 from stevenhorsman/k8s-cpu-ns-exec-retry
tests: k8s: Retry output of kubectl exec in k8s-cpu-ns
This commit is contained in:
commit
e3e0007bf7
@ -66,8 +66,18 @@ setup() {
|
|||||||
# Check the total of cpus
|
# Check the total of cpus
|
||||||
for _ in $(seq 1 "$retries"); do
|
for _ in $(seq 1 "$retries"); do
|
||||||
# Get number of cpus
|
# Get number of cpus
|
||||||
total_cpus_container=$(kubectl exec pod/"$pod_name" -c "$container_name" \
|
# Retry "kubectl exec" several times in case it unexpectedly returns an empty output string,
|
||||||
|
# in an attempt to work around issues similar to https://github.com/kubernetes/kubernetes/issues/124571.
|
||||||
|
for _ in {1..10}; do
|
||||||
|
total_cpus_container=$(kubectl exec pod/"$pod_name" -c "$container_name" \
|
||||||
-- "${exec_num_cpus_cmd[@]}")
|
-- "${exec_num_cpus_cmd[@]}")
|
||||||
|
if [[ -n "${total_cpus_container}" ]]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
warn "Empty output from kubectl exec" >&2
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
# Verify number of cpus
|
# Verify number of cpus
|
||||||
[ "$total_cpus_container" -le "$total_cpus" ]
|
[ "$total_cpus_container" -le "$total_cpus" ]
|
||||||
[ "$total_cpus_container" -eq "$total_cpus" ] && break
|
[ "$total_cpus_container" -eq "$total_cpus" ] && break
|
||||||
@ -76,16 +86,29 @@ setup() {
|
|||||||
[ "$total_cpus_container" -eq "$total_cpus" ]
|
[ "$total_cpus_container" -eq "$total_cpus" ]
|
||||||
|
|
||||||
# Check the total of requests
|
# Check the total of requests
|
||||||
total_requests_container=$(kubectl exec $pod_name -c $container_name \
|
for _ in {1..10}; do
|
||||||
-- "${exec_weightsyspath_cmd[@]}")
|
total_requests_container=$(kubectl exec $pod_name -c $container_name \
|
||||||
|
-- "${exec_weightsyspath_cmd[@]}")
|
||||||
|
if [[ -n "${total_requests_container}" ]]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
warn "Empty output from kubectl exec" >&2
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
info "total_requests_container = $total_requests_container"
|
info "total_requests_container = $total_requests_container"
|
||||||
|
|
||||||
[ "$total_requests_container" -eq "$total_requests" ]
|
[ "$total_requests_container" -eq "$total_requests" ]
|
||||||
|
|
||||||
# Check the cpus inside the container
|
# Check the cpus inside the container
|
||||||
|
for _ in {1..10}; do
|
||||||
read total_cpu_quota total_cpu_period <<< $(kubectl exec $pod_name -c $container_name \
|
maxsyspath=$(kubectl exec $pod_name -c $container_name -- "${exec_maxsyspath_cmd[@]}")
|
||||||
-- "${exec_maxsyspath_cmd[@]}")
|
if [[ -n "${maxsyspath}" ]]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
warn "Empty output from kubectl exec" >&2
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
read total_cpu_quota total_cpu_period <<< ${maxsyspath}
|
||||||
|
|
||||||
division_quota_period=$(echo $((total_cpu_quota/total_cpu_period)))
|
division_quota_period=$(echo $((total_cpu_quota/total_cpu_period)))
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ spec:
|
|||||||
image: quay.io/prometheus/busybox:latest
|
image: quay.io/prometheus/busybox:latest
|
||||||
command:
|
command:
|
||||||
- sleep
|
- sleep
|
||||||
- "30"
|
- "infinity"
|
||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
cpu: "1"
|
cpu: "1"
|
||||||
|
Loading…
Reference in New Issue
Block a user