Resource.create(GLOBAL_RESOURCE_ID, concurrency))); final Map<WorkflowInstance, RunState> activeStatesMap = stateManager.getActiveStates(); final List<InstanceState> activeStates = getActiveInstanceStates(activeStatesMap);
@VisibleForTesting synchronized void tryPollPods() { // Fetch pods _before_ fetching all active states final PodList list = client.pods().list(); final Map<WorkflowInstance, RunState> activeStates = stateManager.getActiveStates(); examineRunningWFISandAssociatedPods(activeStates, list); for (Pod pod : list.getItems()) { logEvent(Watcher.Action.MODIFIED, pod, list.getMetadata().getResourceVersion(), true); final Optional<WorkflowInstance> workflowInstance = readPodWorkflowInstance(pod); if (!workflowInstance.isPresent()) { continue; } final RunState runState = activeStates.get(workflowInstance.get()); if (runState != null && isPodRunState(pod, runState)) { emitPodEvents(pod, runState); cleanupWithRunState(workflowInstance.get(), pod, runState); } else { // The pod is stale as we fetched the active states _after_ listing all pods. cleanupWithoutRunState(workflowInstance.get(), pod); } } }