diff --git a/docs/reference/module-types/helm.md b/docs/reference/module-types/helm.md index 8e95b4ecc4..95ccdca753 100644 --- a/docs/reference/module-types/helm.md +++ b/docs/reference/module-types/helm.md @@ -696,6 +696,14 @@ tests: key: some-key ``` +### `timeout` + +Time in seconds to wait for Helm to complete any individual Kubernetes operation (like Jobs for hooks). + +| Type | Required | Default | +| -------- | -------- | ------- | +| `number` | No | `300` | + ### `version` The chart version to deploy. @@ -785,6 +793,7 @@ tests: hotReloadArgs: args: env: {} +timeout: 300 version: values: {} valueFiles: [] diff --git a/garden-service/src/plugins/kubernetes/helm/config.ts b/garden-service/src/plugins/kubernetes/helm/config.ts index dfa21ee85c..aaca0af4ba 100644 --- a/garden-service/src/plugins/kubernetes/helm/config.ts +++ b/garden-service/src/plugins/kubernetes/helm/config.ts @@ -29,6 +29,8 @@ import { ContainerModule, ContainerEnvVars, containerEnvVarsSchema, commandExamp import { baseBuildSpecSchema } from "../../../config/module" import { ConfigureModuleParams, ConfigureModuleResult } from "../../../types/plugin/module/configure" +export const defaultHelmTimeout = 300 + // A Helm Module always maps to a single Service export type HelmModuleSpec = HelmServiceSpec @@ -140,6 +142,7 @@ export interface HelmServiceSpec extends ServiceSpec { skipDeploy: boolean tasks: HelmTaskSpec[] tests: HelmTestSpec[] + timeout: number version?: string values: DeepPrimitiveMap valueFiles: string[] @@ -205,6 +208,12 @@ export const helmModuleSpecSchema = joi.object().keys({ .description("The task definitions for this module."), tests: joiArray(execTestSchema) .description("The test suite definitions for this module."), + timeout: joi.number() + .integer() + .default(defaultHelmTimeout) + .description( + "Time in seconds to wait for Helm to complete any individual Kubernetes operation (like Jobs for hooks).", + ), version: joi.string() .description("The chart version to deploy."), values: joi.object() diff --git a/garden-service/src/plugins/kubernetes/helm/deployment.ts b/garden-service/src/plugins/kubernetes/helm/deployment.ts index b2550fa713..8a56d2777b 100644 --- a/garden-service/src/plugins/kubernetes/helm/deployment.ts +++ b/garden-service/src/plugins/kubernetes/helm/deployment.ts @@ -45,22 +45,26 @@ export async function deployService( const k8sCtx = ctx const provider = k8sCtx.provider + const chartPath = await getChartPath(module) const namespace = await getAppNamespace(k8sCtx, log, provider) const releaseName = getReleaseName(module) - const releaseStatus = await getReleaseStatus(k8sCtx, releaseName, log) + const commonArgs = [ + "--namespace", namespace, + "--timeout", module.spec.timeout.toString(10), + ...await getValueFileArgs(module), + ] + if (releaseStatus.state === "missing") { log.silly(`Installing Helm release ${releaseName}`) const installArgs = [ "install", chartPath, "--name", releaseName, - "--namespace", namespace, - ...await getValueFileArgs(module), // Make sure chart gets purged if it fails to install "--atomic", - "--timeout", "600", + ...commonArgs, ] if (force) { installArgs.push("--replace") @@ -71,8 +75,7 @@ export async function deployService( const upgradeArgs = [ "upgrade", releaseName, chartPath, "--install", - "--namespace", namespace, - ...await getValueFileArgs(module), + ...commonArgs, ] if (force) { upgradeArgs.push("--force") diff --git a/garden-service/src/plugins/openfaas/openfaas.ts b/garden-service/src/plugins/openfaas/openfaas.ts index 768dffac38..daf5f40a68 100644 --- a/garden-service/src/plugins/openfaas/openfaas.ts +++ b/garden-service/src/plugins/openfaas/openfaas.ts @@ -142,6 +142,7 @@ async function configureProvider( skipDeploy: false, tasks: [], tests: [], + timeout: 900, version: "4.4.0", releaseName, values: { diff --git a/garden-service/test/unit/src/plugins/kubernetes/helm/config.ts b/garden-service/test/unit/src/plugins/kubernetes/helm/config.ts index 1e7bfd4936..5db223e5ab 100644 --- a/garden-service/test/unit/src/plugins/kubernetes/helm/config.ts +++ b/garden-service/test/unit/src/plugins/kubernetes/helm/config.ts @@ -8,6 +8,7 @@ import { deline } from "../../../../../../src/util/string" import { ModuleConfig } from "../../../../../../src/config/module" import { apply } from "json-merge-patch" import { getHelmTestGarden } from "./common" +import { defaultHelmTimeout } from "../../../../../../src/plugins/kubernetes/helm/config" describe("validateHelmModule", () => { let garden: TestGarden @@ -77,6 +78,7 @@ describe("validateHelmModule", () => { skipDeploy: false, tasks: [], tests: [], + timeout: defaultHelmTimeout, values: { image: { tag: versionString, @@ -109,6 +111,7 @@ describe("validateHelmModule", () => { skipDeploy: false, tasks: [], tests: [], + timeout: defaultHelmTimeout, values: { image: { tag: versionString,