wangyang0918 commented on code in PR #168:
URL:
https://github.com/apache/flink-kubernetes-operator/pull/168#discussion_r855741663
##########
docs/content/docs/operations/configuration.md:
##########
@@ -62,3 +62,4 @@ To learn more about metrics and logging configuration please
refer to the dedica
| kubernetes.operator.observer.flink.client.timeout | 10s |
Duration | The timeout for the observer to wait the flink rest client to
return. |
| kubernetes.operator.reconciler.flink.cancel.job.timeout | 1min |
Duration | The timeout for the reconciler to wait for flink to cancel job.
|
| kubernetes.operator.reconciler.flink.cluster.shutdown.timeout | 60s
| Duration | The timeout for the reconciler to wait for flink to shutdown
cluster. |
+| kubernetes.operator.user.artifacts.base.dir | 60s | String |
The base dir to put the session job artifacts. |
Review Comment:
The default value is not `60s`.
##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/artifact/ArtifactManager.java:
##########
@@ -0,0 +1,75 @@
+/*
+ * 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.kubernetes.operator.artifact;
+
+import org.apache.flink.kubernetes.operator.config.FlinkOperatorConfiguration;
+import org.apache.flink.kubernetes.operator.crd.FlinkDeployment;
+import org.apache.flink.kubernetes.operator.crd.FlinkSessionJob;
+import org.apache.flink.util.FlinkRuntimeException;
+
+import org.apache.commons.io.FileUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.net.URI;
+
+/** Manage the user artifacts. */
+public class ArtifactManager {
+
+ private static final Logger LOG =
LoggerFactory.getLogger(ArtifactManager.class);
+ private final File baseDir;
+
+ public ArtifactManager(FlinkOperatorConfiguration operatorConfiguration) {
+ this.baseDir = new File(operatorConfiguration.getArtifactsBaseDir());
+ }
+
+ private synchronized void createIfNotExists(File targetDir) {
+ if (!targetDir.exists()) {
+ try {
+ FileUtils.forceMkdirParent(targetDir);
+ LOG.info("Created dir: {}", targetDir);
+ } catch (Exception e) {
+ throw new FlinkRuntimeException(
+ String.format("Failed to create the dir: %s",
targetDir), e);
+ }
+ }
+ }
+
+ public File fetch(String jarURI, String targetDirStr) throws Exception {
+ File targetDir = new File(targetDirStr);
+ createIfNotExists(targetDir);
+ URI uri = new URI(jarURI);
+ if ("http".equals(uri.getScheme()) || "https".equals(uri.getScheme()))
{
+ return HttpArtifactFetcher.INSTANCE.fetch(jarURI, targetDir);
+ } else {
+ return FileSystemBasedArtifactFetcher.INSTANCE.fetch(jarURI,
targetDir);
+ }
+ }
+
+ public String generateJarDir(FlinkDeployment flinkApp, FlinkSessionJob
sessionJob) {
Review Comment:
We need to enforce the session cluster and session jobs are in the same
namespace. Right?
Then maybe the `baseDir` + `/` + `sessionJob.getMetadata().getNamespace()`
+ `/` + `sessionJob.getSpec().getClusterId()` + `/` +
`sessionJob.getMetadata().getName()` is enough.
--
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]