You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/04/08 02:50:34 UTC

[GitHub] [flink-kubernetes-operator] wangyang0918 commented on a diff in pull request #160: [FLINK-27124] Flink Kubernetes operator prints starting logs with wrong version

wangyang0918 commented on code in PR #160:
URL: https://github.com/apache/flink-kubernetes-operator/pull/160#discussion_r845685451


##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/utils/EnvUtils.java:
##########
@@ -68,4 +90,102 @@ public static String getRequired(String key) {
         }
         return value;
     }
+
+    /**
+     * Logs information about the environment, like code revision, current user, Java version, and
+     * JVM parameters.
+     *
+     * @param log The logger to log the information to.
+     * @param componentName The component name to mention in the log.
+     * @param commandLineArgs The arguments accompanying the starting the component.
+     */
+    public static void logEnvironmentInfo(
+            Logger log, String componentName, String[] commandLineArgs) {
+        if (log.isInfoEnabled()) {
+            EnvironmentInformation.RevisionInformation rev = getRevisionInformation();
+            String javaHome = System.getenv("JAVA_HOME");
+            String inheritedLogs = System.getenv("FLINK_INHERITED_LOGS");
+            String arch = System.getProperty("os.arch");
+            long maxHeapMegabytes = getMaxJvmHeapMemory() >>> 20;
+            if (inheritedLogs != null) {
+                log.info(
+                        "--------------------------------------------------------------------------------");
+                log.info(" Preconfiguration: ");
+                log.info(inheritedLogs);
+            }
+            log.info(
+                    "--------------------------------------------------------------------------------");
+            log.info(
+                    " Starting "
+                            + componentName
+                            + " (Version: "
+                            + getProjectVersion()
+                            + ", Flink Version: "
+                            + getVersion()
+                            + ", Scala: "
+                            + getScalaVersion()
+                            + ", "
+                            + "Rev:"
+                            + rev.commitId
+                            + ", "
+                            + "Date:"
+                            + rev.commitDate
+                            + ")");
+            log.info(" OS current user: " + System.getProperty("user.name"));
+            log.info(" Current Hadoop/Kerberos user: " + getHadoopUser());
+            log.info(" JVM: " + getJvmVersion());
+            log.info(" Arch: " + arch);
+            log.info(" Maximum heap size: " + maxHeapMegabytes + " MiBytes");
+            log.info(" JAVA_HOME: " + (javaHome == null ? "(not set)" : javaHome));
+            String hadoopVersionString = getHadoopVersionString();

Review Comment:
   We do need the hadoop related information.



##########
flink-kubernetes-operator/src/main/resources-filtered/.flink-kubernetes-operator.version.properties:
##########
@@ -0,0 +1,16 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+project.version=${project.version}

Review Comment:
   Could we also add some git commit information here and print them in the logs?



##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/utils/EnvUtils.java:
##########
@@ -68,4 +90,102 @@ public static String getRequired(String key) {
         }
         return value;
     }
+
+    /**
+     * Logs information about the environment, like code revision, current user, Java version, and
+     * JVM parameters.
+     *
+     * @param log The logger to log the information to.
+     * @param componentName The component name to mention in the log.
+     * @param commandLineArgs The arguments accompanying the starting the component.
+     */
+    public static void logEnvironmentInfo(
+            Logger log, String componentName, String[] commandLineArgs) {
+        if (log.isInfoEnabled()) {
+            EnvironmentInformation.RevisionInformation rev = getRevisionInformation();

Review Comment:
   I am afraid we still could not get the git revision information correctly.



##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/utils/EnvUtils.java:
##########
@@ -68,4 +90,102 @@ public static String getRequired(String key) {
         }
         return value;
     }
+
+    /**
+     * Logs information about the environment, like code revision, current user, Java version, and
+     * JVM parameters.
+     *
+     * @param log The logger to log the information to.
+     * @param componentName The component name to mention in the log.
+     * @param commandLineArgs The arguments accompanying the starting the component.
+     */
+    public static void logEnvironmentInfo(
+            Logger log, String componentName, String[] commandLineArgs) {
+        if (log.isInfoEnabled()) {
+            EnvironmentInformation.RevisionInformation rev = getRevisionInformation();
+            String javaHome = System.getenv("JAVA_HOME");
+            String inheritedLogs = System.getenv("FLINK_INHERITED_LOGS");

Review Comment:
   We also do not need the `FLINK_INHERITED_LOGS` since we will never configure it.



-- 
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: issues-unsubscribe@flink.apache.org

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