You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@submarine.apache.org by GitBox <gi...@apache.org> on 2020/08/04 04:19:09 UTC
[GitHub] [submarine] wangdatan commented on a change in pull request #362: SUBMARINE-570. Support run experiment/notebook with synced code
wangdatan commented on a change in pull request #362:
URL: https://github.com/apache/submarine/pull/362#discussion_r464788450
##########
File path: submarine-server/server-submitter/submitter-k8s/src/main/java/org/apache/submarine/server/submitter/k8s/experiment/codelocalizer/HTTPGitCodeLocalizer.java
##########
@@ -0,0 +1,35 @@
+/*
+ * 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.submarine.server.submitter.k8s.experiment.codelocalizer;
+
+import io.kubernetes.client.models.V1PodSpec;
+
+public class HTTPGitCodeLocalizer extends GitCodeLocalizer {
Review comment:
@manirajv06 , it looks like HTTP and SSH Git localizer pretty same, I'm wondering why we need the two implementations. And why `localize` of `SSHGitCodeLocalizer` is empty?
##########
File path: submarine-server/server-submitter/submitter-k8s/src/main/java/org/apache/submarine/server/submitter/k8s/parser/ExperimentSpecParser.java
##########
@@ -168,8 +171,35 @@ private static V1PodTemplateSpec parseTemplateSpec(
container.setResources(resources);
container.setEnv(parseEnvVars(taskSpec, experimentSpec.getMeta().getEnvVars()));
containers.add(container);
- podSpec.setContainers(containers);
+ /**
+ * Init Git localize Container
+ */
+ if (experimentSpec.getCode() != null) {
+ CodeLocalizer localizer = AbstractCodeLocalizer.getCodeLocalizer(
+ experimentSpec.getCode().getSyncMode(),
+ experimentSpec.getCode().getUrl());
+ localizer.localize(podSpec);
+
+ if (podSpec.getInitContainers() != null
+ && podSpec.getInitContainers().size() > 0) {
+ String volumeName = podSpec.getInitContainers().get(0).getVolumeMounts()
Review comment:
Is this part of logic generic enough to support multiple volumes? (It is possible in the future we want to support mount other volumes to the pod, such as an NFS volume. Instead of get(0), can we get the volume by dir name?
##########
File path: submarine-server/server-submitter/submitter-k8s/src/main/java/org/apache/submarine/server/submitter/k8s/experiment/codelocalizer/AbstractCodeLocalizer.java
##########
@@ -0,0 +1,74 @@
+/*
+ * 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.submarine.server.submitter.k8s.experiment.codelocalizer;
+
+import org.apache.submarine.server.api.exception.InvalidSpecException;
+
+import io.kubernetes.client.models.V1EmptyDirVolumeSource;
+import io.kubernetes.client.models.V1PodSpec;
+import io.kubernetes.client.models.V1Volume;
+
+public abstract class AbstractCodeLocalizer implements CodeLocalizer {
+
+ private String url;
+
+ public AbstractCodeLocalizer(String url) {
+ this.url = url;
+ }
+
+ /**
+ * @return the url
+ */
+ public String getUrl() {
+ return url;
+ }
+
+ @Override
+ public void localize(V1PodSpec podSpec) {
+ V1Volume volume = new V1Volume();
+ volume.setName("code-dir");
Review comment:
can we make `code-dir` to be a constant and can be referred in other places (like test)?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org