Skip to content

Commit

Permalink
fix: use "Terminating" instead of "Deleteting" for k8s health
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe committed May 31, 2024
1 parent 0f8fbf3 commit 658edf9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion pkg/health/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const (
HealthStatusCreating HealthStatusCode = "Creating"
HealthStatusDeleted HealthStatusCode = "Deleted"
HealthStatusDeleting HealthStatusCode = "Deleting"
HealthStatusTerminating HealthStatusCode = "Terminating"
HealthStatusError HealthStatusCode = "Error"
HealthStatusRolloutFailed HealthStatusCode = "Rollout Failed"
HealthStatusInaccesible HealthStatusCode = "Inaccesible"
Expand Down Expand Up @@ -121,7 +122,7 @@ func GetResourceHealth(obj *unstructured.Unstructured, healthOverride HealthOver

if obj.GetDeletionTimestamp() != nil {
return &HealthStatus{
Status: HealthStatusDeleting,
Status: HealthStatusTerminating,
}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/health/health_namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ func getNamespaceHealth(obj *unstructured.Unstructured) (*HealthStatus, error) {

return &HealthStatus{
Health: HealthUnknown,
Status: HealthStatusDeleting,
Status: HealthStatusTerminating,
}, nil
}
4 changes: 2 additions & 2 deletions pkg/health/health_pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ func getCorev1PodHealth(pod *corev1.Pod) (*HealthStatus, error) {
if pod.ObjectMeta.DeletionTimestamp != nil && !pod.ObjectMeta.DeletionTimestamp.IsZero() {
if isReady {
return &HealthStatus{
Status: HealthStatusDeleting,
Status: HealthStatusTerminating,
Ready: false,
Health: HealthHealthy,
}, nil
} else {
return &HealthStatus{
Status: HealthStatusDeleting,
Status: HealthStatusTerminating,
Ready: false,
Health: HealthUnhealthy,
}, nil
Expand Down
4 changes: 2 additions & 2 deletions pkg/health/health_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func getHealthStatus(yamlPath string, t *testing.T) *health.HealthStatus {

func TestNamespace(t *testing.T) {
assertAppHealth(t, "./testdata/namespace.yaml", health.HealthStatusHealthy, health.HealthUnknown, true)
assertAppHealth(t, "./testdata/namespace-terminating.yaml", health.HealthStatusDeleting, health.HealthUnknown, false)
assertAppHealth(t, "./testdata/namespace-terminating.yaml", health.HealthStatusTerminating, health.HealthUnknown, false)
}

func TestCertificate(t *testing.T) {
Expand Down Expand Up @@ -130,7 +130,7 @@ func TestPod(t *testing.T) {
assertAppHealth(t, "./testdata/pod-running-restart-onfailure.yaml", health.HealthStatusRunning, health.HealthUnhealthy, false)
assertAppHealth(t, "./testdata/pod-failed.yaml", health.HealthStatusError, health.HealthUnhealthy, true)
assertAppHealth(t, "./testdata/pod-succeeded.yaml", health.HealthStatusCompleted, health.HealthHealthy, true)
assertAppHealth(t, "./testdata/pod-deletion.yaml", health.HealthStatusDeleting, health.HealthUnhealthy, false)
assertAppHealth(t, "./testdata/pod-deletion.yaml", health.HealthStatusTerminating, health.HealthUnhealthy, false)
}

// func TestAPIService(t *testing.T) {
Expand Down

0 comments on commit 658edf9

Please sign in to comment.