From f381d33f1ca059cb9375946d96f380cff746952b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ey=C3=BE=C3=B3r=20Magn=C3=BAsson?= Date: Fri, 6 Jul 2018 16:54:37 +0200 Subject: [PATCH] fix: ensure namespace is removed before returning when deleting env --- src/plugins/kubernetes/actions.ts | 14 ++++++-------- src/plugins/kubernetes/namespace.ts | 2 +- static/bin/garden-debug | 5 +++++ 3 files changed, 12 insertions(+), 9 deletions(-) create mode 100755 static/bin/garden-debug diff --git a/src/plugins/kubernetes/actions.ts b/src/plugins/kubernetes/actions.ts index f79cd508df..b5dfc5878f 100644 --- a/src/plugins/kubernetes/actions.ts +++ b/src/plugins/kubernetes/actions.ts @@ -50,7 +50,7 @@ import { createNamespace, getAppNamespace, getMetadataNamespace, - getAllAppNamespaces, + getAllGardenNamespaces, } from "./namespace" import { KUBECTL_DEFAULT_TIMEOUT, @@ -141,12 +141,12 @@ export async function getServiceStatus(params: GetServiceStatusParams{}) } catch (err) { entry.setError(err.message) - const availableNamespaces = await getAllAppNamespaces(context) + const availableNamespaces = await getAllGardenNamespaces(context) throw new NotFoundError(err, { namespace, availableNamespaces }) } @@ -165,10 +165,8 @@ export async function destroyEnvironment({ ctx, provider, env }: DestroyEnvironm while (true) { await sleep(2000) - const status = await getEnvironmentStatus({ ctx, provider, env }) - - if (!status.configured) { - entry.setSuccess("Finished") + const nsNames = await getAllGardenNamespaces(context) + if (!nsNames.includes(namespace)) { break } diff --git a/src/plugins/kubernetes/namespace.ts b/src/plugins/kubernetes/namespace.ts index 90424c748b..71682c7c14 100644 --- a/src/plugins/kubernetes/namespace.ts +++ b/src/plugins/kubernetes/namespace.ts @@ -60,7 +60,7 @@ export function getMetadataNamespace(ctx: PluginContext, provider: KubernetesPro return `garden-metadata--${ctx.projectName}--${env.namespace}` } -export async function getAllAppNamespaces(context: string): Promise { +export async function getAllGardenNamespaces(context: string): Promise { const allNamespaces = await coreApi(context).listNamespace() return allNamespaces.body.items .map(n => n.metadata.name) diff --git a/static/bin/garden-debug b/static/bin/garden-debug new file mode 100755 index 0000000000..bc92b0d77c --- /dev/null +++ b/static/bin/garden-debug @@ -0,0 +1,5 @@ +#!/usr/bin/env node --inspect + +const cli = require("../../build/cli/cli") + +cli.run()