-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(k8s): error when task logs were longer than 500kB
This fix is a hacky temporary fix, just to get rid of the error case. A better solution would be to store logs as files somehow, e.g. in a persistent volume.
- Loading branch information
Showing
5 changed files
with
122 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
garden-service/test/integ/src/plugins/kubernetes/task-results.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Copyright (C) 2018-2020 Garden Technologies, Inc. <[email protected]> | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
import { Garden } from "../../../../../src/garden" | ||
import { Provider } from "../../../../../src/config/provider" | ||
import { KubernetesConfig } from "../../../../../src/plugins/kubernetes/config" | ||
import { getDataDir, makeTestGarden } from "../../../../helpers" | ||
import { randomString } from "../../../../../src/util/string" | ||
import { expect } from "chai" | ||
import { storeTaskResult, getTaskResult } from "../../../../../src/plugins/kubernetes/task-results" | ||
import { MAX_RUN_RESULT_LOG_LENGTH } from "../../../../../src/plugins/kubernetes/constants" | ||
|
||
describe("kubernetes task results", () => { | ||
let garden: Garden | ||
let provider: Provider<KubernetesConfig> | ||
|
||
before(async () => { | ||
const root = getDataDir("test-projects", "container") | ||
garden = await makeTestGarden(root) | ||
provider = (await garden.resolveProvider("local-kubernetes")) as Provider<KubernetesConfig> | ||
}) | ||
|
||
after(async () => { | ||
await garden.close() | ||
}) | ||
|
||
describe("storeTaskResult", () => { | ||
it("should trim logs when necessary", async () => { | ||
const ctx = garden.getPluginContext(provider) | ||
const graph = await garden.getConfigGraph(garden.log) | ||
const task = await graph.getTask("echo-task") | ||
|
||
const data = randomString(1024 * 1024) | ||
|
||
const trimmed = await storeTaskResult({ | ||
ctx, | ||
log: garden.log, | ||
module: task.module, | ||
taskName: task.name, | ||
taskVersion: task.module.version, | ||
result: { | ||
moduleName: task.module.name, | ||
taskName: task.name, | ||
outputs: { log: data }, | ||
log: data, | ||
startedAt: new Date(), | ||
completedAt: new Date(), | ||
command: [], | ||
version: task.module.version.versionString, | ||
success: true, | ||
}, | ||
}) | ||
|
||
expect(trimmed.log.length).to.be.lte(MAX_RUN_RESULT_LOG_LENGTH) | ||
|
||
const stored = await getTaskResult({ | ||
ctx, | ||
log: garden.log, | ||
module: task.module, | ||
task, | ||
taskVersion: task.module.version, | ||
}) | ||
|
||
expect(stored).to.exist | ||
expect(stored!.log.length).to.equal(trimmed.log.length) | ||
|
||
const outputsLog = stored!.outputs.log as string | ||
expect(outputsLog.length).to.equal(trimmed.log.length) | ||
}) | ||
}) | ||
}) |