Skip to content

Commit

Permalink
fix(k8s): make helm & k8s tasks respect timeouts
Browse files Browse the repository at this point in the history
Before this fix, the `task.timeout` config field was not being
respected for `helm` and `kubernetes` tasks.

We now correctly use the configured value, and fall back to a
default, explicit constant for `timeout` when calling
`runAndCopy`.
  • Loading branch information
thsig authored and eysi09 committed May 27, 2020
1 parent 5062c9e commit 8b4a4b8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions garden-service/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const DEFAULT_PORT_PROTOCOL = "TCP"
export const DEFAULT_API_VERSION = "garden.io/v0"

export const DEFAULT_TEST_TIMEOUT = 60 * 1000
export const DEFAULT_TASK_TIMEOUT = 60 * 1000

export type SupportedPlatform = "linux" | "darwin" | "win32"
export const SUPPORTED_PLATFORMS: SupportedPlatform[] = ["linux", "darwin", "win32"]
Expand Down
5 changes: 3 additions & 2 deletions garden-service/src/plugins/kubernetes/helm/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { prepareEnvVars } from "../util"
import { V1PodSpec } from "@kubernetes/client-node"
import { KubeApi } from "../api"
import { getModuleNamespace } from "../namespace"
import { DEFAULT_TASK_TIMEOUT } from "../../../constants"

export async function runHelmModule({
ctx,
Expand Down Expand Up @@ -97,7 +98,7 @@ export async function runHelmModule({
}

export async function runHelmTask(params: RunTaskParams<HelmModule>): Promise<RunTaskResult> {
const { ctx, log, module, task, taskVersion, timeout } = params
const { ctx, log, module, task, taskVersion } = params
// TODO: deduplicate this from testHelmModule
const k8sCtx = <KubernetesPluginContext>ctx

Expand Down Expand Up @@ -132,7 +133,7 @@ export async function runHelmTask(params: RunTaskParams<HelmModule>): Promise<Ru
namespace,
podName: makePodName("task", module.name, task.name),
description: `Task '${task.name}' in container module '${module.name}'`,
timeout,
timeout: task.config.timeout || DEFAULT_TASK_TIMEOUT,
})

const result: RunTaskResult = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ import { RunTaskParams, RunTaskResult } from "../../../types/plugin/task/runTask
import { getManifests } from "./common"
import { KubeApi } from "../api"
import { getModuleNamespace } from "../namespace"
import { DEFAULT_TASK_TIMEOUT } from "../../../constants"

export async function runKubernetesTask(params: RunTaskParams<KubernetesModule>): Promise<RunTaskResult> {
const { ctx, log, module, task, taskVersion, timeout } = params
const { ctx, log, module, task, taskVersion } = params
const k8sCtx = <KubernetesPluginContext>ctx
const namespace = await getModuleNamespace({
ctx: k8sCtx,
Expand Down Expand Up @@ -52,7 +53,7 @@ export async function runKubernetesTask(params: RunTaskParams<KubernetesModule>)
namespace,
podName: makePodName("task", module.name, task.name),
description: `Task '${task.name}' in container module '${module.name}'`,
timeout,
timeout: task.config.timeout || DEFAULT_TASK_TIMEOUT,
})

const result = {
Expand Down

0 comments on commit 8b4a4b8

Please sign in to comment.