From f1c521f254be3553b0e6e5c9b6299b63cb9c49da Mon Sep 17 00:00:00 2001 From: Thorarinn Sigurdsson Date: Wed, 21 Oct 2020 13:41:40 +0200 Subject: [PATCH] fix(kubernetes-module): fix regression This fixes a regression introduced when we added hot reloading support for the `kubernetes-module` module type. Also added an integ test case to guard against this regression in the future. --- .../kubernetes/kubernetes-module/handlers.ts | 3 +-- .../kubernetes-module/module-simple/garden.yml | 1 + .../kubernetes-module/with-namespace/garden.yml | 1 + .../kubernetes/kubernetes-module/config.ts | 2 ++ .../kubernetes/kubernetes-module/handlers.ts | 15 +++++++++++++++ 5 files changed, 20 insertions(+), 2 deletions(-) diff --git a/core/src/plugins/kubernetes/kubernetes-module/handlers.ts b/core/src/plugins/kubernetes/kubernetes-module/handlers.ts index 5ebab0acdc..40cebdab66 100644 --- a/core/src/plugins/kubernetes/kubernetes-module/handlers.ts +++ b/core/src/plugins/kubernetes/kubernetes-module/handlers.ts @@ -286,8 +286,7 @@ async function prepareManifestsForHotReload({ } } - const hotReloadSpec = getHotReloadSpec(service) - + const hotReloadSpec = hotReload ? getHotReloadSpec(service) : null if (hotReload && hotReloadSpec) { const resourceSpec = getServiceResourceSpec(module, undefined) configureHotReload({ diff --git a/core/test/data/test-projects/kubernetes-module/module-simple/garden.yml b/core/test/data/test-projects/kubernetes-module/module-simple/garden.yml index 4346f2e0a1..9a4556c0de 100644 --- a/core/test/data/test-projects/kubernetes-module/module-simple/garden.yml +++ b/core/test/data/test-projects/kubernetes-module/module-simple/garden.yml @@ -22,6 +22,7 @@ manifests: containers: - name: busybox image: busybox:1.31.1 + args: [sleep, "100"] ports: - containerPort: 80 serviceResource: diff --git a/core/test/data/test-projects/kubernetes-module/with-namespace/garden.yml b/core/test/data/test-projects/kubernetes-module/with-namespace/garden.yml index d8d355536c..ca11029595 100644 --- a/core/test/data/test-projects/kubernetes-module/with-namespace/garden.yml +++ b/core/test/data/test-projects/kubernetes-module/with-namespace/garden.yml @@ -23,6 +23,7 @@ manifests: containers: - name: busybox image: busybox:1.31.1 + args: [sleep, "100"] ports: - containerPort: 80 env: diff --git a/core/test/integ/src/plugins/kubernetes/kubernetes-module/config.ts b/core/test/integ/src/plugins/kubernetes/kubernetes-module/config.ts index 90006f63fc..9307e0256c 100644 --- a/core/test/integ/src/plugins/kubernetes/kubernetes-module/config.ts +++ b/core/test/integ/src/plugins/kubernetes/kubernetes-module/config.ts @@ -128,6 +128,7 @@ describe("validateKubernetesModule", () => { { image: "busybox:1.31.1", name: "busybox", + args: ["sleep", "100"], ports: [ { containerPort: 80, @@ -180,6 +181,7 @@ describe("validateKubernetesModule", () => { { image: "busybox:1.31.1", name: "busybox", + args: ["sleep", "100"], ports: [ { containerPort: 80, diff --git a/core/test/integ/src/plugins/kubernetes/kubernetes-module/handlers.ts b/core/test/integ/src/plugins/kubernetes/kubernetes-module/handlers.ts index 1a903a192a..81ad632699 100644 --- a/core/test/integ/src/plugins/kubernetes/kubernetes-module/handlers.ts +++ b/core/test/integ/src/plugins/kubernetes/kubernetes-module/handlers.ts @@ -114,6 +114,21 @@ describe("kubernetes-module handlers", () => { }) describe("deployKubernetesService", () => { + it("should successfully deploy when serviceResource doesn't have a containerModule", async () => { + const graph = await garden.getConfigGraph(garden.log) + const service = graph.getService("module-simple") + const deployParams = { + ctx, + log: garden.log, + module: service.module, + service, + force: false, + hotReload: false, + runtimeContext: emptyRuntimeContext, + } + await deployKubernetesService(deployParams) + }) + it("should toggle hot reload", async () => { const graph = await garden.getConfigGraph(garden.log) const service = graph.getService("with-source-module")