Skip to content
Merged
Show file tree
Hide file tree
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
14 changes: 14 additions & 0 deletions common-lib/utils/k8s/health/health_pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,20 @@ func getCorev1PodHealth(pod *corev1.Pod) (*HealthStatus, error) {
}
}

for i, cs := range pod.Status.InitContainerStatuses {
if i < len(pod.Spec.InitContainers) &&
pod.Spec.InitContainers[i].RestartPolicy != nil &&
*pod.Spec.InitContainers[i].RestartPolicy == corev1.ContainerRestartPolicyAlways {
waiting := cs.State.Waiting
if waiting != nil && (strings.HasPrefix(waiting.Reason, "Err") ||
strings.HasSuffix(waiting.Reason, "Error") ||
strings.HasSuffix(waiting.Reason, "BackOff")) {
status = HealthStatusDegraded
messages = append(messages, waiting.Message)
}
}
}

if status != "" {
return &HealthStatus{
Status: status,
Expand Down
14 changes: 14 additions & 0 deletions common-lib/utils/k8sObjectsUtil/ResourceTreeUtil.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ func PopulatePodInfo(un *unstructured.Unstructured) ([]commonBean.InfoItem, erro

initializing := false
for i := range pod.Status.InitContainerStatuses {
if pod.Spec.InitContainers[i].RestartPolicy != nil &&
*pod.Spec.InitContainers[i].RestartPolicy == v1.ContainerRestartPolicyAlways {
continue // native sidecar — not a blocking init container
}
container := pod.Status.InitContainerStatuses[i]
restarts += int(container.RestartCount)
switch {
Expand All @@ -243,6 +247,16 @@ func PopulatePodInfo(un *unstructured.Unstructured) ([]commonBean.InfoItem, erro
}
break
}
for i, cs := range pod.Status.InitContainerStatuses {
if pod.Spec.InitContainers[i].RestartPolicy != nil &&
*pod.Spec.InitContainers[i].RestartPolicy == v1.ContainerRestartPolicyAlways {
totalContainers++
restarts += int(cs.RestartCount)
if cs.Ready && cs.State.Running != nil {
readyContainers++
}
}
}
if !initializing {
restarts = 0
hasRunning := false
Expand Down
2 changes: 1 addition & 1 deletion kubelink/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,4 @@ require (
sigs.k8s.io/structured-merge-diff/v4 v4.7.0 // indirect
)

replace github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20260227055702-7fe9d47354a0
replace github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20260402084407-a92702e8f0ff
4 changes: 2 additions & 2 deletions kubelink/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20260227055702-7fe9d47354a0 h1:KnmMU3qEy/QRtEJaUQNnXvCrintij+BYhOJtw+OjxYw=
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20260227055702-7fe9d47354a0/go.mod h1:d6awSGcXQc57s4PJlwcyACovJ4PgBmR9jZJ7h6CScUM=
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20260402084407-a92702e8f0ff h1:bn6Z1AlHMd8+gBZjMCHr0kE7a+QKL3ZPTlsP3rT5vp8=
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20260402084407-a92702e8f0ff/go.mod h1:d6awSGcXQc57s4PJlwcyACovJ4PgBmR9jZJ7h6CScUM=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/distribution/distribution/v3 v3.0.0 h1:q4R8wemdRQDClzoNNStftB2ZAfqOiN6UX90KJc4HjyM=
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions kubelink/vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ github.com/cyphar/filepath-securejoin
# github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
## explicit
github.com/davecgh/go-spew/spew
# github.com/devtron-labs/common-lib v0.0.0 => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20260227055702-7fe9d47354a0
# github.com/devtron-labs/common-lib v0.0.0 => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20260402084407-a92702e8f0ff
## explicit; go 1.24.0
github.com/devtron-labs/common-lib/async
github.com/devtron-labs/common-lib/constants
Expand Down Expand Up @@ -1403,4 +1403,4 @@ sigs.k8s.io/structured-merge-diff/v4/value
sigs.k8s.io/yaml
sigs.k8s.io/yaml/goyaml.v2
sigs.k8s.io/yaml/goyaml.v3
# github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20260227055702-7fe9d47354a0
# github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20260402084407-a92702e8f0ff
Loading