You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@submarine.apache.org by ka...@apache.org on 2021/06/14 03:38:25 UTC
[submarine] branch master updated: SUBMARINE-844. allow notebook
operation could work on assigned namespace
This is an automated email from the ASF dual-hosted git repository.
kaihsun 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 fb21e79 SUBMARINE-844. allow notebook operation could work on assigned namespace
fb21e79 is described below
commit fb21e797bbe8e501484a21fb5c9847d05dd03d1e
Author: brandonlin <br...@verizonmedia.com>
AuthorDate: Mon Jun 14 10:09:50 2021 +0800
SUBMARINE-844. allow notebook operation could work on assigned namespace
**What is this PR for?**
Currently the namespace which we use to execute notebook operation is passed from the frontend, which is hardcore which "default" value.(https://github.com/apache/submarine/blob/master/submarine-workbench/workbench-web/src/app/pages/workbench/notebook/notebook-home/notebook-form/notebook-form.component.ts#L184)
Per discussion with kevin85421, we would like to make some change here to align the similar behavior in TFBoard(https://github.com/apache/submarine/blob/master/submarine-server/server-submitter/submitter-k8s/src/main/java/org/apache/submarine/server/submitter/k8s/K8sSubmitter.java#L270-L273) which is assgend by operator.
**What type of PR is it?**
Improvement
**Todos**
how to pass the assigned namespace via script or helm.
**What is the Jira issue?**
https://issues.apache.org/jira/browse/SUBMARINE-844
**How should this be tested?**
create a notebook from UI, then check that is the notebook is created in the same namespace withe other modules insted of "default".
**Screenshots**
<img width="1399" alt="截圖 2021-06-11 下午5 21 14" src="https://user-images.githubusercontent.com/5687317/121697297-7f87a780-caff-11eb-9a74-6798fbe9ce82.png">
<img width="1443" alt="截圖 2021-06-12 下午6 09 05" src="https://user-images.githubusercontent.com/5687317/121772727-df3a8d00-cba9-11eb-9db1-493e2924ed89.png">
**Questions:**
Do the license files need updating? No
Are there breaking changes for older versions? No
Does this need new documentation? No
Author: brandonlin <br...@verizonmedia.com>
Signed-off-by: Kai-Hsun Chen <ka...@apache.org>
Closes #602 from FatalLin/SUBMARINE-844 and squashes the following commits:
185637c9 [brandonlin] align code style
a3cb3fb8 [brandonlin] fix
f3dc0334 [brandonlin] align tf borad, use the operator set env namespace as working namespace
e12fea31 [brandonlin] remove debug command
d9804754 [brandonlin] fix typo and change method to getProperty
0fe231fa [brandonlin] allow notebook operation could work on assigned namespace which ix extracted from environment variable
---
.../server/submitter/k8s/K8sSubmitter.java | 35 +++++++++++++++++-----
1 file changed, 28 insertions(+), 7 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 b139087..446535b 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
@@ -355,18 +355,25 @@ public class K8sSubmitter implements Submitter {
final String host = NotebookUtils.HOST_PATH;
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);
+ }
+
try {
// create notebook custom resource
NotebookCR notebookCR = NotebookSpecParser.parseNotebook(spec);
Map<String, String> labels = new HashMap<>();
labels.put(NotebookCR.NOTEBOOK_OWNER_SELECTOR_KET, spec.getMeta().getOwnerId());
notebookCR.getMetadata().setLabels(labels);
-
+ notebookCR.getMetadata().setNamespace(namespace);
+
// create persistent volume
createPersistentVolume(pvName, host, storage);
// create persistent volume claim
- createPersistentVolumeClaim(pvcName, spec.getMeta().getNamespace(), pvName, storage);
+ createPersistentVolumeClaim(pvcName, namespace, pvName, storage);
// bind persistent volume claim
V1PersistentVolumeClaimVolumeSource pvcSource = new V1PersistentVolumeClaimVolumeSource()
@@ -374,7 +381,7 @@ public class K8sSubmitter implements Submitter {
notebookCR.getSpec().getTemplate().getSpec().getVolumes().get(0).persistentVolumeClaim(pvcSource);
Object object = api.createNamespacedCustomObject(notebookCR.getGroup(), notebookCR.getVersion(),
- notebookCR.getMetadata().getNamespace(), notebookCR.getPlural(), notebookCR, "true");
+ namespace, notebookCR.getPlural(), notebookCR, "true");
notebook = NotebookUtils.parseObject(object, NotebookUtils.ParseOpt.PARSE_OPT_CREATE);
// create Traefik custom resource
@@ -394,10 +401,18 @@ public class K8sSubmitter implements Submitter {
@Override
public Notebook findNotebook(NotebookSpec spec) throws SubmarineRuntimeException {
Notebook notebook;
+ String namespace = "default";
+
+ if (System.getenv(ENV_NAMESPACE) != null) {
+ namespace = System.getenv(ENV_NAMESPACE);
+ }
+
try {
+
+
NotebookCR notebookCR = NotebookSpecParser.parseNotebook(spec);
Object object = api.getNamespacedCustomObject(notebookCR.getGroup(), notebookCR.getVersion(),
- notebookCR.getMetadata().getNamespace(),
+ namespace,
notebookCR.getPlural(), notebookCR.getMetadata().getName());
notebook = NotebookUtils.parseObject(object, NotebookUtils.ParseOpt.PARSE_OPT_GET);
} catch (ApiException e) {
@@ -412,16 +427,22 @@ public class K8sSubmitter implements Submitter {
final String name = spec.getMeta().getName();
final String pvName = NotebookUtils.PV_PREFIX + name;
final String pvcName = NotebookUtils.PVC_PREFIX + name;
+ String namespace = "default";
+
+ if (System.getenv(ENV_NAMESPACE) != null) {
+ namespace = System.getenv(ENV_NAMESPACE);
+ }
+
try {
NotebookCR notebookCR = NotebookSpecParser.parseNotebook(spec);
Object object = api.deleteNamespacedCustomObject(notebookCR.getGroup(), notebookCR.getVersion(),
- notebookCR.getMetadata().getNamespace(), notebookCR.getPlural(),
+ 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(notebookCR.getMetadata().getNamespace(), notebookCR.getMetadata().getName());
- deletePersistentVolumeClaim(pvcName, spec.getMeta().getNamespace());
+ deleteIngressRoute(namespace, notebookCR.getMetadata().getName());
+ deletePersistentVolumeClaim(pvcName, namespace);
deletePersistentVolume(pvName);
} catch (ApiException e) {
throw new SubmarineRuntimeException(e.getCode(), e.getMessage());
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@submarine.apache.org
For additional commands, e-mail: dev-help@submarine.apache.org