Skip to content

Commit 56db4ec

Browse files
committed
Minor refactoring
1 parent 5c74ebd commit 56db4ec

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

phpfpm/pod_discovery.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func (pm *PoolManager) handlePodRunning(exporter *Exporter, pod *v1.Pod, uri str
9898
ip := pod.Status.PodIP
9999
podName := pod.Name
100100
if ip != "" {
101-
log.Infof("New running pod detected %s with IP %s", podName, ip)
101+
log.Infof("Pod in Running state detected %s with IP %s. Adding in the Pool Manager..", podName, ip)
102102
pm.Add(uri)
103103
exporter.UpdatePoolManager(*pm)
104104
} else {
@@ -119,13 +119,15 @@ func (pm *PoolManager) processPodAdded(exporter *Exporter, pod *v1.Pod, uri stri
119119
// To be included in the pool manager, the pod must be in the "Running" phase. The function checks the pod's current phase
120120
// and, if it is running, calls handlePodRunning to append the pod to the pool manager's PodPhases.
121121
func (pm *PoolManager) processPodModified(exporter *Exporter, pod *v1.Pod, uri string) {
122-
lastPhase, exists := pm.PodPhases[pod.Name]
122+
podName := pod.Name
123+
currentPhase := pod.Status.Phase
124+
lastPhase, exists := pm.PodPhases[podName]
123125

124-
if exists && lastPhase == v1.PodPending && pod.Status.Phase == v1.PodRunning {
125-
log.Infof("Pod %s transitioned from Pending to Running", pod.Name)
126+
if exists && lastPhase == v1.PodPending && currentPhase == v1.PodRunning {
127+
log.Infof("Pod %s transitioned from Pending to Running", podName)
126128
pm.handlePodRunning(exporter, pod, uri)
127129
}
128-
pm.PodPhases[pod.Name] = pod.Status.Phase
130+
pm.PodPhases[podName] = currentPhase
129131
}
130132

131133
// processPodDeleted handles the removal of a pods URI from the pool manager's PodPhases.

0 commit comments

Comments
 (0)