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

fix: Regularize health status messages (#230) #231

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
42 changes: 21 additions & 21 deletions pkg/health/health_statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,45 +45,45 @@ func getAppsv1StatefulSetHealth(sts *appsv1.StatefulSet) (*HealthStatus, error)
if sts.Status.ObservedGeneration == 0 || sts.Generation > sts.Status.ObservedGeneration {
return &HealthStatus{
Status: HealthStatusProgressing,
Message: "Waiting for statefulset spec update to be observed...",
Message: "Waiting for statefulset spec update to be observed",
}, nil
}
if sts.Spec.Replicas != nil && sts.Status.ReadyReplicas < *sts.Spec.Replicas {
return &HealthStatus{
Status: HealthStatusProgressing,
Message: fmt.Sprintf("Waiting for %d pods to be ready...", *sts.Spec.Replicas-sts.Status.ReadyReplicas),
Message: fmt.Sprintf("Waiting for %d pods to be ready", *sts.Spec.Replicas-sts.Status.ReadyReplicas),
}, nil
}
if sts.Spec.UpdateStrategy.Type == appsv1.RollingUpdateStatefulSetStrategyType && sts.Spec.UpdateStrategy.RollingUpdate != nil {
if sts.Spec.Replicas != nil && sts.Spec.UpdateStrategy.RollingUpdate.Partition != nil {
if sts.Status.UpdatedReplicas < (*sts.Spec.Replicas - *sts.Spec.UpdateStrategy.RollingUpdate.Partition) {
return &HealthStatus{
Status: HealthStatusProgressing,
Message: fmt.Sprintf("Waiting for partitioned roll out to finish: %d out of %d new pods have been updated...",
Message: fmt.Sprintf("Waiting for partitioned roll out to finish: %d out of %d new pods have been updated",
sts.Status.UpdatedReplicas, (*sts.Spec.Replicas - *sts.Spec.UpdateStrategy.RollingUpdate.Partition)),
}, nil
}
}
return &HealthStatus{
Status: HealthStatusHealthy,
Message: fmt.Sprintf("partitioned roll out complete: %d new pods have been updated...", sts.Status.UpdatedReplicas),
Message: fmt.Sprintf("Partitioned roll out complete: %d new pods have been updated", sts.Status.UpdatedReplicas),
}, nil
}
if sts.Spec.UpdateStrategy.Type == appsv1.OnDeleteStatefulSetStrategyType {
return &HealthStatus{
Status: HealthStatusHealthy,
Message: fmt.Sprintf("statefulset has %d ready pods", sts.Status.ReadyReplicas),
Message: fmt.Sprintf("Statefulset has %d ready pods", sts.Status.ReadyReplicas),
}, nil
}
if sts.Status.UpdateRevision != sts.Status.CurrentRevision {
return &HealthStatus{
Status: HealthStatusProgressing,
Message: fmt.Sprintf("waiting for statefulset rolling update to complete %d pods at revision %s...", sts.Status.UpdatedReplicas, sts.Status.UpdateRevision),
Message: fmt.Sprintf("Waiting for statefulset rolling update to complete %d pods at revision %s", sts.Status.UpdatedReplicas, sts.Status.UpdateRevision),
}, nil
}
return &HealthStatus{
Status: HealthStatusHealthy,
Message: fmt.Sprintf("statefulset rolling update complete %d pods at revision %s...", sts.Status.CurrentReplicas, sts.Status.CurrentRevision),
Message: fmt.Sprintf("Statefulset rolling update complete %d pods at revision %s", sts.Status.CurrentReplicas, sts.Status.CurrentRevision),
}, nil
}

Expand All @@ -97,45 +97,45 @@ func getAppsv1beta1StatefulSetHealth(sts *appsv1beta1.StatefulSet) (*HealthStatu
if *observedGeneration == 0 || sts.Generation > *observedGeneration {
return &HealthStatus{
Status: HealthStatusProgressing,
Message: "Waiting for statefulset spec update to be observed...",
Message: "Waiting for statefulset spec update to be observed",
}, nil
}
if sts.Spec.Replicas != nil && sts.Status.ReadyReplicas < *sts.Spec.Replicas {
return &HealthStatus{
Status: HealthStatusProgressing,
Message: fmt.Sprintf("Waiting for %d pods to be ready...", *sts.Spec.Replicas-sts.Status.ReadyReplicas),
Message: fmt.Sprintf("Waiting for %d pods to be ready", *sts.Spec.Replicas-sts.Status.ReadyReplicas),
}, nil
}
if sts.Spec.UpdateStrategy.Type == appsv1beta1.RollingUpdateStatefulSetStrategyType && sts.Spec.UpdateStrategy.RollingUpdate != nil {
if sts.Spec.Replicas != nil && sts.Spec.UpdateStrategy.RollingUpdate.Partition != nil {
if sts.Status.UpdatedReplicas < (*sts.Spec.Replicas - *sts.Spec.UpdateStrategy.RollingUpdate.Partition) {
return &HealthStatus{
Status: HealthStatusProgressing,
Message: fmt.Sprintf("Waiting for partitioned roll out to finish: %d out of %d new pods have been updated...",
Message: fmt.Sprintf("Waiting for partitioned roll out to finish: %d out of %d new pods have been updated",
sts.Status.UpdatedReplicas, (*sts.Spec.Replicas - *sts.Spec.UpdateStrategy.RollingUpdate.Partition)),
}, nil
}
}
return &HealthStatus{
Status: HealthStatusHealthy,
Message: fmt.Sprintf("partitioned roll out complete: %d new pods have been updated...", sts.Status.UpdatedReplicas),
Message: fmt.Sprintf("Partitioned roll out complete: %d new pods have been updated", sts.Status.UpdatedReplicas),
}, nil
}
if sts.Spec.UpdateStrategy.Type == appsv1beta1.OnDeleteStatefulSetStrategyType {
return &HealthStatus{
Status: HealthStatusHealthy,
Message: fmt.Sprintf("statefulset has %d ready pods", sts.Status.ReadyReplicas),
Message: fmt.Sprintf("Statefulset has %d ready pods", sts.Status.ReadyReplicas),
}, nil
}
if sts.Status.UpdateRevision != sts.Status.CurrentRevision {
return &HealthStatus{
Status: HealthStatusProgressing,
Message: fmt.Sprintf("waiting for statefulset rolling update to complete %d pods at revision %s...", sts.Status.UpdatedReplicas, sts.Status.UpdateRevision),
Message: fmt.Sprintf("Waiting for statefulset rolling update to complete %d pods at revision %s", sts.Status.UpdatedReplicas, sts.Status.UpdateRevision),
}, nil
}
return &HealthStatus{
Status: HealthStatusHealthy,
Message: fmt.Sprintf("statefulset rolling update complete %d pods at revision %s...", sts.Status.CurrentReplicas, sts.Status.CurrentRevision),
Message: fmt.Sprintf("Statefulset rolling update complete %d pods at revision %s", sts.Status.CurrentReplicas, sts.Status.CurrentRevision),
}, nil
}

Expand All @@ -144,44 +144,44 @@ func getAppsv1beta2StatefulSetHealth(sts *appsv1beta2.StatefulSet) (*HealthStatu
if sts.Status.ObservedGeneration == 0 || sts.Generation > sts.Status.ObservedGeneration {
return &HealthStatus{
Status: HealthStatusProgressing,
Message: "Waiting for statefulset spec update to be observed...",
Message: "Waiting for statefulset spec update to be observed",
}, nil
}
if sts.Spec.Replicas != nil && sts.Status.ReadyReplicas < *sts.Spec.Replicas {
return &HealthStatus{
Status: HealthStatusProgressing,
Message: fmt.Sprintf("Waiting for %d pods to be ready...", *sts.Spec.Replicas-sts.Status.ReadyReplicas),
Message: fmt.Sprintf("Waiting for %d pods to be ready", *sts.Spec.Replicas-sts.Status.ReadyReplicas),
}, nil
}
if sts.Spec.UpdateStrategy.Type == appsv1beta2.RollingUpdateStatefulSetStrategyType && sts.Spec.UpdateStrategy.RollingUpdate != nil {
if sts.Spec.Replicas != nil && sts.Spec.UpdateStrategy.RollingUpdate.Partition != nil {
if sts.Status.UpdatedReplicas < (*sts.Spec.Replicas - *sts.Spec.UpdateStrategy.RollingUpdate.Partition) {
return &HealthStatus{
Status: HealthStatusProgressing,
Message: fmt.Sprintf("Waiting for partitioned roll out to finish: %d out of %d new pods have been updated...",
Message: fmt.Sprintf("Waiting for partitioned roll out to finish: %d out of %d new pods have been updated",
sts.Status.UpdatedReplicas, (*sts.Spec.Replicas - *sts.Spec.UpdateStrategy.RollingUpdate.Partition)),
}, nil
}
}
return &HealthStatus{
Status: HealthStatusHealthy,
Message: fmt.Sprintf("partitioned roll out complete: %d new pods have been updated...", sts.Status.UpdatedReplicas),
Message: fmt.Sprintf("Partitioned roll out complete: %d new pods have been updated", sts.Status.UpdatedReplicas),
}, nil
}
if sts.Spec.UpdateStrategy.Type == appsv1beta2.OnDeleteStatefulSetStrategyType {
return &HealthStatus{
Status: HealthStatusHealthy,
Message: fmt.Sprintf("statefulset has %d ready pods", sts.Status.ReadyReplicas),
Message: fmt.Sprintf("Statefulset has %d ready pods", sts.Status.ReadyReplicas),
}, nil
}
if sts.Status.UpdateRevision != sts.Status.CurrentRevision {
return &HealthStatus{
Status: HealthStatusProgressing,
Message: fmt.Sprintf("waiting for statefulset rolling update to complete %d pods at revision %s...", sts.Status.UpdatedReplicas, sts.Status.UpdateRevision),
Message: fmt.Sprintf("Waiting for statefulset rolling update to complete %d pods at revision %s", sts.Status.UpdatedReplicas, sts.Status.UpdateRevision),
}, nil
}
return &HealthStatus{
Status: HealthStatusHealthy,
Message: fmt.Sprintf("statefulset rolling update complete %d pods at revision %s...", sts.Status.CurrentReplicas, sts.Status.CurrentRevision),
Message: fmt.Sprintf("Statefulset rolling update complete %d pods at revision %s", sts.Status.CurrentReplicas, sts.Status.CurrentRevision),
}, nil
}