Filtering pods not in 'Running' phase (#2771)

* Filtering pods not in 'Running' phase

* Amending checkstyle errors
This commit is contained in:
Gao Hongtao 2019-05-28 16:05:36 +08:00 committed by 吴晟 Wu Sheng
parent bcdf1c4bd5
commit 4f89ea2704
1 changed files with 8 additions and 1 deletions

View File

@ -63,6 +63,8 @@ public class K8sALSServiceMeshHTTPAnalysis implements ALSHTTPAnalysis {
private static final String ADDRESS_TYPE_INTERNAL_IP = "InternalIP";
private static final String VALID_PHASE = "Running";
@Getter(AccessLevel.PROTECTED)
private final AtomicReference<Map<String, ServiceMetaInfo>> ipServiceMap = new AtomicReference<>();
@ -93,8 +95,13 @@ public class K8sALSServiceMeshHTTPAnalysis implements ALSHTTPAnalysis {
Map<String, ServiceMetaInfo> ipMap = new HashMap<>(list.getItems().size());
long startTime = System.nanoTime();
for (V1Pod item : list.getItems()) {
if (!item.getStatus().getPhase().equals(VALID_PHASE)) {
logger.debug("Invalid pod {} is not in a valid phase {}", item.getMetadata().getName(), item.getStatus().getPhase());
continue;
}
if (item.getStatus().getPodIP().equals(item.getStatus().getHostIP())) {
logger.warn("Pod {}.{} is removed because hostIP and podIP are identical ", item.getMetadata().getName());
logger.debug("Pod {}.{} is removed because hostIP and podIP are identical ", item.getMetadata().getName(),
item.getMetadata().getNamespace());
continue;
}
ipMap.put(item.getStatus().getPodIP(), createServiceMetaInfo(item.getMetadata()));