-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from StatCan/18-destroy-old-notebooks
Support notebook volume (PVC) management
- Loading branch information
Showing
20 changed files
with
446 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,87 @@ | ||
import { Component, OnInit } from "@angular/core"; | ||
import { NamespaceService } from "../services/namespace.service"; | ||
import {Component, OnInit} from "@angular/core"; | ||
import {NamespaceService} from "../services/namespace.service"; | ||
import {KubernetesService} from "src/app/services/kubernetes.service"; | ||
|
||
import {Subscription} from "rxjs"; | ||
import {isEqual} from "lodash"; | ||
import {first} from "rxjs/operators"; | ||
|
||
import {ExponentialBackoff} from "src/app/utils/polling"; | ||
import {Volume, Resource} from "../utils/types"; | ||
import {PvcWithStatus} from "./volumes-table/volume-table.component" | ||
|
||
@Component({ | ||
selector: "app-main-table", | ||
templateUrl: "./main-table.component.html", | ||
styleUrls: ["./main-table.component.scss"] | ||
}) | ||
export class MainTableComponent implements OnInit { | ||
currNamespace = ""; | ||
namespaces = []; | ||
currNamespace: string; | ||
resources = []; | ||
|
||
pvcs: Volume[] = []; | ||
pvcProperties: PvcWithStatus[] = []; | ||
|
||
subscriptions = new Subscription(); | ||
poller: ExponentialBackoff; | ||
|
||
constructor( | ||
public ns: NamespaceService, | ||
private k8s: KubernetesService, | ||
) {} | ||
|
||
ngOnInit() { | ||
this.poller = new ExponentialBackoff({interval: 2000, retries: 3}); | ||
const resourcesSub = this.poller.start().subscribe(() => { | ||
if (!this.currNamespace) { | ||
return; | ||
} | ||
|
||
Promise.all([ | ||
this.k8s.getResource(this.currNamespace).toPromise(), | ||
this.k8s.getVolumes(this.currNamespace).toPromise() | ||
]).then(([notebooks, volumes]) => { | ||
if (!isEqual(notebooks, this.resources) || !isEqual(volumes, this.pvcs)) { | ||
this.poller.reset(); | ||
} | ||
this.resources = notebooks; | ||
this.pvcs = volumes; | ||
let mounts = Object.fromEntries( | ||
notebooks.flatMap(nb => nb.volumes.map(v => [v, nb])) | ||
); | ||
this.pvcProperties = volumes.map(v => ({ | ||
pvc: v, | ||
mountedBy: mounts[v.name]?.name | ||
})); | ||
}); | ||
}); | ||
|
||
// Keep track of the selected namespace | ||
const namespaceSub = this.ns.getSelectedNamespace().subscribe(namespace => { | ||
this.currNamespace = namespace; | ||
this.poller.reset(); | ||
}); | ||
|
||
this.subscriptions.add(resourcesSub); | ||
this.subscriptions.add(namespaceSub); | ||
} | ||
|
||
constructor(public ns: NamespaceService) {} | ||
deleteResource(rsrc: Resource): void { | ||
this.k8s | ||
.deleteResource(rsrc.namespace, rsrc.name) | ||
.pipe(first()) | ||
.subscribe(r => { | ||
this.poller.reset(); | ||
}); | ||
} | ||
|
||
ngOnInit() {} | ||
deletePvc(p: PvcWithStatus): void { | ||
this.k8s | ||
.deletePersistentVolumeClaim(p.pvc.namespace, p.pvc.name) | ||
.pipe(first()) | ||
.subscribe(_ => { | ||
this.poller.reset(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,86 +0,0 @@ | ||
.card { | ||
width: 900px; | ||
padding: 0px; | ||
border-radius: 5px; | ||
background: white; | ||
} | ||
|
||
table { | ||
width: 100%; | ||
} | ||
|
||
.header { | ||
display: flex; | ||
align-items: center; | ||
padding: 0px 16px 0px 16px; | ||
height: 64px; | ||
} | ||
|
||
.header p { | ||
font-weight: 400; | ||
font-size: 20px; | ||
} | ||
|
||
.cdk-column-actions { | ||
text-align: center; | ||
} | ||
|
||
.mat-icon { | ||
line-height: 0.85; | ||
} | ||
|
||
td.mat-cell:last-of-type, | ||
td.mat-footer-cell:last-of-type, | ||
th.mat-header-cell:last-of-type { | ||
padding-right: 0px; | ||
} | ||
|
||
.inline { | ||
display: inline-block; | ||
} | ||
|
||
// Status Icons | ||
.running { | ||
color: green; | ||
} | ||
|
||
.warning { | ||
color: orange; | ||
} | ||
|
||
.error { | ||
color: red; | ||
} | ||
|
||
.status { | ||
display: inline-flex; | ||
vertical-align: middle; | ||
} | ||
|
||
.delete { | ||
color: red; | ||
} | ||
|
||
// Flex | ||
.parent { | ||
display: flex; | ||
} | ||
|
||
.spacer { | ||
flex-grow: 1; | ||
} | ||
|
||
th, | ||
td { | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
} | ||
|
||
td.mat-column-image, | ||
td.mat-column-name { | ||
max-width: 200px; | ||
} | ||
|
||
td.mat-column-cpu { | ||
width: 40px; | ||
} | ||
Oops, something went wrong.