This is an automated email from the ASF dual-hosted git repository.

pingsutw pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/submarine.git


The following commit(s) were added to refs/heads/master by this push:
     new 9ed4cb6  SUBMARINE-966. Correct the job label selector
9ed4cb6 is described below

commit 9ed4cb6188bcc17f6590a2d3458d18ad10f3fc53
Author: Lisa <aeioul...@gmail.com>
AuthorDate: Mon Aug 9 18:05:39 2021 +0800

    SUBMARINE-966. Correct the job label selector
    
    ### What is this PR for?
    Get empty reply when getting logs because the selector key 'tf-job-name' 
represent to ExperimentId now, correct it to get the right response.
    
    ### What type of PR is it?
    [Bug Fix]
    
    ### Todos
    * [ ] - Task
    
    ### What is the Jira issue?
    https://issues.apache.org/jira/browse/SUBMARINE-966
    
    ### How should this be tested?
    
    ### Screenshots (if appropriate)
    
![image](https://user-images.githubusercontent.com/30621230/128705006-cc6fd404-2a0d-49e2-ab00-f63456d40567.png)
    
    ### Questions:
    * Do the license files need updating? No
    * Are there breaking changes for older versions? No
    * Does this need new documentation? No
    
    Author: Lisa <aeioul...@gmail.com>
    
    Signed-off-by: Kevin <pings...@apache.org>
    
    Closes #704 from aeioulisa/SUBMARINE-966 and squashes the following commits:
    
    0d8401f0 [Lisa] getExperimentLog
---
 .../server/experiment/ExperimentManager.java       | 10 +--
 .../server/submitter/k8s/K8sSubmitter.java         | 95 +++++++++++-----------
 2 files changed, 50 insertions(+), 55 deletions(-)

diff --git 
a/submarine-server/server-core/src/main/java/org/apache/submarine/server/experiment/ExperimentManager.java
 
b/submarine-server/server-core/src/main/java/org/apache/submarine/server/experiment/ExperimentManager.java
index 33d76ce..e809158 100644
--- 
a/submarine-server/server-core/src/main/java/org/apache/submarine/server/experiment/ExperimentManager.java
+++ 
b/submarine-server/server-core/src/main/java/org/apache/submarine/server/experiment/ExperimentManager.java
@@ -185,7 +185,7 @@ public class ExperimentManager {
   /**
    * List experiments
    *
-   * @param tag, if null will return all experiments
+   * @param searchTag, if null will return all experiments
    * @return list
    * @throws SubmarineRuntimeException the service error
    */
@@ -321,13 +321,7 @@ public class ExperimentManager {
     ExperimentEntity entity = experimentService.select(id);
     Experiment experiment = buildExperimentFromEntity(entity);
 
-    Experiment foundExperiment = 
submitter.findExperiment(experiment.getSpec());
-    experiment.rebuild(foundExperiment);
-
-    return submitter.getExperimentLog(
-        experiment.getSpec(),
-        experiment.getSpec().getMeta().getExperimentId()
-    );
+    return submitter.getExperimentLog(experiment.getSpec(), id);
   }
 
   /**
diff --git 
a/submarine-server/server-submitter/submitter-k8s/src/main/java/org/apache/submarine/server/submitter/k8s/K8sSubmitter.java
 
b/submarine-server/server-submitter/submitter-k8s/src/main/java/org/apache/submarine/server/submitter/k8s/K8sSubmitter.java
index 900419f..063b978 100644
--- 
a/submarine-server/server-submitter/submitter-k8s/src/main/java/org/apache/submarine/server/submitter/k8s/K8sSubmitter.java
+++ 
b/submarine-server/server-submitter/submitter-k8s/src/main/java/org/apache/submarine/server/submitter/k8s/K8sSubmitter.java
@@ -96,7 +96,8 @@ public class K8sSubmitter implements Submitter {
 
   private AppsV1Api appsV1Api;
 
-  public K8sSubmitter() {}
+  public K8sSubmitter() {
+  }
 
   @Override
   public void initialize(SubmarineConfiguration conf) {
@@ -204,7 +205,7 @@ public class K8sSubmitter implements Submitter {
   }
 
   private Experiment parseExperimentResponseObject(Object object, ParseOp op)
-          throws SubmarineRuntimeException {
+      throws SubmarineRuntimeException {
     Gson gson = new JSON().getGson();
     String jsonString = gson.toJson(object);
     LOG.info("Upstream response JSON: {}", jsonString);
@@ -232,7 +233,7 @@ public class K8sSubmitter implements Submitter {
           "false", null, null,
           getJobLabelSelector(spec), null, null,
           null, null);
-      for (V1Pod pod: podList.getItems()) {
+      for (V1Pod pod : podList.getItems()) {
         String podName = pod.getMetadata().getName();
         experimentLog.addPodLog(podName, null);
       }
@@ -279,7 +280,7 @@ public class K8sSubmitter implements Submitter {
     }
 
     try {
-      V1Deployment deploy =  appsV1Api.readNamespacedDeploymentStatus(name, 
namespace, "true");
+      V1Deployment deploy = appsV1Api.readNamespacedDeploymentStatus(name, 
namespace, "true");
       boolean available = deploy.getStatus().getAvailableReplicas() > 0; // at 
least one replica is running
 
       IngressRoute ingressRoute = new IngressRoute();
@@ -321,7 +322,7 @@ public class K8sSubmitter implements Submitter {
     }
 
     try {
-      V1Deployment deploy =  appsV1Api.readNamespacedDeploymentStatus(name, 
namespace, "true");
+      V1Deployment deploy = appsV1Api.readNamespacedDeploymentStatus(name, 
namespace, "true");
       boolean available = deploy.getStatus().getAvailableReplicas() > 0; // at 
least one replica is running
 
       IngressRoute ingressRoute = new IngressRoute();
@@ -330,9 +331,9 @@ public class K8sSubmitter implements Submitter {
       meta.setNamespace(namespace);
       ingressRoute.setMetadata(meta);
       Object object = api.getNamespacedCustomObject(
-              ingressRoute.getGroup(), ingressRoute.getVersion(),
-              ingressRoute.getMetadata().getNamespace(),
-              ingressRoute.getPlural(), ingressRouteName
+          ingressRoute.getGroup(), ingressRoute.getVersion(),
+          ingressRoute.getMetadata().getNamespace(),
+          ingressRoute.getPlural(), ingressRouteName
       );
 
       Gson gson = new JSON().getGson();
@@ -362,11 +363,11 @@ public class K8sSubmitter implements Submitter {
     final String storage = NotebookUtils.STORAGE;
     final String pvcName = NotebookUtils.PVC_PREFIX + name;
     String namespace = "default";
-    
+
     if (System.getenv(ENV_NAMESPACE) != null) {
       namespace = System.getenv(ENV_NAMESPACE);
     }
-    
+
     // parse notebook custom resource
     NotebookCR notebookCR;
     try {
@@ -379,7 +380,7 @@ public class K8sSubmitter implements Submitter {
       LOG.error("K8s submitter: parse response object failed by " + 
e.getMessage(), e);
       throw new SubmarineRuntimeException(500, "K8s Submitter parse upstream 
response failed.");
     }
-    
+
     // create persistent volume claim
     try {
       createPersistentVolumeClaim(pvcName, namespace, scName, storage);
@@ -389,7 +390,7 @@ public class K8sSubmitter implements Submitter {
       throw new SubmarineRuntimeException(e.getCode(), "K8s submitter: Create 
persistent volume claim for " +
           "Notebook object failed by " + e.getMessage());
     }
-    
+
     // create notebook custom resource
     try {
       Object object = api.createNamespacedCustomObject(notebookCR.getGroup(), 
notebookCR.getVersion(),
@@ -433,8 +434,8 @@ public class K8sSubmitter implements Submitter {
     try {
       NotebookCR notebookCR = NotebookSpecParser.parseNotebook(spec);
       Object object = api.getNamespacedCustomObject(notebookCR.getGroup(), 
notebookCR.getVersion(),
-              namespace,
-              notebookCR.getPlural(), notebookCR.getMetadata().getName());
+          namespace,
+          notebookCR.getPlural(), notebookCR.getMetadata().getName());
       notebook = NotebookUtils.parseObject(object, 
NotebookUtils.ParseOpt.PARSE_OPT_GET);
     } catch (ApiException e) {
       throw new SubmarineRuntimeException(e.getCode(), e.getMessage());
@@ -456,10 +457,10 @@ public class K8sSubmitter implements Submitter {
     try {
       NotebookCR notebookCR = NotebookSpecParser.parseNotebook(spec);
       Object object = api.deleteNamespacedCustomObject(notebookCR.getGroup(), 
notebookCR.getVersion(),
-              namespace, notebookCR.getPlural(),
-              notebookCR.getMetadata().getName(),
-              new 
V1DeleteOptionsBuilder().withApiVersion(notebookCR.getApiVersion()).build(),
-              null, null, null);
+          namespace, notebookCR.getPlural(),
+          notebookCR.getMetadata().getName(),
+          new 
V1DeleteOptionsBuilder().withApiVersion(notebookCR.getApiVersion()).build(),
+          null, null, null);
       notebook = NotebookUtils.parseObject(object, 
NotebookUtils.ParseOpt.PARSE_OPT_DELETE);
       deleteIngressRoute(namespace, notebookCR.getMetadata().getName());
       deletePersistentVolumeClaim(pvcName, namespace);
@@ -481,9 +482,9 @@ public class K8sSubmitter implements Submitter {
 
     try {
       Object object = 
api.listNamespacedCustomObject(NotebookCR.CRD_NOTEBOOK_GROUP_V1,
-              NotebookCR.CRD_NOTEBOOK_VERSION_V1, namespace , 
NotebookCR.CRD_NOTEBOOK_PLURAL_V1,
-              "true", null, NotebookCR.NOTEBOOK_OWNER_SELECTOR_KET + "=" + id,
-              null, null, null);
+          NotebookCR.CRD_NOTEBOOK_VERSION_V1, namespace, 
NotebookCR.CRD_NOTEBOOK_PLURAL_V1,
+          "true", null, NotebookCR.NOTEBOOK_OWNER_SELECTOR_KET + "=" + id,
+          null, null, null);
       notebookList = NotebookUtils.parseObjectForList(object);
     } catch (ApiException e) {
       throw new SubmarineRuntimeException(e.getCode(), e.getMessage());
@@ -510,14 +511,14 @@ public class K8sSubmitter implements Submitter {
       coreApi.createNamespacedService(namespace, svc, "true", null, null);
 
       api.createNamespacedCustomObject(
-            middleware.getGroup(), middleware.getVersion(),
-            middleware.getMetadata().getNamespace(),
-            middleware.getPlural(), middleware, "true");
+          middleware.getGroup(), middleware.getVersion(),
+          middleware.getMetadata().getNamespace(),
+          middleware.getPlural(), middleware, "true");
 
       api.createNamespacedCustomObject(
-            ingressRoute.getGroup(), ingressRoute.getVersion(),
-            ingressRoute.getMetadata().getNamespace(),
-            ingressRoute.getPlural(), ingressRoute, "true");
+          ingressRoute.getGroup(), ingressRoute.getVersion(),
+          ingressRoute.getMetadata().getNamespace(),
+          ingressRoute.getPlural(), ingressRoute, "true");
       return serveInfo;
     } catch (ApiException e) {
       throw new SubmarineRuntimeException(e.getCode(), e.getMessage());
@@ -558,12 +559,12 @@ public class K8sSubmitter implements Submitter {
   }
 
   public void createPersistentVolumeClaim(String pvcName, String namespace, 
String scName, String storage)
-          throws ApiException {
+      throws ApiException {
     V1PersistentVolumeClaim pvc = 
VolumeSpecParser.parsePersistentVolumeClaim(pvcName, scName, storage);
 
     try {
       V1PersistentVolumeClaim result = 
coreApi.createNamespacedPersistentVolumeClaim(
-              namespace, pvc, "true", null, null
+          namespace, pvc, "true", null, null
       );
     } catch (ApiException e) {
       LOG.error("Exception when creating persistent volume claim " + 
e.getMessage(), e);
@@ -579,9 +580,9 @@ public class K8sSubmitter implements Submitter {
     */
     try {
       V1Status result = coreApi.deleteNamespacedPersistentVolumeClaim(
-                pvcName, namespace, "true",
+          pvcName, namespace, "true",
           null, null, null,
-            null, null
+          null, null
       );
     } catch (ApiException e) {
       LOG.error("Exception when deleting persistent volume claim " + 
e.getMessage(), e);
@@ -605,9 +606,9 @@ public class K8sSubmitter implements Submitter {
     // TODO(JohnTing): SELECTOR_KEY should be obtained from individual models 
in MLJOB
     if (experimentSpec.getMeta().getFramework()
         
.equalsIgnoreCase(ExperimentMeta.SupportedMLFramework.TENSORFLOW.getName())) {
-      return TF_JOB_SELECTOR_KEY + experimentSpec.getMeta().getName();
+      return TF_JOB_SELECTOR_KEY + experimentSpec.getMeta().getExperimentId();
     } else {
-      return PYTORCH_JOB_SELECTOR_KEY + experimentSpec.getMeta().getName();
+      return PYTORCH_JOB_SELECTOR_KEY + 
experimentSpec.getMeta().getExperimentId();
     }
   }
 
@@ -620,9 +621,9 @@ public class K8sSubmitter implements Submitter {
       ingressRoute.setMetadata(meta);
       ingressRoute.setSpec(parseIngressRouteSpec(meta.getNamespace(), 
meta.getName()));
       api.createNamespacedCustomObject(
-              ingressRoute.getGroup(), ingressRoute.getVersion(),
-              ingressRoute.getMetadata().getNamespace(),
-              ingressRoute.getPlural(), ingressRoute, "true");
+          ingressRoute.getGroup(), ingressRoute.getVersion(),
+          ingressRoute.getMetadata().getNamespace(),
+          ingressRoute.getPlural(), ingressRoute, "true");
     } catch (ApiException e) {
       LOG.error("K8s submitter: Create Traefik custom resource object failed 
by " + e.getMessage(), e);
       throw new SubmarineRuntimeException(e.getCode(), e.getMessage());
@@ -635,10 +636,10 @@ public class K8sSubmitter implements Submitter {
   private void deleteIngressRoute(String namespace, String name) {
     try {
       api.deleteNamespacedCustomObject(
-              IngressRoute.CRD_INGRESSROUTE_GROUP_V1, 
IngressRoute.CRD_INGRESSROUTE_VERSION_V1,
-              namespace, IngressRoute.CRD_INGRESSROUTE_PLURAL_V1, name,
-              new 
V1DeleteOptionsBuilder().withApiVersion(IngressRoute.CRD_APIVERSION_V1).build(),
-              null, null, null);
+          IngressRoute.CRD_INGRESSROUTE_GROUP_V1, 
IngressRoute.CRD_INGRESSROUTE_VERSION_V1,
+          namespace, IngressRoute.CRD_INGRESSROUTE_PLURAL_V1, name,
+          new 
V1DeleteOptionsBuilder().withApiVersion(IngressRoute.CRD_APIVERSION_V1).build(),
+          null, null, null);
     } catch (ApiException e) {
       LOG.error("K8s submitter: Delete Traefik custom resource object failed 
by " + e.getMessage(), e);
       throw new SubmarineRuntimeException(e.getCode(), e.getMessage());
@@ -675,19 +676,19 @@ public class K8sSubmitter implements Submitter {
     }
   }
 
-  private void rollbackCreationNotebook(NotebookCR notebookCR, String 
namespace) 
-    throws SubmarineRuntimeException {
+  private void rollbackCreationNotebook(NotebookCR notebookCR, String 
namespace)
+      throws SubmarineRuntimeException {
     try {
       Object object = api.deleteNamespacedCustomObject(notebookCR.getGroup(), 
notebookCR.getVersion(),
-              namespace, notebookCR.getPlural(),
-              notebookCR.getMetadata().getName(),
-              new 
V1DeleteOptionsBuilder().withApiVersion(notebookCR.getApiVersion()).build(),
-              null, null, null);
+          namespace, notebookCR.getPlural(),
+          notebookCR.getMetadata().getName(),
+          new 
V1DeleteOptionsBuilder().withApiVersion(notebookCR.getApiVersion()).build(),
+          null, null, null);
     } catch (ApiException e) {
       throw new SubmarineRuntimeException(e.getCode(), e.getMessage());
     }
   }
-  
+
   private enum ParseOp {
     PARSE_OP_RESULT,
     PARSE_OP_DELETE

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@submarine.apache.org
For additional commands, e-mail: dev-h...@submarine.apache.org

Reply via email to