Skip to content

Commit 37a7057

Browse files
author
feiyuzhang
committed
feat(jupyter): use generateName for PVCs created by Notebook form
Changes the Jupyter Notebook form to use Kubernetes generateName instead of name when creating new PVCs. This prevents naming conflicts when notebooks are recreated or when PVCs from deleted notebooks still exist. Changes: - createNewPvcFormGroup(): use generateName instead of name - Default volume names now end with '-' (required for generateName) - Workspace volume: {notebook-name}-workspace- - Data volumes: {notebook-name}-datavol-{n}- Signed-off-by: Feiyu Zhang <feiyuzhang@nianticlabs.com>
1 parent 7262cb1 commit 37a7057

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

components/crud-web-apps/jupyter/frontend/src/app/pages/form/form-new/form-data-volumes/form-data-volumes.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class FormDataVolumesComponent implements OnInit {
3939
addNewVolume() {
4040
const volId = this.volsArray.length + 1;
4141
const volGroup = createNewPvcVolumeFormGroup(
42-
`{notebook-name}-datavol-${volId}`,
42+
`{notebook-name}-datavol-${volId}-`,
4343
);
4444

4545
this.volsArray.push(volGroup);

components/crud-web-apps/jupyter/frontend/src/app/pages/form/form-new/form-workspace-volume/form-workspace-volume.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class FormWorkspaceVolumeComponent implements OnInit, OnDestroy {
5050
}
5151

5252
addNewVolume() {
53-
this.volGroup.addControl('newPvc', createNewPvcFormGroup());
53+
this.volGroup.addControl('newPvc', createNewPvcFormGroup('{notebook-name}-workspace-'));
5454
this.volGroup.get('mount').setValue('/home/jovyan');
5555
this.volGroup.enable();
5656
this.volGroup.get('newPvc.spec.storageClassName').disable();

components/crud-web-apps/jupyter/frontend/src/app/shared/utils/volumes/forms.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ export function createExistingSourceFormGroup(): FormGroup {
7070

7171
// for volume.newPvc
7272
export function createNewPvcFormGroup(
73-
name = '{notebook-name}-volume',
73+
name = '{notebook-name}-volume-',
7474
): FormGroup {
7575
return new FormGroup({
7676
metadata: new FormGroup({
77-
name: new FormControl(name, Validators.required),
77+
generateName: new FormControl(name, Validators.required),
7878
}),
7979
spec: new FormGroup({
8080
accessModes: new FormControl(['ReadWriteOnce']),

0 commit comments

Comments
 (0)