You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2022/09/28 06:04:32 UTC

[GitHub] [inlong] GanfengTan opened a new pull request, #6048: [INLONG-6047][Agent] Fix file could not be matched in the k8s

GanfengTan opened a new pull request, #6048:
URL: https://github.com/apache/inlong/pull/6048

    Fix file could not be matched in the k8s.
    Add a Regular Expression.
   - Fixes #6047 
   
   ### Motivation
   The file name in the soft link path must be matched with the regular.
   
   ### Modifications
   
   Add a util
   
   ### Verifying this change
   
   *(Please pick either of the following options)*
   
   - [x] This change is a trivial rework/code cleanup without any test coverage.
   
   - [ ] This change is already covered by existing tests, such as:
     *(please describe tests)*
   
   - [ ] This change added tests and can be verified as follows:
   


-- 
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: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] healchow commented on a diff in pull request #6048: [INLONG-6047][Agent] Fix file could not be matched in the k8s

Posted by GitBox <gi...@apache.org>.
healchow commented on code in PR #6048:
URL: https://github.com/apache/inlong/pull/6048#discussion_r982059067


##########
inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/sources/reader/file/KubernetesFileReader.java:
##########
@@ -115,7 +115,7 @@ public Map<String, String> getK8sMetadata(JobProfile jobConf) {
             return null;
         }
         Map<String, String> k8sInfo = MetaDataUtils.getLogInfo(fileReaderOperator.file.getName());
-        log.info("k8s information size:{}", k8sInfo.size());
+        log.info("file name is:{},k8s information size:{}", fileReaderOperator.file.getName(), k8sInfo.size());

Review Comment:
   ```suggestion
           log.info("file name is: {}, k8s information size: {}", fileReaderOperator.file.getName(), k8sInfo.size());
   ```



-- 
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: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] healchow commented on a diff in pull request #6048: [INLONG-6047][Agent] Fix file could not be matched in the k8s

Posted by GitBox <gi...@apache.org>.
healchow commented on code in PR #6048:
URL: https://github.com/apache/inlong/pull/6048#discussion_r982058197


##########
inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/utils/MetaDataUtils.java:
##########
@@ -47,16 +49,17 @@ public class MetaDataUtils {
     private static final String LOG_MARK = ".log";
 
     // standard log path for k8s
-    private static final String STANDARD_OUT = "/var/log/containers";
+    private static final String FILE_NAME_PATTERN = "(^[-a-zA-Z0-9]+)_([a-zA-Z0-9-]+)_([a-zA-Z0-9-]+)(.log)";
 
     /**
      * standard log for k8s
      *
      * get pod_name,namespace,container_name,container_id
      */
     public static Map<String, String> getLogInfo(String fileName) {
+        Matcher matcher = Pattern.compile(FILE_NAME_PATTERN).matcher(fileName);

Review Comment:
   Suggested extracting the `Pattern.compile` to a static final field, it is more efficient.



-- 
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: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] dockerzhang merged pull request #6048: [INLONG-6047][Agent] Fix file could not be matched in the k8s

Posted by GitBox <gi...@apache.org>.
dockerzhang merged PR #6048:
URL: https://github.com/apache/inlong/pull/6048


-- 
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: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] GanfengTan commented on a diff in pull request #6048: [INLONG-6047][Agent] Fix file could not be matched in the k8s

Posted by GitBox <gi...@apache.org>.
GanfengTan commented on code in PR #6048:
URL: https://github.com/apache/inlong/pull/6048#discussion_r982071894


##########
inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/utils/MetaDataUtils.java:
##########
@@ -47,16 +49,17 @@ public class MetaDataUtils {
     private static final String LOG_MARK = ".log";
 
     // standard log path for k8s
-    private static final String STANDARD_OUT = "/var/log/containers";
+    private static final String FILE_NAME_PATTERN = "(^[-a-zA-Z0-9]+)_([a-zA-Z0-9-]+)_([a-zA-Z0-9-]+)(.log)";
 
     /**
      * standard log for k8s
      *
      * get pod_name,namespace,container_name,container_id
      */
     public static Map<String, String> getLogInfo(String fileName) {
+        Matcher matcher = Pattern.compile(FILE_NAME_PATTERN).matcher(fileName);

Review Comment:
   done



##########
inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/sources/reader/file/KubernetesFileReader.java:
##########
@@ -115,7 +115,7 @@ public Map<String, String> getK8sMetadata(JobProfile jobConf) {
             return null;
         }
         Map<String, String> k8sInfo = MetaDataUtils.getLogInfo(fileReaderOperator.file.getName());
-        log.info("k8s information size:{}", k8sInfo.size());
+        log.info("file name is:{},k8s information size:{}", fileReaderOperator.file.getName(), k8sInfo.size());

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: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org