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 9f5a317e SUBMARINE-1276. Notebook pod cannot find userPvc and
workspacePvc
9f5a317e is described below
commit 9f5a317e6a2308ad86d7579af20d342d1ed762ce
Author: KUAN-HSUN-LI <[email protected]>
AuthorDate: Mon May 23 11:23:47 2022 +0800
SUBMARINE-1276. Notebook pod cannot find userPvc and workspacePvc
### What is this PR for?
1. Name error when Notebook pod connecting PVC.
2. Name error when Notebook agent connecting Notebook pod.
### What type of PR is it?
[Bug Fix]
### Todos
### What is the Jira issue?
https://issues.apache.org/jira/browse/SUBMARINE-1276
### How should this be tested?
### Screenshots (if appropriate)

### Questions:
* Do the license files need updating? No
* Are there breaking changes for older versions? No
* Does this need new documentation? No
Author: KUAN-HSUN-LI <[email protected]>
Signed-off-by: Kevin <[email protected]>
Closes #961 from KUAN-HSUN-LI/SUBMARINE-1276 and squashes the following
commits:
f7551d82 [KUAN-HSUN-LI] fix notebook agent getting wrong pod name
0575a608 [KUAN-HSUN-LI] fix notebook cannot find pvc
86182298 [KUAN-HSUN-LI] fix notebook cannot find pvc
---
.../server/submitter/k8s/K8sSubmitter.java | 28 +++++++++++-----------
.../submitter/k8s/parser/NotebookSpecParser.java | 25 ++++++++++---------
.../submitter/k8s/NotebookSpecParserTest.java | 2 +-
3 files changed, 29 insertions(+), 26 deletions(-)
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 2be4c00d..6a2c6a31 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
@@ -469,15 +469,15 @@ public class K8sSubmitter implements Submitter {
final String name = String.format("%s-%s", notebookId.replace("_", "-"),
spec.getMeta().getName());
final String scName = NotebookUtils.SC_NAME;
final String host = NotebookUtils.HOST_PATH;
- final String workspacePvc = String.format("%s-%s",
NotebookUtils.PVC_PREFIX, name);
- final String userPvc = String.format("%s-user-%s",
NotebookUtils.PVC_PREFIX, name);
+ final String workspacePvcName = String.format("%s-%s",
NotebookUtils.PVC_PREFIX, name);
+ final String userPvcName = String.format("%s-user-%s",
NotebookUtils.PVC_PREFIX, name);
final String configmap = String.format("%s-%s",
NotebookUtils.OVERWRITE_PREFIX, name);
String namespace = getServerNamespace();
// parse notebook custom resource
NotebookCR notebookCR;
try {
- notebookCR = NotebookSpecParser.parseNotebook(spec, namespace);
+ notebookCR = NotebookSpecParser.parseNotebook(spec, namespace,
workspacePvcName, userPvcName);
notebookCR.getMetadata().setName(name);
notebookCR.getMetadata().setNamespace(namespace);
notebookCR.getMetadata().setOwnerReferences(OwnerReferenceUtils.getOwnerReference());
@@ -485,14 +485,14 @@ 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.");
}
- AgentPod agentPod = new AgentPod(namespace, spec.getMeta().getName(),
+ AgentPod agentPod = new AgentPod(namespace,
notebookCR.getMetadata().getName(),
CustomResourceType.Notebook, notebookId);
// create persistent volume claim
try {
// workspace
- createPersistentVolumeClaim(workspacePvc, namespace, scName,
NotebookUtils.STORAGE);
+ createPersistentVolumeClaim(workspacePvcName, namespace, scName,
NotebookUtils.STORAGE);
// user setting
- createPersistentVolumeClaim(userPvc, namespace, scName,
NotebookUtils.DEFAULT_USER_STORAGE);
+ createPersistentVolumeClaim(userPvcName, namespace, scName,
NotebookUtils.DEFAULT_USER_STORAGE);
} catch (ApiException e) {
LOG.error("K8s submitter: Create persistent volume claim for Notebook
object failed by " +
e.getMessage(), e);
@@ -507,11 +507,11 @@ public class K8sSubmitter implements Submitter {
createConfigMap(configmap, namespace,
NotebookUtils.DEFAULT_OVERWRITE_FILE_NAME, OVERWRITE_JSON);
} catch (JsonSyntaxException e) {
LOG.error("K8s submitter: parse response object failed by " +
e.getMessage(), e);
- rollbackCreationPVC(namespace, workspacePvc, userPvc);
+ rollbackCreationPVC(namespace, workspacePvcName, userPvcName);
throw new SubmarineRuntimeException(500, "K8s Submitter parse upstream
response failed.");
} catch (ApiException e) {
LOG.error("K8s submitter: parse Notebook object failed by " +
e.getMessage(), e);
- rollbackCreationPVC(namespace, workspacePvc, userPvc);
+ rollbackCreationPVC(namespace, workspacePvcName, userPvcName);
throw new SubmarineRuntimeException(e.getCode(), "K8s submitter: parse
Notebook object failed by " +
e.getMessage());
}
@@ -525,12 +525,12 @@ public class K8sSubmitter implements Submitter {
} catch (JsonSyntaxException e) {
LOG.error("K8s submitter: parse response object failed by " +
e.getMessage(), e);
if (needOverwrite) rollbackCreationConfigMap(namespace, configmap);
- rollbackCreationPVC(namespace, workspacePvc, userPvc);
+ rollbackCreationPVC(namespace, workspacePvcName, userPvcName);
throw new SubmarineRuntimeException(500, "K8s Submitter parse upstream
response failed.");
} catch (ApiException e) {
LOG.error("K8s submitter: parse Notebook object failed by " +
e.getMessage(), e);
if (needOverwrite) rollbackCreationConfigMap(namespace, configmap);
- rollbackCreationPVC(namespace, workspacePvc, userPvc);
+ rollbackCreationPVC(namespace, workspacePvcName, userPvcName);
throw new SubmarineRuntimeException(e.getCode(), "K8s submitter: parse
Notebook object failed by " +
e.getMessage());
}
@@ -544,7 +544,7 @@ public class K8sSubmitter implements Submitter {
e.getMessage(), e);
rollbackCreationNotebook(notebookCR, namespace);
if (needOverwrite) rollbackCreationConfigMap(namespace, configmap);
- rollbackCreationPVC(namespace, workspacePvc, userPvc);
+ rollbackCreationPVC(namespace, workspacePvcName, userPvcName);
throw new SubmarineRuntimeException(e.getCode(), "K8s submitter:
ingressroute for Notebook " +
"object failed by " + e.getMessage());
}
@@ -558,7 +558,7 @@ public class K8sSubmitter implements Submitter {
e.getMessage(), e);
rollbackCreationNotebook(notebookCR, namespace);
if (needOverwrite) rollbackCreationConfigMap(namespace, configmap);
- rollbackCreationPVC(namespace, workspacePvc, userPvc);
+ rollbackCreationPVC(namespace, workspacePvcName, userPvcName);
throw new SubmarineRuntimeException(e.getCode(), "K8s submitter:
VirtualService for Notebook " +
"object failed by " + e.getMessage());
}
@@ -574,7 +574,7 @@ public class K8sSubmitter implements Submitter {
String namespace = getServerNamespace();
try {
- NotebookCR notebookCR = NotebookSpecParser.parseNotebook(spec, null);
+ NotebookCR notebookCR = NotebookSpecParser.parseNotebook(spec, null, "",
"");
notebookCR.getMetadata().setName(name);
Object object = notebookCRClient.get(namespace,
notebookCR.getMetadata().getName())
.throwsApiException().getObject();
@@ -603,7 +603,7 @@ public class K8sSubmitter implements Submitter {
Notebook notebook = null;
final String name = String.format("%s-%s", notebookId.replace("_", "-"),
spec.getMeta().getName());
String namespace = getServerNamespace();
- NotebookCR notebookCR = NotebookSpecParser.parseNotebook(spec, null);
+ NotebookCR notebookCR = NotebookSpecParser.parseNotebook(spec, null, "",
"");
AgentPod agentPod = new AgentPod(namespace, spec.getMeta().getName(),
CustomResourceType.Notebook, notebookId);
diff --git
a/submarine-server/server-submitter/submitter-k8s/src/main/java/org/apache/submarine/server/submitter/k8s/parser/NotebookSpecParser.java
b/submarine-server/server-submitter/submitter-k8s/src/main/java/org/apache/submarine/server/submitter/k8s/parser/NotebookSpecParser.java
index 55ae4c02..c7ebfe5a 100644
---
a/submarine-server/server-submitter/submitter-k8s/src/main/java/org/apache/submarine/server/submitter/k8s/parser/NotebookSpecParser.java
+++
b/submarine-server/server-submitter/submitter-k8s/src/main/java/org/apache/submarine/server/submitter/k8s/parser/NotebookSpecParser.java
@@ -63,10 +63,11 @@ public class NotebookSpecParser {
SubmarineConfiguration.getInstance();
- public static NotebookCR parseNotebook(NotebookSpec spec, String namespace) {
+ public static NotebookCR parseNotebook(NotebookSpec spec, String namespace,
+ String workspacePvcName, String userPvcName) {
NotebookCR notebookCR = new NotebookCR();
notebookCR.setMetadata(parseMetadata(spec));
- notebookCR.setSpec(parseNotebookCRSpec(spec));
+ notebookCR.setSpec(parseNotebookCRSpec(spec, workspacePvcName,
userPvcName));
return notebookCR;
}
@@ -78,13 +79,15 @@ public class NotebookSpecParser {
return meta;
}
- private static NotebookCRSpec parseNotebookCRSpec(NotebookSpec spec) {
+ private static NotebookCRSpec parseNotebookCRSpec(NotebookSpec spec, String
workspacePvcName,
+ String userPvcName) {
NotebookCRSpec CRSpec = new NotebookCRSpec();
- CRSpec.setTemplate(parseTemplateSpec(spec));
+ CRSpec.setTemplate(parseTemplateSpec(spec, workspacePvcName, userPvcName));
return CRSpec;
}
- private static V1PodTemplateSpec parseTemplateSpec(NotebookSpec
notebookSpec) {
+ private static V1PodTemplateSpec parseTemplateSpec(NotebookSpec
notebookSpec,
+ String workspacePvcNameName, String userPvcNameName) {
String name = notebookSpec.getMeta().getName();
NotebookPodSpec notebookPodSpec = notebookSpec.getSpec();
@@ -176,16 +179,16 @@ public class NotebookSpecParser {
// workspace
V1Volume workspaceVolume = new V1Volume();
workspaceVolume.setName(String.format("%s-%s",
NotebookUtils.STORAGE_PREFIX, name));
- V1PersistentVolumeClaimVolumeSource workspacePvc = new
V1PersistentVolumeClaimVolumeSource();
- workspacePvc.setClaimName(String.format("%s-%s", NotebookUtils.PVC_PREFIX,
name));
- workspaceVolume.setPersistentVolumeClaim(workspacePvc);
+ V1PersistentVolumeClaimVolumeSource workspacePvcName = new
V1PersistentVolumeClaimVolumeSource();
+ workspacePvcName.setClaimName(workspacePvcNameName);
+ workspaceVolume.setPersistentVolumeClaim(workspacePvcName);
volumeList.add(workspaceVolume);
// user setting
V1Volume userVolume = new V1Volume();
userVolume.setName(String.format("%s-user-%s",
NotebookUtils.STORAGE_PREFIX, name));
- V1PersistentVolumeClaimVolumeSource userPvc = new
V1PersistentVolumeClaimVolumeSource();
- userPvc.setClaimName(String.format("%s-user-%s", NotebookUtils.PVC_PREFIX,
name));
- userVolume.setPersistentVolumeClaim(userPvc);
+ V1PersistentVolumeClaimVolumeSource userPvcName = new
V1PersistentVolumeClaimVolumeSource();
+ userPvcName.setClaimName(userPvcNameName);
+ userVolume.setPersistentVolumeClaim(userPvcName);
volumeList.add(userVolume);
// add overwrite.json configmap
diff --git
a/submarine-server/server-submitter/submitter-k8s/src/test/java/org/apache/submarine/server/submitter/k8s/NotebookSpecParserTest.java
b/submarine-server/server-submitter/submitter-k8s/src/test/java/org/apache/submarine/server/submitter/k8s/NotebookSpecParserTest.java
index e7bc1209..8f87460c 100644
---
a/submarine-server/server-submitter/submitter-k8s/src/test/java/org/apache/submarine/server/submitter/k8s/NotebookSpecParserTest.java
+++
b/submarine-server/server-submitter/submitter-k8s/src/test/java/org/apache/submarine/server/submitter/k8s/NotebookSpecParserTest.java
@@ -41,7 +41,7 @@ public class NotebookSpecParserTest extends SpecBuilder {
@Test
public void testValidNotebook() throws IOException, URISyntaxException {
NotebookSpec notebookSpec = (NotebookSpec)
buildFromJsonFile(NotebookSpec.class, notebookReqFile);
- NotebookCR notebook = NotebookSpecParser.parseNotebook(notebookSpec, null);
+ NotebookCR notebook = NotebookSpecParser.parseNotebook(notebookSpec, null,
"", "");
validateMetadata(notebookSpec.getMeta(), notebook.getMetadata());
validateEnvironment(notebookSpec, notebook.getSpec());
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]