argoyal2212 commented on code in PR #29157:
URL: https://github.com/apache/flink/pull/29157#discussion_r4471049779


##########
flink-runtime/src/main/java/org/apache/flink/runtime/rest/util/EnvironmentInfoUtils.java:
##########
@@ -0,0 +1,79 @@
+/*
+ * 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.
+ */
+
+package org.apache.flink.runtime.rest.util;
+
+/**
+ * Helper utility class to retrieve the YARN container environment context. 
This relies on the
+ * standard environment variables that YARN's NodeManager exports into every 
launched container, so
+ * it intentionally avoids adding a dependency on the YARN client libraries.
+ */
+public class EnvironmentInfoUtils {
+
+    private static final String ENV_CONTAINER_ID = "CONTAINER_ID";
+    private static final String ENV_NM_HOST = "NM_HOST";
+    private static final String ENV_NM_HTTP_PORT = "NM_HTTP_PORT";
+    private static final String ENV_USER = "USER";
+
+    /** Class that holds the application environment context. */
+    public static class EnvironmentContext {
+
+        public final String containerId;
+
+        public final String nodeManagerHostName;
+
+        public final String nodeManagerHttpPort;
+
+        public final String user;
+
+        public EnvironmentContext(
+                String containerId,
+                String nodeManagerHostName,
+                String nodeManagerHttpPort,
+                String user) {
+            this.containerId = containerId;
+            this.nodeManagerHostName = nodeManagerHostName;
+            this.nodeManagerHttpPort = nodeManagerHttpPort;
+            this.user = user;
+        }
+    }
+
+    public static EnvironmentContext getEnvironmentContext() {

Review Comment:
   Good catch, env is now validated once and we fall back to the generated 
handlers when anything is missing.



##########
flink-runtime/src/main/java/org/apache/flink/runtime/rest/util/EnvironmentInfoUtils.java:
##########
@@ -0,0 +1,79 @@
+/*
+ * 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.
+ */
+
+package org.apache.flink.runtime.rest.util;
+
+/**
+ * Helper utility class to retrieve the YARN container environment context. 
This relies on the
+ * standard environment variables that YARN's NodeManager exports into every 
launched container, so
+ * it intentionally avoids adding a dependency on the YARN client libraries.
+ */
+public class EnvironmentInfoUtils {

Review Comment:
   Done, it's @Internal, final, and takes an env map so the real path is 
testable.



##########
flink-core/src/main/java/org/apache/flink/configuration/HistoryServerOptions.java:
##########
@@ -75,6 +75,18 @@ public class HistoryServerOptions {
                                     + " with replacing the special 
placeholders, `<jobid>`, to the id of job."
                                     + " Only http / https schemes are 
supported.");
 
+    public static final ConfigOption<Boolean>
+            HISTORY_SERVER_JOBMANAGER_TASKMANAGER_LOG_ENABLE_CUSTOM_HANDLERS =
+                    key("historyserver.yarn.log.enable-custom-url-handlers")

Review Comment:
   Kept the key for now but the description now says it goes on the job 
cluster, happy to rename if you prefer a JM scoped key.



##########
flink-core/src/main/java/org/apache/flink/configuration/HistoryServerOptions.java:
##########
@@ -75,6 +75,18 @@ public class HistoryServerOptions {
                                     + " with replacing the special 
placeholders, `<jobid>`, to the id of job."
                                     + " Only http / https schemes are 
supported.");
 
+    public static final ConfigOption<Boolean>
+            HISTORY_SERVER_JOBMANAGER_TASKMANAGER_LOG_ENABLE_CUSTOM_HANDLERS =
+                    key("historyserver.yarn.log.enable-custom-url-handlers")
+                            .booleanType()
+                            .noDefaultValue()

Review Comment:
   Done, defaults to false now and the generated docs are updated.



##########
flink-core/src/main/java/org/apache/flink/configuration/HistoryServerOptions.java:
##########
@@ -75,6 +75,18 @@ public class HistoryServerOptions {
                                     + " with replacing the special 
placeholders, `<jobid>`, to the id of job."
                                     + " Only http / https schemes are 
supported.");
 
+    public static final ConfigOption<Boolean>
+            HISTORY_SERVER_JOBMANAGER_TASKMANAGER_LOG_ENABLE_CUSTOM_HANDLERS =
+                    key("historyserver.yarn.log.enable-custom-url-handlers")
+                            .booleanType()
+                            .noDefaultValue()
+                            .withDescription(
+                                    "Enable custom URL handlers for JobManager 
and TaskManager logs. The HistoryServer will generate a URL based"

Review Comment:
   Fixed, the description now says history server url patterns take precedence 
and mentions YARN and the env vars.



##########
flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/cluster/JobManagerLogUrlHandler.java:
##########
@@ -0,0 +1,107 @@
+/*
+ * 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.
+ */
+
+package org.apache.flink.runtime.rest.handler.cluster;
+
+import org.apache.flink.annotation.VisibleForTesting;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.runtime.rest.handler.AbstractRestHandler;
+import org.apache.flink.runtime.rest.handler.HandlerRequest;
+import org.apache.flink.runtime.rest.handler.RestHandlerException;
+import org.apache.flink.runtime.rest.messages.EmptyRequestBody;
+import org.apache.flink.runtime.rest.messages.JobIDPathParameter;
+import org.apache.flink.runtime.rest.messages.JobManagerLogUrlHeaders;
+import org.apache.flink.runtime.rest.messages.JobMessageParameters;
+import org.apache.flink.runtime.rest.messages.LogUrlResponse;
+import org.apache.flink.runtime.rest.messages.MessageHeaders;
+import org.apache.flink.runtime.rest.messages.ResponseBody;
+import org.apache.flink.runtime.rest.util.EnvironmentInfoUtils;
+import org.apache.flink.runtime.scheduler.ExecutionGraphInfo;
+import org.apache.flink.runtime.webmonitor.RestfulGateway;
+import org.apache.flink.runtime.webmonitor.history.ArchivedJson;
+import org.apache.flink.runtime.webmonitor.history.JsonArchivist;
+import org.apache.flink.runtime.webmonitor.retriever.GatewayRetriever;
+
+import javax.annotation.Nonnull;
+
+import java.io.IOException;
+import java.time.Duration;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+
+/** Request handler for retrieving the job manager log url. */
+public class JobManagerLogUrlHandler
+        extends AbstractRestHandler<
+                RestfulGateway, EmptyRequestBody, LogUrlResponse, 
JobMessageParameters>
+        implements JsonArchivist {
+    public static final String JOB_MANAGER_LOG_URL_FORMAT = 
"http://%s:%s/node/containerlogs/%s/%s";;
+
+    private final Configuration config;

Review Comment:
   Removed the unused config field and ctor arg.



-- 
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