Skip to content

Commit

Permalink
When the pod phase is running, the status reason is also set to runni…
Browse files Browse the repository at this point in the history
…ng (#367)
  • Loading branch information
dciangot authored Jan 29, 2025
2 parents 8d52792 + ec47420 commit 2f86cd1
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pkg/virtualkubelet/execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,7 @@ func handleContainersUpdate(ctx context.Context, podRemoteStatus types.PodStatus
podRunning = true
log.G(ctx).Debug("Pod " + podRemoteStatus.PodName + ": Service " + containerRemoteStatus.Name + " is running on Sidecar")
podRefInCluster.Status.ContainerStatuses[index].Ready = true
podRefInCluster.Status.ContainerStatuses[index].State.Running = containerRemoteStatus.State.Running
}
}
}
Expand Down Expand Up @@ -712,10 +713,16 @@ func checkPodsStatus(ctx context.Context, p *Provider, podsList []*v1.Pod, token
failedReason := ""
failedReasonInit := ""

nContainersInPod := len(podRemoteStatus.Containers)
nContainersInPod := 0
if podRemoteStatus.Containers != nil {
nContainersInPod = len(podRemoteStatus.Containers)
}
counterOfTerminatedContainers := 0

nInitContainersInPod := len(podRemoteStatus.InitContainers)
nInitContainersInPod := 0
if podRemoteStatus.InitContainers != nil {
nInitContainersInPod = len(podRemoteStatus.InitContainers)
}
counterOfTerminatedInitContainers := 0

log.G(ctx).Debug("Number of containers in POD: " + strconv.Itoa(nContainersInPod))
Expand Down Expand Up @@ -771,6 +778,7 @@ func checkPodsStatus(ctx context.Context, p *Provider, podsList []*v1.Pod, token
if podRunning && podRefInCluster.Status.Phase != v1.PodRunning { // do not update the status if it is already running
podRefInCluster.Status.Phase = v1.PodRunning
podRefInCluster.Status.Conditions = append(podRefInCluster.Status.Conditions, v1.PodCondition{Type: v1.PodReady, Status: v1.ConditionTrue})
podRefInCluster.Status.Reason = "Running"
}
}
} else {
Expand Down

0 comments on commit 2f86cd1

Please sign in to comment.