Skip to content

Commit

Permalink
Wait functions now wait for ready replicas
Browse files Browse the repository at this point in the history
Signed-off-by: Raul Sevilla <[email protected]>
  • Loading branch information
rsevilla87 committed Jul 5, 2021
1 parent 1ac31c2 commit 372b3e8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
17 changes: 9 additions & 8 deletions pkg/burner/waiters.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"github.com/cloud-bulldozer/kube-burner/log"

corev1 "k8s.io/api/core/v1"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
Expand Down Expand Up @@ -79,14 +78,15 @@ func (ex *Executor) waitForObjects(ns string) {

func waitForDeployments(ns string, maxWaitTimeout time.Duration, wg *sync.WaitGroup) {
defer wg.Done()
// TODO handle errors such as timeouts
wait.PollImmediate(1*time.Second, maxWaitTimeout, func() (bool, error) {
deps, err := ClientSet.AppsV1().Deployments(ns).List(context.TODO(), metav1.ListOptions{})
if err != nil {
return false, err
}
for _, dep := range deps.Items {
if dep.Status.AvailableReplicas != *dep.Spec.Replicas {
log.Debugf("Waiting for Deployments in ns %s to be ready", ns)
if *dep.Spec.Replicas != dep.Status.ReadyReplicas {
log.Debugf("Waiting for replicas from deployments in ns %s to be ready", ns)
return false, nil
}
}
Expand All @@ -102,8 +102,8 @@ func waitForRS(ns string, maxWaitTimeout time.Duration, wg *sync.WaitGroup) {
return false, err
}
for _, rs := range rss.Items {
if *rs.Spec.Replicas != rs.Status.AvailableReplicas {
log.Debugf("Waiting for ReplicaSets in ns %s to be ready", ns)
if *rs.Spec.Replicas != rs.Status.ReadyReplicas {
log.Debugf("Waiting for replicas from replicaSets in ns %s to be ready", ns)
return false, nil
}
}
Expand All @@ -120,7 +120,7 @@ func waitForRC(ns string, maxWaitTimeout time.Duration, wg *sync.WaitGroup) {
}
for _, rc := range rcs.Items {
if *rc.Spec.Replicas != rc.Status.ReadyReplicas {
log.Debugf("Waiting for ReplicationControllers in ns %s to be ready", ns)
log.Debugf("Waiting for replicas from replicationControllers in ns %s to be ready", ns)
return false, nil
}
}
Expand All @@ -136,8 +136,8 @@ func waitForDS(ns string, maxWaitTimeout time.Duration, wg *sync.WaitGroup) {
return false, err
}
for _, ds := range dss.Items {
if ds.Status.DesiredNumberScheduled != ds.Status.NumberAvailable {
log.Debugf("Waiting for daemonsets in ns %s to be readt", ns)
if ds.Status.DesiredNumberScheduled != ds.Status.NumberReady {
log.Debugf("Waiting for replicas from daemonsets in ns %s to be ready", ns)
return false, nil
}
}
Expand All @@ -153,6 +153,7 @@ func waitForPod(ns string, maxWaitTimeout time.Duration, wg *sync.WaitGroup) {
return false, err
}
for _, pod := range pods.Items {
// TODO Check for all containers from the pod to be in ready state
if pod.Status.Phase != corev1.PodRunning {
log.Debugf("Waiting for pods in ns %s to be running", ns)
return false, nil
Expand Down
3 changes: 2 additions & 1 deletion test/kube-burner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:

- name: not-namespaced
jobType: create
jobIterations: {{randInteger 1 4}}
jobIterations: {{randInteger 1 2}}
qps: 5
burst: 15
namespacedIterations: false
Expand All @@ -44,6 +44,7 @@ jobs:
waitWhenFinished: false
verifyObjects: true
errorOnVerify: true
maxWaitTimeout: 2m
objects:

- objectTemplate: objectTemplates/deployment.yml
Expand Down
2 changes: 1 addition & 1 deletion test/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ check_files () {
}

log "Running kube-burner init"
kube-burner init -c kube-burner.yml --uuid ${uuid} --log-level=debug -u http://localhost:9090 -m metrics-profile.yaml -a alert-profile.yaml
timeout 120 kube-burner init -c kube-burner.yml --uuid ${uuid} --log-level=debug -u http://localhost:9090 -m metrics-profile.yaml -a alert-profile.yaml
check_files
check_ns kube-burner-job=namespaced,kube-burner-uuid=${uuid} 5
check_destroyed_ns kube-burner-job=not-namespaced,kube-burner-uuid=${uuid}
Expand Down

0 comments on commit 372b3e8

Please sign in to comment.