Unverified Commit 0b0d97f5 authored by star's avatar star Committed by GitHub
Browse files

Fix correct deploy extend api get events right (#3)


* Fix correct deploy extend api get events right

* Fix fmt
Co-authored-by: default avatarfusida <fusida@corp.netease.com>
parent 84b6adb8
Showing with 28 additions and 1 deletion
+28 -1
......@@ -197,7 +197,9 @@ func (d *Deployment) getWarningEventsByPodList(podList corev1.PodList) (resource
// kubectl get ev --field-selector="involvedObject.uid=1a58441c-3c03-4267-85d1-a81f0c268d62,type=Warning"
resultEventList := make(resources.K8sJsonArr, 0)
for _, pod := range podList.Items {
if isPodReadyOrSucceed(pod) {
continue
}
fieldSelector := make(map[string]string)
fieldSelector["involvedObject.uid"] = string(pod.GetUID())
fieldSelector["type"] = "Warning"
......@@ -224,3 +226,28 @@ func (d *Deployment) getWarningEventsByPodList(podList corev1.PodList) (resource
}
return resultEventList, nil
}
func isPodReadyOrSucceed(pod corev1.Pod) bool {
if pod.Status.Phase == "" {
return true
}
if pod.Status.Phase == "Succeeded" {
return true
}
if pod.Status.Phase == "Running" {
conditions := pod.Status.Conditions
if len(conditions) == 0 {
return true
}
for _, cond := range conditions {
if cond.Type == "Ready" && cond.Status == "False" {
return false
}
}
return true
}
return false
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment