Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PTX-3561 Torpedo reports 2/3 pods are ready, when all pods are ready #261

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 8 additions & 18 deletions k8s/apps/daemonsets.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,32 +125,22 @@ func (c *Client) ValidateDaemonSet(name, namespace string, timeout time.Duration
}
}

if ds.Status.DesiredNumberScheduled != ds.Status.NumberReady {
return "", true, &schederrors.ErrAppNotReady{
ID: name,
Cause: fmt.Sprintf("Expected ready: %v Actual ready:%v Current pods overview:\n%s",
ds.Status.DesiredNumberScheduled, ds.Status.NumberReady, podsOverviewString),
}
}

var notReadyPods []string
var readyCount int32
for _, pod := range pods {
if !common.IsPodReady(pod) {
notReadyPods = append(notReadyPods, pod.Name)
} else {
if common.IsPodReady(pod) {
readyCount++
}
}

if readyCount == ds.Status.DesiredNumberScheduled {
return "", false, nil
if ds.Status.DesiredNumberScheduled != readyCount {
return "", true, &schederrors.ErrAppNotReady{
ID: name,
Cause: fmt.Sprintf("Expected ready: %v Actual ready:%v Current pods overview:\n%s",
ds.Status.DesiredNumberScheduled, readyCount, podsOverviewString),
}
}

return "", true, &schederrors.ErrAppNotReady{
ID: ds.Name,
Cause: fmt.Sprintf("Pod(s): %#v not yet ready", notReadyPods),
}
return "", false, nil
}

if _, err := task.DoRetryWithTimeout(t, timeout, 15*time.Second); err != nil {
Expand Down
26 changes: 8 additions & 18 deletions k8s/apps/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,6 @@ func (c *Client) ValidateDeployment(deployment *appsv1.Deployment, timeout, retr
}
}

if requiredReplicas > dep.Status.ReadyReplicas {
return "", true, &schederrors.ErrAppNotReady{
ID: dep.Name,
Cause: fmt.Sprintf("Expected replicas: %v Ready replicas: %v Current pods overview:\n%s",
requiredReplicas, dep.Status.ReadyReplicas, podsOverviewString),
}
}

if requiredReplicas != dep.Status.UpdatedReplicas && shared {
return "", true, &schederrors.ErrAppNotReady{
ID: dep.Name,
Expand All @@ -173,24 +165,22 @@ func (c *Client) ValidateDeployment(deployment *appsv1.Deployment, timeout, retr
}

// look for "requiredReplicas" number of pods in ready state
var notReadyPods []string
var readyCount int32
for _, pod := range pods {
if !common.IsPodReady(pod) {
notReadyPods = append(notReadyPods, pod.Name)
} else {
if common.IsPodReady(pod) {
readyCount++
}
}

if readyCount >= requiredReplicas {
return "", false, nil
if requiredReplicas > readyCount {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be >=

return "", true, &schederrors.ErrAppNotReady{
ID: dep.Name,
Cause: fmt.Sprintf("Expected replicas: %v Ready replicas: %v Current pods overview:\n%s",
requiredReplicas, readyCount, podsOverviewString),
}
}

return "", true, &schederrors.ErrAppNotReady{
ID: dep.Name,
Cause: fmt.Sprintf("Pod(s): %#v not yet ready", notReadyPods),
}
return "", false, nil
}

if _, err := task.DoRetryWithTimeout(t, timeout, retryInterval); err != nil {
Expand Down
26 changes: 8 additions & 18 deletions k8s/apps/replicasets.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,32 +130,22 @@ func (c *Client) ValidateReplicaSet(name, namespace string, timeout time.Duratio
}
}

if rs.Status.Replicas != rs.Status.ReadyReplicas {
return "", true, &schederrors.ErrAppNotReady{
ID: name,
Cause: fmt.Sprintf("Expected ready: %v Actual ready:%v Current pods overview:\n%s",
rs.Status.Replicas, rs.Status.ReadyReplicas, podsOverviewString),
}
}

var notReadyPods []string
var readyCount int32
for _, pod := range pods {
if !common.IsPodReady(pod) {
notReadyPods = append(notReadyPods, pod.Name)
} else {
if common.IsPodReady(pod) {
readyCount++
}
}

if readyCount == rs.Status.Replicas {
return "", false, nil
if rs.Status.Replicas != readyCount {
return "", true, &schederrors.ErrAppNotReady{
ID: name,
Cause: fmt.Sprintf("Expected ready: %v Actual ready:%v Current pods overview:\n%s",
rs.Status.Replicas, readyCount, podsOverviewString),
}
}
return "", false, nil

return "", true, &schederrors.ErrAppNotReady{
ID: rs.Name,
Cause: fmt.Sprintf("Pod(s): %#v not yet ready", notReadyPods),
}
}

if _, err := task.DoRetryWithTimeout(t, timeout, 15*time.Second); err != nil {
Expand Down
20 changes: 9 additions & 11 deletions k8s/apps/statefulsets.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,20 +138,18 @@ func (c *Client) ValidateStatefulSet(statefulset *appsv1.StatefulSet, timeout ti
}
}

if *sset.Spec.Replicas != sset.Status.ReadyReplicas {
return "", true, &schederrors.ErrAppNotReady{
ID: sset.Name,
Cause: fmt.Sprintf("Expected replicas: %v Ready replicas: %v Current pods overview:\n%s",
*sset.Spec.Replicas, sset.Status.ReadyReplicas, podsOverviewString),
var readyCount int32
for _, pod := range pods {
if common.IsPodReady(pod) {
readyCount++
}
}

for _, pod := range pods {
if !common.IsPodReady(pod) {
return "", true, &schederrors.ErrAppNotReady{
ID: sset.Name,
Cause: fmt.Sprintf("Pod: %v is not yet ready", pod.Name),
}
if *sset.Spec.Replicas != readyCount {
return "", true, &schederrors.ErrAppNotReady{
ID: sset.Name,
Cause: fmt.Sprintf("Expected replicas: %v Ready replicas: %v Current pods overview:\n%s",
*sset.Spec.Replicas, readyCount, podsOverviewString),
}
}

Expand Down