Skip to content

Commit

Permalink
fix(k8s): error when retrieving older test results from cache
Browse files Browse the repository at this point in the history
  • Loading branch information
edvald committed Sep 3, 2019
1 parent 8afa8f6 commit e3db60a
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 31 deletions.
12 changes: 11 additions & 1 deletion garden-service/src/plugins/kubernetes/container/test.ts
Expand Up @@ -56,5 +56,15 @@ export async function testContainerModule(
timeout,
})

return storeTestResult({ ctx, log, module, testName, testVersion, result })
return storeTestResult({
ctx,
log,
module,
testName,
testVersion,
result: {
testName,
...result,
},
})
}
5 changes: 4 additions & 1 deletion garden-service/src/plugins/kubernetes/helm/test.ts
Expand Up @@ -71,6 +71,9 @@ export async function testHelmModule(
module,
testName,
testVersion,
result,
result: {
testName,
...result,
},
})
}
17 changes: 3 additions & 14 deletions garden-service/src/plugins/kubernetes/task-results.ts
Expand Up @@ -36,16 +36,12 @@ export async function getTaskResult(
const result: any = deserializeValues(res.data!)

// Backwards compatibility for modified result schema
if (result.output) {
result.log = result.output
}

if (!result.outputs) {
result.outputs = {}
}

if (!result.outputs.stdout) {
result.outputs.log = result.log
if (!result.outputs.log) {
result.outputs.log = result.log || ""
}

if (result.version.versionString) {
Expand Down Expand Up @@ -89,14 +85,7 @@ export async function storeTaskResult(
const api = await KubeApi.factory(log, provider)
const namespace = await getMetadataNamespace(ctx, log, provider)

result = trimRunOutput(result)

const data: RunTaskResult = {
...result,
outputs: {
log: result.log,
},
}
const data = trimRunOutput(result)

await upsertConfigMap({
api,
Expand Down
20 changes: 12 additions & 8 deletions garden-service/src/plugins/kubernetes/test-results.ts
Expand Up @@ -17,7 +17,6 @@ import { KubernetesPluginContext } from "./config"
import { systemMetadataNamespace } from "./system"
import { LogEntry } from "../../logger/log-entry"
import { GetTestResultParams, TestResult } from "../../types/plugin/module/getTestResult"
import { RunResult } from "../../types/plugin/base"
import * as hasha from "hasha"
import { gardenAnnotationKey } from "../../util/string"
import { upsertConfigMap } from "./util"
Expand All @@ -37,6 +36,14 @@ export async function getTestResult(
const result: any = deserializeValues(res.data!)

// Backwards compatibility for modified result schema
if (!result.outputs) {
result.outputs = {}
}

if (!result.outputs.log) {
result.outputs.log = result.log || ""
}

if (result.version.versionString) {
result.version = result.version.versionString
}
Expand All @@ -63,7 +70,7 @@ interface StoreTestResultParams {
module: Module,
testName: string,
testVersion: ModuleVersion,
result: RunResult,
result: TestResult,
}

/**
Expand All @@ -77,10 +84,7 @@ export async function storeTestResult(
const k8sCtx = <KubernetesPluginContext>ctx
const api = await KubeApi.factory(log, k8sCtx.provider)

const testResult: TestResult = {
...trimRunOutput(result),
testName,
}
const data: TestResult = trimRunOutput(result)

await upsertConfigMap({
api,
Expand All @@ -92,8 +96,8 @@ export async function storeTestResult(
[gardenAnnotationKey("moduleVersion")]: module.version.versionString,
[gardenAnnotationKey("version")]: testVersion.versionString,
},
data: testResult,
data,
})

return testResult
return data
}
7 changes: 0 additions & 7 deletions garden-service/src/types/plugin/task/runTask.ts
Expand Up @@ -22,14 +22,7 @@ export interface RunTaskParams<T extends Module = Module> extends PluginTaskActi
}

export interface RunTaskResult extends RunResult {
moduleName: string
taskName: string
command: string[]
version: string
success: boolean
startedAt: Date
completedAt: Date
log: string
outputs: PrimitiveMap
}

Expand Down

0 comments on commit e3db60a

Please sign in to comment.