Skip to content

Commit

Permalink
improve ingress health check
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe committed Apr 4, 2024
1 parent a5e19a7 commit 1a41115
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/health/health_ingress.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
package health

import (
"fmt"

"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
)

func getIngressHealth(obj *unstructured.Unstructured) (*HealthStatus, error) {
ingresses, _, _ := unstructured.NestedSlice(obj.Object, "status", "loadBalancer", "ingress")
ingresses, found, err := unstructured.NestedSlice(obj.Object, "status", "loadBalancer", "ingress")
if err != nil {
return &HealthStatus{Status: HealthStatusError, Message: fmt.Sprintf("failed to ingress status: %v", err)}, nil
} else if !found {
return &HealthStatus{Status: HealthStatusPending, Message: "ingress loadbalancer status not found"}, nil
}

health := HealthStatus{}
if len(ingresses) > 0 {
health.Status = HealthStatusHealthy
Expand Down

0 comments on commit 1a41115

Please sign in to comment.