MCPcopy Create free account
hub / github.com/devspace-sh/devspace / checkPod

Function checkPod

pkg/devspace/analyze/pods.go:135–193  ·  view source on GitHub ↗

Pod analyzes the pod for potential problems

(client kubectl.Client, pod *v1.Pod, ignoreContainerRestarts bool)

Source from the content-addressed store, hash-verified

133
134// Pod analyzes the pod for potential problems
135func checkPod(client kubectl.Client, pod *v1.Pod, ignoreContainerRestarts bool) *podProblem {
136 hasProblem := false
137 podProblem := &podProblem{
138 Name: pod.Name,
139 Status: kubectl.GetPodStatus(pod),
140 Age: time.Since(pod.CreationTimestamp.Time).Round(time.Second).String(),
141 ContainerProblems: []*containerProblem{},
142 InitContainerProblems: []*containerProblem{},
143 }
144
145 // Check for unusual status
146 if _, ok := kubectl.OkayStatus[podProblem.Status]; !ok {
147 if !strings.HasPrefix(podProblem.Status, "Init") {
148 hasProblem = true
149 }
150 }
151
152 // Analyze container status
153 if pod.Status.ContainerStatuses != nil {
154 podProblem.ContainerTotal = len(pod.Status.ContainerStatuses)
155
156 for _, containerStatus := range pod.Status.ContainerStatuses {
157 containerProblem := getContainerProblem(client, pod, &containerStatus, ignoreContainerRestarts)
158 if containerProblem != nil {
159 hasProblem = true
160
161 podProblem.ContainerProblems = append(podProblem.ContainerProblems, containerProblem)
162 }
163
164 if containerStatus.Ready {
165 podProblem.ContainerReady++
166 }
167 }
168 }
169
170 // Analyze init container status
171 if pod.Status.InitContainerStatuses != nil {
172 podProblem.InitContainerTotal = len(pod.Status.ContainerStatuses)
173
174 for _, containerStatus := range pod.Status.InitContainerStatuses {
175 containerProblem := getContainerProblem(client, pod, &containerStatus, ignoreContainerRestarts)
176 if containerProblem != nil {
177 hasProblem = true
178
179 podProblem.InitContainerProblems = append(podProblem.InitContainerProblems, containerProblem)
180 }
181
182 if containerStatus.Ready {
183 podProblem.InitContainerReady++
184 }
185 }
186 }
187
188 if hasProblem {
189 return podProblem
190 }
191
192 return nil

Callers 1

podsMethod · 0.85

Calls 3

GetPodStatusFunction · 0.92
getContainerProblemFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected