Handled resource kind PodDisruptionBudget and CRD for health status. (#448)

* Handled resource kind PodDisruptionBudget and CRD for health status.

* Handled resource kind PodDisruptionBudget and CRD for health status.

---------

Co-authored-by: vkumar3 <vkumar@aarnanetworks.com>
This commit is contained in:
Vikas Kumar
2023-07-29 02:31:56 +05:30
committed by GitHub
parent 64331ad33a
commit 0b354331d5

View File

@@ -82,6 +82,7 @@ func EnhanceStatus(res *v12.Carp, err error) *v12.CarpStatus {
c.Status = Unhealthy
} else if slices.Contains([]string{"Available", "Active", "Established", "Bound", "Ready"}, string(s.Phase)) {
c.Status = Healthy
c.Reason = "Exists" //since there is no condition to check here, we can set reason as exists.
} else if s.Phase == "" && len(s.Conditions) > 0 {
for _, cond := range s.Conditions {
if cond.Type == "Progressing" { // https://kubernetes.io/docs/concepts/workloads/controllers/deployment/
@@ -102,6 +103,22 @@ func EnhanceStatus(res *v12.Carp, err error) *v12.CarpStatus {
}
c.Reason = cond.Reason
c.Message = cond.Message
} else if cond.Type == "DisruptionAllowed" && c.Status == Unknown { //condition for PodDisruptionBudget
if cond.Status == "False" {
c.Status = Unhealthy
} else {
c.Status = Healthy
}
c.Reason = cond.Reason
c.Message = cond.Message
} else if (cond.Type == "Established" || cond.Type == "NamesAccepted") && (c.Status == Unknown || c.Status == Healthy) { //condition for CRD
if cond.Status == "False" {
c.Status = Unhealthy
} else {
c.Status = Healthy
}
c.Reason = cond.Reason
c.Message = cond.Message
}
}
} else if s.Phase == "Pending" {