GanfengTan commented on code in PR #5534:
URL: https://github.com/apache/inlong/pull/5534#discussion_r944355431


##########
inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/sources/reader/file/KubernetesFileReader.java:
##########
@@ -92,11 +111,36 @@ public PodList getPods() {
     /**
      * get pod metadata by namespace and pod name
      */
-    public ObjectMeta getPodMetadata(String namespace, String podName) {
-        List<ObjectMeta> objectMetas = 
client.pods().list().getItems().stream().map(Pod::getMetadata)
-                .filter(data -> data.getName().equalsIgnoreCase(podName) && 
data.getNamespace()
-                        
.equalsIgnoreCase(namespace)).collect(Collectors.toList());
-        return CollectionUtils.isNotEmpty(objectMetas) ? objectMetas.get(0) : 
null;
+    public Map<String, String> getK8sMetadata(JobProfile jobConf) {
+        if (Objects.isNull(jobConf)) {
+            return null;
+        }
+        Map<String, String> k8sInfo = 
MetaDataUtils.getLogInfo(fileReaderOperator.file.getName());
+        if (k8sInfo.isEmpty()) {
+            return null;
+        }
+        List<String> namespaces = MetaDataUtils.getNamespace(jobConf);
+        if (Objects.isNull(namespaces) || namespaces.isEmpty()) {
+            return null;
+        }
+        if (!namespaces.contains(k8sInfo.get(NAMESPACE))) {
+            return null;
+        }
+        Pod pod = 
client.pods().inNamespace(k8sInfo.get(NAMESPACE)).withName(k8sInfo.get(POD_NAME)).get();
+        PodList podList = client.pods().inNamespace(k8sInfo.get(NAMESPACE))
+                .withLabels(MetaDataUtils.getPodLabels(jobConf)).list();
+        Gson gson = new Gson();

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to