Skip to content

Commit 9050c51

Browse files
committed
Remove unused variables from computePodPhase
The initialized and failed variables in the computePodPhase function are effectively write only. Remove them.
1 parent c082ace commit 9050c51

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

pkg/kubelet/kubelet_pods.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,7 +1220,6 @@ func (kl *Kubelet) GetKubeletContainerLogs(ctx context.Context, podFullName, con
12201220

12211221
// getPhase returns the phase of a pod given its container info.
12221222
func getPhase(spec *v1.PodSpec, info []v1.ContainerStatus) v1.PodPhase {
1223-
initialized := 0
12241223
pendingInitialization := 0
12251224
failedInitialization := 0
12261225
for _, container := range spec.InitContainers {
@@ -1234,16 +1233,12 @@ func getPhase(spec *v1.PodSpec, info []v1.ContainerStatus) v1.PodPhase {
12341233
case containerStatus.State.Running != nil:
12351234
pendingInitialization++
12361235
case containerStatus.State.Terminated != nil:
1237-
if containerStatus.State.Terminated.ExitCode == 0 {
1238-
initialized++
1239-
} else {
1236+
if containerStatus.State.Terminated.ExitCode != 0 {
12401237
failedInitialization++
12411238
}
12421239
case containerStatus.State.Waiting != nil:
12431240
if containerStatus.LastTerminationState.Terminated != nil {
1244-
if containerStatus.LastTerminationState.Terminated.ExitCode == 0 {
1245-
initialized++
1246-
} else {
1241+
if containerStatus.LastTerminationState.Terminated.ExitCode != 0 {
12471242
failedInitialization++
12481243
}
12491244
} else {
@@ -1258,7 +1253,6 @@ func getPhase(spec *v1.PodSpec, info []v1.ContainerStatus) v1.PodPhase {
12581253
running := 0
12591254
waiting := 0
12601255
stopped := 0
1261-
failed := 0
12621256
succeeded := 0
12631257
for _, container := range spec.Containers {
12641258
containerStatus, ok := podutil.GetContainerStatus(info, container.Name)
@@ -1274,8 +1268,6 @@ func getPhase(spec *v1.PodSpec, info []v1.ContainerStatus) v1.PodPhase {
12741268
stopped++
12751269
if containerStatus.State.Terminated.ExitCode == 0 {
12761270
succeeded++
1277-
} else {
1278-
failed++
12791271
}
12801272
case containerStatus.State.Waiting != nil:
12811273
if containerStatus.LastTerminationState.Terminated != nil {

0 commit comments

Comments
 (0)