Skip to content

Commit

Permalink
fix: wks ingress create/delete logic (#41)
Browse files Browse the repository at this point in the history
* chore: remove ingress when workspace is disabled

* chore: remove unneeded k8s client

* fix: regenerate openUrl and health url on update

* fix: ingress delete logic
  • Loading branch information
avatxus authored Sep 30, 2023
1 parent 464da44 commit a18d947
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions operator/src/workspaces/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,17 @@ export async function handleResource(
async function handleIngress(ns: string, name: string, spec: Workspace.Spec, owner: CustomResource<Workspace.Spec, Workspace.Status>) {
const { net } = getClients();

if (spec.enabled) {
const exists = await net.readNamespacedIngress(name, ns).catch(() => false);

if (spec.enabled && !exists) {
console.log('Creating ingress for workspace', name);
await net
.createNamespacedIngress(ns, ingress(name, buildDnsZone(spec), owner))
.catch(() => console.log('Error creating ingress for workspace', name));
} else {
.catch((err: any) => console.log('Error creating ingress for workspace', name, err.body));
}

if (!spec.enabled && exists) {
console.log('Deleting ingress for workspace', name);
await net.deleteNamespacedIngress(name, ns).catch(() => console.log('Error deleting ingress for workspace', name));
}
}
Expand Down

0 comments on commit a18d947

Please sign in to comment.