From e3db60af2eb0b66d235ec1f22fdf4dfe6c0969b9 Mon Sep 17 00:00:00 2001 From: Jon Edvald Date: Tue, 3 Sep 2019 22:19:24 +0200 Subject: [PATCH] fix(k8s): error when retrieving older test results from cache --- .../src/plugins/kubernetes/container/test.ts | 12 ++++++++++- .../src/plugins/kubernetes/helm/test.ts | 5 ++++- .../src/plugins/kubernetes/task-results.ts | 17 +++------------- .../src/plugins/kubernetes/test-results.ts | 20 +++++++++++-------- .../src/types/plugin/task/runTask.ts | 7 ------- 5 files changed, 30 insertions(+), 31 deletions(-) diff --git a/garden-service/src/plugins/kubernetes/container/test.ts b/garden-service/src/plugins/kubernetes/container/test.ts index af03b65943..e4dc27a665 100644 --- a/garden-service/src/plugins/kubernetes/container/test.ts +++ b/garden-service/src/plugins/kubernetes/container/test.ts @@ -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, + }, + }) } diff --git a/garden-service/src/plugins/kubernetes/helm/test.ts b/garden-service/src/plugins/kubernetes/helm/test.ts index 23753a789a..e11083e343 100644 --- a/garden-service/src/plugins/kubernetes/helm/test.ts +++ b/garden-service/src/plugins/kubernetes/helm/test.ts @@ -71,6 +71,9 @@ export async function testHelmModule( module, testName, testVersion, - result, + result: { + testName, + ...result, + }, }) } diff --git a/garden-service/src/plugins/kubernetes/task-results.ts b/garden-service/src/plugins/kubernetes/task-results.ts index 86b450159a..378a908e23 100644 --- a/garden-service/src/plugins/kubernetes/task-results.ts +++ b/garden-service/src/plugins/kubernetes/task-results.ts @@ -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) { @@ -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, diff --git a/garden-service/src/plugins/kubernetes/test-results.ts b/garden-service/src/plugins/kubernetes/test-results.ts index 5a6ac99c0e..49ddd2c45c 100644 --- a/garden-service/src/plugins/kubernetes/test-results.ts +++ b/garden-service/src/plugins/kubernetes/test-results.ts @@ -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" @@ -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 } @@ -63,7 +70,7 @@ interface StoreTestResultParams { module: Module, testName: string, testVersion: ModuleVersion, - result: RunResult, + result: TestResult, } /** @@ -77,10 +84,7 @@ export async function storeTestResult( const k8sCtx = ctx const api = await KubeApi.factory(log, k8sCtx.provider) - const testResult: TestResult = { - ...trimRunOutput(result), - testName, - } + const data: TestResult = trimRunOutput(result) await upsertConfigMap({ api, @@ -92,8 +96,8 @@ export async function storeTestResult( [gardenAnnotationKey("moduleVersion")]: module.version.versionString, [gardenAnnotationKey("version")]: testVersion.versionString, }, - data: testResult, + data, }) - return testResult + return data } diff --git a/garden-service/src/types/plugin/task/runTask.ts b/garden-service/src/types/plugin/task/runTask.ts index d6839f9a91..63aed0ddae 100644 --- a/garden-service/src/types/plugin/task/runTask.ts +++ b/garden-service/src/types/plugin/task/runTask.ts @@ -22,14 +22,7 @@ export interface RunTaskParams 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 }