From d286b92581d337c4cb97b47e96961624c9555eda Mon Sep 17 00:00:00 2001 From: Vladimir Vagaytsev <10628074+vvagaytsev@users.noreply.github.com> Date: Thu, 26 Sep 2024 16:50:11 +0200 Subject: [PATCH] chore: minor fixes and improvements in logging (#6487) * chore: fix action config counter * chore: change log message * chore: use dot accessor * refactor: use GraphSolver's logger in most cases * refactor: remove unused log param from SolveParams * refactor: remove unused argument * refactor: lazy messages in silly-logging --- core/src/commands/build.ts | 2 +- core/src/commands/delete.ts | 2 +- core/src/commands/deploy.ts | 2 +- core/src/commands/publish.ts | 2 +- core/src/commands/run.ts | 2 +- core/src/commands/sync/sync-start.ts | 4 +- core/src/commands/test.ts | 2 +- core/src/garden.ts | 9 ++-- core/src/graph/actions.ts | 6 +-- core/src/graph/solver.ts | 47 ++++++++----------- core/src/outputs.ts | 2 +- core/src/plugins/kubernetes/logs.ts | 2 +- core/src/plugins/kubernetes/namespace.ts | 2 +- core/src/router/router.ts | 6 +-- core/src/util/testing.ts | 5 -- core/src/vcs/git-sub-tree.ts | 2 +- core/src/vcs/git.ts | 4 +- .../src/plugins/kubernetes/commands/exec.ts | 2 +- .../src/plugins/kubernetes/commands/sync.ts | 2 +- .../kubernetes/container/build/build.ts | 2 +- .../kubernetes/container/deployment.ts | 12 ++--- .../src/plugins/kubernetes/helm/common.ts | 3 +- .../src/plugins/kubernetes/local-mode.ts | 2 +- core/test/unit/src/commands/publish.ts | 6 +-- core/test/unit/src/graph/solver.ts | 2 +- core/test/unit/src/tasks/resolve-action.ts | 24 +++++----- .../test/conftest-kubernetes.ts | 2 +- plugins/conftest/test/conftest.ts | 8 ++-- plugins/pulumi/src/commands.ts | 3 +- plugins/terraform/test/terraform.ts | 8 ++-- 30 files changed, 83 insertions(+), 94 deletions(-) diff --git a/core/src/commands/build.ts b/core/src/commands/build.ts index 6055a9e6ce..05e3ab1fa8 100644 --- a/core/src/commands/build.ts +++ b/core/src/commands/build.ts @@ -122,7 +122,7 @@ export class BuildCommand extends Command { }) ) - const result = await garden.processTasks({ tasks, log }) + const result = await garden.processTasks({ tasks }) return handleProcessResults(garden, log, "build", result) } diff --git a/core/src/commands/delete.ts b/core/src/commands/delete.ts index 55399945d3..5ee3e4b268 100644 --- a/core/src/commands/delete.ts +++ b/core/src/commands/delete.ts @@ -203,7 +203,7 @@ export class DeleteDeployCommand extends Command { return task }) - const results = await garden.processTasks({ tasks, log }) + const results = await garden.processTasks({ tasks }) return handleProcessResults(garden, log, "deploy", results) } diff --git a/core/src/commands/publish.ts b/core/src/commands/publish.ts index 926b70489a..4300941502 100644 --- a/core/src/commands/publish.ts +++ b/core/src/commands/publish.ts @@ -104,7 +104,7 @@ export class PublishCommand extends Command { }) }) - const processed = await garden.processTasks({ tasks, log, throwOnError: true }) + const processed = await garden.processTasks({ tasks, throwOnError: true }) return handleProcessResults(garden, log, "publish", processed) } } diff --git a/core/src/commands/run.ts b/core/src/commands/run.ts index d3eda2e29b..b72a6d6921 100644 --- a/core/src/commands/run.ts +++ b/core/src/commands/run.ts @@ -208,7 +208,7 @@ export class RunCommand extends Command { }) ) - const results = await garden.processTasks({ tasks, log }) + const results = await garden.processTasks({ tasks }) return handleProcessResults(garden, log, "run", results) } diff --git a/core/src/commands/sync/sync-start.ts b/core/src/commands/sync/sync-start.ts index e81b72adc4..6c7644a35d 100644 --- a/core/src/commands/sync/sync-start.ts +++ b/core/src/commands/sync/sync-start.ts @@ -171,7 +171,7 @@ export class SyncStartCommand extends Command { } return task }) - await garden.processTasks({ tasks, log }) + await garden.processTasks({ tasks }) log.success({ msg: "\nDone!", showDuration: false }) return {} } else { @@ -224,7 +224,7 @@ export async function startSyncWithoutDeploy({ }) }) - const statusResult = await garden.processTasks({ log, tasks, statusOnly: true }) + const statusResult = await garden.processTasks({ tasks, statusOnly: true }) let someSyncStarted = false const router = await garden.getActionRouter() diff --git a/core/src/commands/test.ts b/core/src/commands/test.ts index 856dc6dd0d..e8f989e408 100644 --- a/core/src/commands/test.ts +++ b/core/src/commands/test.ts @@ -221,7 +221,7 @@ export class TestCommand extends Command { }) } - const results = await garden.processTasks({ tasks, log }) + const results = await garden.processTasks({ tasks }) return handleProcessResults(garden, log, "test", results) } diff --git a/core/src/garden.ts b/core/src/garden.ts index 7aa6009d5f..5c10daf814 100644 --- a/core/src/garden.ts +++ b/core/src/garden.ts @@ -606,8 +606,8 @@ export class Garden { return this.solver.solve(params) } - async processTask(task: T, log: Log, opts: SolveOpts): Promise | null> { - const { results } = await this.solver.solve({ tasks: [task], log, ...opts }) + async processTask(task: T, opts: SolveOpts): Promise | null> { + const { results } = await this.solver.solve({ tasks: [task], ...opts }) return results.getResult(task) } @@ -847,7 +847,7 @@ export class Garden { }) // Process as many providers in parallel as possible - const taskResults = await this.processTasks({ tasks, log, statusOnly }) + const taskResults = await this.processTasks({ tasks, statusOnly }) const providerResults = Object.values(taskResults.results.getMap()) @@ -1493,6 +1493,7 @@ export class Garden { for (const config of actionsFromTemplates) { this.addActionConfig(config) + actionsCount++ } this.log.debug( @@ -1545,7 +1546,7 @@ export class Garden { * Add an action config to the context, after validating and calling the appropriate configure plugin handler. */ protected addActionConfig(config: BaseActionConfig) { - this.log.silly(() => `Adding ${config.kind} action ${config.name}`) + this.log.silly(() => `Adding action config for ${config.kind} ${config.name}`) const key = actionReferenceToString(config) const existing = this.actionConfigs[config.kind][config.name] diff --git a/core/src/graph/actions.ts b/core/src/graph/actions.ts index 6b3ded9cb5..ed2b489c8b 100644 --- a/core/src/graph/actions.ts +++ b/core/src/graph/actions.ts @@ -543,7 +543,7 @@ export async function resolveAction({ force: true, }) - const results = await garden.processTasks({ tasks: [task], log, throwOnError: true }) + const results = await garden.processTasks({ tasks: [task], throwOnError: true }) log.success({ msg: `Done`, showDuration: false }) @@ -581,7 +581,7 @@ export async function resolveActions({ }) ) - const results = await garden.processTasks({ tasks, log, throwOnError: true }) + const results = await garden.processTasks({ tasks, throwOnError: true }) return >(mapValues(results.results.getMap(), (r) => r!.result!.outputs.resolvedAction)) } @@ -611,7 +611,7 @@ export async function executeAction({ force: true, }) - const results = await garden.processTasks({ tasks: [task], log, throwOnError: true, statusOnly }) + const results = await garden.processTasks({ tasks: [task], throwOnError: true, statusOnly }) return >(results.results.getResult(task)!.result!.executedAction) } diff --git a/core/src/graph/solver.ts b/core/src/graph/solver.ts index 831b57e635..709cd1c1f5 100644 --- a/core/src/graph/solver.ts +++ b/core/src/graph/solver.ts @@ -11,7 +11,7 @@ import type { Log } from "../logger/log-entry.js" import type { GardenError, GardenErrorParams } from "../exceptions.js" import { GraphError, toGardenError } from "../exceptions.js" import { uuidv4 } from "../util/random.js" -import { DependencyGraph, metadataForLog } from "./common.js" +import { DependencyGraph } from "./common.js" import { Profile } from "../util/profiling.js" import { TypedEventEmitter } from "../util/events.js" import { groupBy, keyBy } from "lodash-es" @@ -34,7 +34,6 @@ export interface SolveOpts { } export interface SolveParams extends SolveOpts { - log: Log tasks: T[] } @@ -67,7 +66,7 @@ export class GraphSolver extends TypedEventEmitter { ) { super() - this.log = garden.log + this.log = garden.log.createLog({ name: "graph-solver" }) this.inLoop = false this.requestedTasks = {} this.nodes = {} @@ -91,18 +90,19 @@ export class GraphSolver extends TypedEventEmitter { } async solve(params: SolveParams): Promise { - const { statusOnly, tasks, throwOnError, log } = params + const { statusOnly, tasks, throwOnError } = params const batchId = uuidv4() const results = new GraphResults(tasks) let aborted = false - log.silly(`GraphSolver: Starting batch ${batchId} (${tasks.length} tasks)`) + this.log.silly(() => `Starting batch ${batchId} (${tasks.length} tasks)`) if (tasks.length === 0) { return { results, error: null } } + const log = this.log // TODO-0.13.1+: remove this lock and test with concurrent execution return this.lock.acquire("solve", async () => { const output = await new Promise((resolve, reject) => { @@ -114,7 +114,7 @@ export class GraphSolver extends TypedEventEmitter { ) function completeHandler(result: GraphResult) { - log.silly(`GraphSolver: Complete handler for batch ${batchId} called with result ${result.key}`) + log.silly(() => `Complete handler for batch ${batchId} called with result ${result.key}`) if (aborted) { return @@ -129,7 +129,7 @@ export class GraphSolver extends TypedEventEmitter { return } - log.silly(`GraphSolver: Complete handler for batch ${batchId} matched with request ${request.getKey()}`) + log.silly(() => `Complete handler for batch ${batchId} matched with request ${request.getKey()}`) results.setResult(request.task, result) @@ -148,7 +148,7 @@ export class GraphSolver extends TypedEventEmitter { if (missing.length > 0) { const missingKeys = missing.map((t) => t.getBaseKey()) - log.silly(`Batch ${batchId} has ${missing.length} result(s) still missing: ${missingKeys.join(", ")}`) + log.silly(() => `Batch ${batchId} has ${missing.length} result(s) still missing: ${missingKeys.join(", ")}`) // Keep going if any of the expected results are pending return } @@ -182,9 +182,9 @@ export class GraphSolver extends TypedEventEmitter { cleanup({ error: null }) if (error) { - log.silly(`Batch ${batchId} failed: ${error.message}`) + log.silly(() => `Batch ${batchId} failed: ${error.message}`) } else { - log.silly(`Batch ${batchId} completed`) + log.silly(() => `Batch ${batchId} completed`) } resolve({ error, results }) @@ -380,7 +380,7 @@ export class GraphSolver extends TypedEventEmitter { return } - this.logTask(node) + this.log.silly(() => `Processing node ${taskStyle(node.getKey())}`) try { const processResult = await node.execute() @@ -445,7 +445,10 @@ export class GraphSolver extends TypedEventEmitter { } const currentlyActive = Object.values(this.inProgress).map((n) => n.describe()) - this.log.silly(`Task nodes in progress: ${currentlyActive.length > 0 ? currentlyActive.join(", ") : "(none)"}`) + this.log.silly( + () => + `Task nodes in progress (${currentlyActive.length}): ${currentlyActive.length > 0 ? currentlyActive.join(", ") : "(none)"}` + ) } private ensurePendingNode(node: TaskNode, dependant: TaskNode) { @@ -486,19 +489,6 @@ export class GraphSolver extends TypedEventEmitter { // // Logging // - private logTask(node: TaskNode) { - // The task.log instance is of type ActionLog but we want to use a "CoreLog" here. - const taskLog = node.task.log.root.createLog({ name: "graph-solver" }) - taskLog.silly({ - msg: `Processing node ${taskStyle(node.getKey())}`, - metadata: metadataForLog({ - task: node.task, - inputVersion: node.getInputVersion(), - status: "active", - }), - }) - } - private logTaskError(node: TaskNode, err: Error) { const log = node.task.log const prefix = `Failed ${node.describe()} ${renderDuration(log.getDuration())}. This is what happened:` @@ -506,8 +496,9 @@ export class GraphSolver extends TypedEventEmitter { } private logInternalError(node: TaskNode, err: Error) { - const prefix = `An internal error occurred while ${node.describe()}. This is what happened:` - this.logError(node.task.log, err, prefix) + const log = node.task.log + const prefix = `An internal error occurred while ${node.describe()} ${renderDuration(log.getDuration())}. This is what happened:` + this.logError(log, err, prefix) } private logError(log: Log, err: Error, errMessagePrefix: string) { @@ -519,7 +510,7 @@ export class GraphSolver extends TypedEventEmitter { }) log.error({ msg, rawMsg, error, showDuration: false }) const divider = renderDivider() - log.silly( + log.silly(() => styles.primary(`Full error with stack trace and wrapped errors:\n${divider}\n${error.toString(true)}\n${divider}`) ) } diff --git a/core/src/outputs.ts b/core/src/outputs.ts index 0512c03331..4f0b388f89 100644 --- a/core/src/outputs.ts +++ b/core/src/outputs.ts @@ -94,7 +94,7 @@ export async function resolveProjectOutputs(garden: Garden, log: Log): Promise 0 - ? await garden.processTasks({ tasks: graphTasks, log, throwOnError: true }) + ? await garden.processTasks({ tasks: graphTasks, throwOnError: true }) : { results: new GraphResults([]) } const configContext = await garden.getOutputConfigContext(log, modules, results) diff --git a/core/src/plugins/kubernetes/logs.ts b/core/src/plugins/kubernetes/logs.ts index 153fe22498..696d399180 100644 --- a/core/src/plugins/kubernetes/logs.ts +++ b/core/src/plugins/kubernetes/logs.ts @@ -337,7 +337,7 @@ export class K8sLogFollower { } } catch (e) { if (e instanceof KubernetesError) { - this.log.silly(``) + this.log.silly(() => ``) // retry once if the pod status query returned 404 if (e.responseStatusCode === 404 && prevStatus === "error") { stopRetrying("The pod or the namespace does not exist") diff --git a/core/src/plugins/kubernetes/namespace.ts b/core/src/plugins/kubernetes/namespace.ts index d585f78b20..b99a80576e 100644 --- a/core/src/plugins/kubernetes/namespace.ts +++ b/core/src/plugins/kubernetes/namespace.ts @@ -287,7 +287,7 @@ export async function prepareNamespaces({ ctx, log }: GetEnvironmentStatusParams if (!(err instanceof KubernetesError)) { throw err } - log.silly(`Full Kubernetes connect error: ${err.stack}`) + log.silly(() => `Full Kubernetes connect error: ${err.stack}`) throw new DeploymentError({ message: dedent` diff --git a/core/src/router/router.ts b/core/src/router/router.ts index 7efc5415c5..fdfb8746f8 100644 --- a/core/src/router/router.ts +++ b/core/src/router/router.ts @@ -123,7 +123,7 @@ export class ActionRouter extends BaseRouter { forceActions: [], }) ) - const { results } = await this.garden.processTasks({ tasks, log, throwOnError: true, statusOnly: true }) + const { results } = await this.garden.processTasks({ tasks, throwOnError: true, statusOnly: true }) return getDeployStatuses(results) } @@ -143,7 +143,7 @@ export class ActionRouter extends BaseRouter { }) ) - return this.garden.processTasks({ tasks, log }) + return this.garden.processTasks({ tasks }) } /** @@ -176,7 +176,7 @@ export class ActionRouter extends BaseRouter { }) }) - const { results } = await this.garden.processTasks({ tasks, log, throwOnError: true }) + const { results } = await this.garden.processTasks({ tasks, throwOnError: true }) const serviceStatuses = deletedDeployStatuses(results) diff --git a/core/src/util/testing.ts b/core/src/util/testing.ts index 0c15d6a16d..63975482ed 100644 --- a/core/src/util/testing.ts +++ b/core/src/util/testing.ts @@ -31,7 +31,6 @@ import { getRootLogger } from "../logger/logger.js" import stripAnsi from "strip-ansi" import type { VcsHandler } from "../vcs/vcs.js" import type { ConfigGraph } from "../graph/config-graph.js" -import type { SolveParams } from "../graph/solver.js" import type { GraphResults } from "../graph/results.js" import { expect } from "chai" import type { ActionConfig, ActionConfigMap, ActionKind, ActionStatus } from "../actions/types.js" @@ -254,10 +253,6 @@ export class TestGarden extends Garden { } } - override async processTasks(params: Omit & { log?: Log }) { - return super.processTasks({ ...params, log: params.log || this.log }) - } - /** * Override to cache the config graph. */ diff --git a/core/src/vcs/git-sub-tree.ts b/core/src/vcs/git-sub-tree.ts index 4697e8c1bd..9610b43521 100644 --- a/core/src/vcs/git-sub-tree.ts +++ b/core/src/vcs/git-sub-tree.ts @@ -195,7 +195,7 @@ export class GitSubTreeHandler extends AbstractGitHandler { const submodules = await this.getSubmodules(path) const submodulePaths = submodules.map((s) => join(gitRoot, s.path)) if (submodules.length > 0) { - gitLog.silly(`Submodules listed at ${submodules.map((s) => `${s.path} (${s.url})`).join(", ")}`) + gitLog.silly(() => `Submodules listed at ${submodules.map((s) => `${s.path} (${s.url})`).join(", ")}`) } let submoduleFiles: Promise[] = [] diff --git a/core/src/vcs/git.ts b/core/src/vcs/git.ts index 0f6b5cee71..089f922f7d 100644 --- a/core/src/vcs/git.ts +++ b/core/src/vcs/git.ts @@ -59,7 +59,7 @@ function gitCliExecutor({ log, cwd, failOnPrompt = false }: GitCliParams): GitCl * @throws ChildProcessError */ return async (...args: string[]) => { - log.silly(`Calling git with args '${args.join(" ")}' in ${cwd}`) + log.silly(() => `Calling git with args '${args.join(" ")}' in ${cwd}`) const { stdout } = await exec("git", args, { cwd, maxBuffer: 100 * 1024 * 1024, @@ -135,7 +135,7 @@ export class GitCli { output.originUrl = await this.getOriginUrl() } catch (err) { // Just ignore if not available - this.log.silly(`Tried to retrieve git remote.origin.url but encountered an error: ${err}`) + this.log.silly(() => `Tried to retrieve git remote.origin.url but encountered an error: ${err}`) } return output diff --git a/core/test/integ/src/plugins/kubernetes/commands/exec.ts b/core/test/integ/src/plugins/kubernetes/commands/exec.ts index 5642d78ad5..4e84a7dde8 100644 --- a/core/test/integ/src/plugins/kubernetes/commands/exec.ts +++ b/core/test/integ/src/plugins/kubernetes/commands/exec.ts @@ -31,7 +31,7 @@ describe("runExecCommand", () => { force: true, forceBuild: false, }) - await garden.processTasks({ tasks: [deployTask], log: garden.log, throwOnError: true }) + await garden.processTasks({ tasks: [deployTask], throwOnError: true }) }) async function resolveDeployAction(name: string) { diff --git a/core/test/integ/src/plugins/kubernetes/commands/sync.ts b/core/test/integ/src/plugins/kubernetes/commands/sync.ts index 3def7d86f9..0b106d347d 100644 --- a/core/test/integ/src/plugins/kubernetes/commands/sync.ts +++ b/core/test/integ/src/plugins/kubernetes/commands/sync.ts @@ -65,7 +65,7 @@ describe("sync plugin commands", () => { startSync: true, }) - await garden.processTasks({ log, tasks: [deployTask], throwOnError: true }) + await garden.processTasks({ tasks: [deployTask], throwOnError: true }) } describe("sync-status", () => { diff --git a/core/test/integ/src/plugins/kubernetes/container/build/build.ts b/core/test/integ/src/plugins/kubernetes/container/build/build.ts index 4396e8a7d1..8b644d2c5a 100644 --- a/core/test/integ/src/plugins/kubernetes/container/build/build.ts +++ b/core/test/integ/src/plugins/kubernetes/container/build/build.ts @@ -63,7 +63,7 @@ describe.skip("Kubernetes Container Build Extension", () => { async function executeBuild(buildActionName: string) { const action = await garden.resolveAction({ action: graph.getBuild(buildActionName), graph, log }) - const result = await garden.processTask(new BuildTask({ action, force: true, garden, graph, log }), log, { + const result = await garden.processTask(new BuildTask({ action, force: true, garden, graph, log }), { throwOnError: true, }) return result?.result?.executedAction! diff --git a/core/test/integ/src/plugins/kubernetes/container/deployment.ts b/core/test/integ/src/plugins/kubernetes/container/deployment.ts index 1b62d788e5..25f900afd8 100644 --- a/core/test/integ/src/plugins/kubernetes/container/deployment.ts +++ b/core/test/integ/src/plugins/kubernetes/container/deployment.ts @@ -673,7 +673,7 @@ describe("kubernetes container deployment handlers", () => { }) garden.events.eventLog = [] - const results = await garden.processTasks({ tasks: [deployTask], log: garden.log, throwOnError: true }) + const results = await garden.processTasks({ tasks: [deployTask], throwOnError: true }) const statuses = getDeployStatuses(results.results) const status = statuses[action.name] const resources = keyBy(status.detail?.detail["remoteResources"], "kind") @@ -741,7 +741,7 @@ describe("kubernetes container deployment handlers", () => { forceBuild: false, }) - await garden.processTasks({ tasks: [deployTask], log: garden.log, throwOnError: true }) + await garden.processTasks({ tasks: [deployTask], throwOnError: true }) // We expect this `ConfigMap` to still exist. await api.core.readNamespacedConfigMap({ name: mapToNotPruneKey, namespace }) @@ -778,7 +778,7 @@ describe("kubernetes container deployment handlers", () => { forceBuild: false, }) - const results = await garden.processTasks({ tasks: [deployTask], log: garden.log, throwOnError: true }) + const results = await garden.processTasks({ tasks: [deployTask], throwOnError: true }) const statuses = getDeployStatuses(results.results) const status = statuses[action.name] expect(status.state).to.eql("ready") @@ -796,7 +796,7 @@ describe("kubernetes container deployment handlers", () => { forceBuild: false, }) - const results = await garden.processTasks({ tasks: [deployTask], log: garden.log, throwOnError: true }) + const results = await garden.processTasks({ tasks: [deployTask], throwOnError: true }) const statuses = getDeployStatuses(results.results) const status = statuses[action.name] const resources = keyBy(status.detail?.detail["remoteResources"], "kind") @@ -834,7 +834,7 @@ describe("kubernetes container deployment handlers", () => { forceBuild: false, }) - const results = await garden.processTasks({ tasks: [deployTask], log: garden.log, throwOnError: true }) + const results = await garden.processTasks({ tasks: [deployTask], throwOnError: true }) const statuses = getDeployStatuses(results.results) return statuses[resolvedAction.name] @@ -928,7 +928,7 @@ describe("kubernetes container deployment handlers", () => { forceBuild: false, }) - await garden.processTasks({ tasks: [deployTask], log: garden.log, throwOnError: true }) + await garden.processTasks({ tasks: [deployTask], throwOnError: true }) // Important: This is a fresh config graoh with no action modes set, as would be the case e.g. when // calling the `get status` command. This is to test that we're indeed using the action mode written in the diff --git a/core/test/integ/src/plugins/kubernetes/helm/common.ts b/core/test/integ/src/plugins/kubernetes/helm/common.ts index a4260cefc2..d369cc024b 100644 --- a/core/test/integ/src/plugins/kubernetes/helm/common.ts +++ b/core/test/integ/src/plugins/kubernetes/helm/common.ts @@ -34,6 +34,7 @@ import type { HelmDeployAction } from "../../../../../../src/plugins/kubernetes/ import { loadAllYaml, loadYaml } from "@kubernetes/client-node" import fsExtra from "fs-extra" import { getActionNamespace } from "../../../../../../src/plugins/kubernetes/namespace.js" + const { readdir, readFile } = fsExtra let helmTestGarden: TestGarden @@ -78,7 +79,7 @@ export async function buildHelmModules(garden: Garden | TestGarden, graph: Confi force: false, }) ) - const results = await garden.processTasks({ tasks, log: garden.log }) + const results = await garden.processTasks({ tasks }) const err = first(Object.values(results).map((r) => r && r.error)) diff --git a/core/test/integ/src/plugins/kubernetes/local-mode.ts b/core/test/integ/src/plugins/kubernetes/local-mode.ts index d2d6f26b3c..89cb03cc43 100644 --- a/core/test/integ/src/plugins/kubernetes/local-mode.ts +++ b/core/test/integ/src/plugins/kubernetes/local-mode.ts @@ -82,7 +82,7 @@ describe("local mode deployments and ssh tunneling behavior", () => { forceBuild: false, skipRuntimeDependencies: true, }) - await garden.processTask(task, log, {}) + await garden.processTask(task, {}) const actionLog = createActionLog({ log, actionName: action.name, actionKind: action.kind }) const status = await pRetry( diff --git a/core/test/unit/src/commands/publish.ts b/core/test/unit/src/commands/publish.ts index 0a1c0395a4..11a2a08c53 100644 --- a/core/test/unit/src/commands/publish.ts +++ b/core/test/unit/src/commands/publish.ts @@ -249,7 +249,7 @@ describe("PublishTask", () => { }) }) - const processed = await garden.processTasks({ tasks, log, throwOnError: true }) + const processed = await garden.processTasks({ tasks, throwOnError: true }) const graphResultsMap = processed.results.getMap() expect(graphResultsMap["publish.module-a"]!.result.detail.published).to.be.true expect(graphResultsMap["publish.module-a"]!.result.detail.identifier).to.equal("foo") @@ -276,7 +276,7 @@ describe("PublishTask", () => { }) }) - const processed = await garden.processTasks({ tasks, log, throwOnError: true }) + const processed = await garden.processTasks({ tasks, throwOnError: true }) const graphResultsMap = processed.results.getMap() const verA = graph.getBuild("module-a").versionString() const verB = graph.getBuild("module-b").versionString() @@ -305,7 +305,7 @@ describe("PublishTask", () => { }) }) - const processed = await garden.processTasks({ tasks, log, throwOnError: true }) + const processed = await garden.processTasks({ tasks, throwOnError: true }) const graphResultsMap = processed.results.getMap() expect(graphResultsMap["publish.module-a"]!.result.detail.published).to.be.true expect(graphResultsMap["publish.module-a"]!.result.detail.identifier).to.equal(undefined) diff --git a/core/test/unit/src/graph/solver.ts b/core/test/unit/src/graph/solver.ts index 55840cfc67..ae867ad6ac 100644 --- a/core/test/unit/src/graph/solver.ts +++ b/core/test/unit/src/graph/solver.ts @@ -142,7 +142,7 @@ describe("GraphSolver", () => { } async function processTask(task: BaseTask, opts: SolveOpts = {}) { - return garden.processTask(task, garden.log, opts) + return garden.processTask(task, opts) } it("processes a single task without dependencies", async () => { diff --git a/core/test/unit/src/tasks/resolve-action.ts b/core/test/unit/src/tasks/resolve-action.ts index c56ce0ac64..6ef7fdfaaf 100644 --- a/core/test/unit/src/tasks/resolve-action.ts +++ b/core/test/unit/src/tasks/resolve-action.ts @@ -164,7 +164,7 @@ describe("ResolveActionTask", () => { ]) const task = await getTask("Build", "foo") - const result = await garden.processTask(task, log, { throwOnError: true }) + const result = await garden.processTask(task, { throwOnError: true }) const resolved = result?.outputs.resolvedAction @@ -185,7 +185,7 @@ describe("ResolveActionTask", () => { ]) const task = await getTask("Build", "foo") - const result = await garden.processTask(task, log, { throwOnError: true }) + const result = await garden.processTask(task, { throwOnError: true }) const resolved = result!.outputs.resolvedAction const variables = resolved.getVariables() @@ -206,7 +206,7 @@ describe("ResolveActionTask", () => { ]) const task = await getTask("Deploy", "foo", { local: ["deploy.foo"] }) - const result = await garden.processTask(task, log, { throwOnError: true }) + const result = await garden.processTask(task, { throwOnError: true }) const resolved = result!.outputs.resolvedAction const spec = resolved.getSpec() @@ -233,7 +233,7 @@ describe("ResolveActionTask", () => { garden.variableOverrides.b = 2000 // <-- should win const task = await getTask("Build", "foo") - const result = await garden.processTask(task, log, { throwOnError: true }) + const result = await garden.processTask(task, { throwOnError: true }) const resolved = result!.outputs.resolvedAction const variables = resolved.getVariables() @@ -264,7 +264,7 @@ describe("ResolveActionTask", () => { ]) const task = await getTask("Deploy", "foo") - const result = await garden.processTask(task, log, { throwOnError: true }) + const result = await garden.processTask(task, { throwOnError: true }) const all = getAllTaskResults(result?.dependencyResults!) @@ -297,7 +297,7 @@ describe("ResolveActionTask", () => { const task = await getTask("Deploy", "foo") - await expectError(() => garden.processTask(task, log, { throwOnError: true }), { + await expectError(() => garden.processTask(task, { throwOnError: true }), { contains: ["Unrecognized key(s) in object: 'foo'"], }) }) @@ -312,7 +312,7 @@ describe("ResolveActionTask", () => { ]) const task = await getTask("Build", "foo") - const result = await garden.processTask(task, log, { throwOnError: true }) + const result = await garden.processTask(task, { throwOnError: true }) const resolved = result!.outputs.resolvedAction const outputs = resolved.getOutputs() @@ -357,7 +357,7 @@ describe("ResolveActionTask", () => { const task = await getTask("Build", "foo") - await expectError(() => garden.processTask(task, log, { throwOnError: true }), { + await expectError(() => garden.processTask(task, { throwOnError: true }), { contains: ["Error validating static action outputs from Build", 'key "blep" is not allowed'], }) }) @@ -398,7 +398,7 @@ describe("ResolveActionTask", () => { const task = await getTask("Build", "foo") - const result = await garden.processTask(task, log, { throwOnError: true }) + const result = await garden.processTask(task, { throwOnError: true }) const resolved = result!.outputs.resolvedAction expect(resolved.getSpec()).to.eql({ foo: 123 }) @@ -426,7 +426,7 @@ describe("ResolveActionTask", () => { const task = await getTask("Deploy", "foo") - const result = await garden.processTask(task, log, { throwOnError: true }) + const result = await garden.processTask(task, { throwOnError: true }) const resolved = result!.outputs.resolvedAction expect(resolved.getSpec("deployCommand")).to.eql(["echo", "echo foo"]) @@ -454,7 +454,7 @@ describe("ResolveActionTask", () => { const task = await getTask("Deploy", "foo") - const result = await garden.processTask(task, log, { throwOnError: true }) + const result = await garden.processTask(task, { throwOnError: true }) const resolved = result!.outputs.resolvedAction expect(resolved.getSpec("deployCommand")).to.eql(["echo", "echo foo"]) @@ -493,7 +493,7 @@ describe("ResolveActionTask", () => { const task = await getTask("Deploy", "foo") - const result = await garden.processTask(task, log, { throwOnError: true }) + const result = await garden.processTask(task, { throwOnError: true }) const resolved = result!.outputs.resolvedAction expect(resolved.getSpec("deployCommand")).to.eql(["echo", "parent", "template", "bar"]) diff --git a/plugins/conftest-kubernetes/test/conftest-kubernetes.ts b/plugins/conftest-kubernetes/test/conftest-kubernetes.ts index 8a0553a6b5..c51e66e7df 100644 --- a/plugins/conftest-kubernetes/test/conftest-kubernetes.ts +++ b/plugins/conftest-kubernetes/test/conftest-kubernetes.ts @@ -83,7 +83,7 @@ describe.skip("conftest-kubernetes provider", () => { }) const key = testTask.getKey() - const res = await garden.processTasks({ log: garden.log, tasks: [testTask], throwOnError: true }) + const res = await garden.processTasks({ tasks: [testTask], throwOnError: true }) const result = res.results[key] expect(result).to.exist diff --git a/plugins/conftest/test/conftest.ts b/plugins/conftest/test/conftest.ts index 6eb8a76df3..a2abd3f8b0 100644 --- a/plugins/conftest/test/conftest.ts +++ b/plugins/conftest/test/conftest.ts @@ -61,7 +61,7 @@ describe("conftest provider", () => { }) const key = testTask.getKey() - const res = await garden.processTasks({ log: garden.log, tasks: [testTask], throwOnError: true }) + const res = await garden.processTasks({ tasks: [testTask], throwOnError: true }) const result = res.results[key] expect(result).to.exist @@ -96,7 +96,7 @@ describe("conftest provider", () => { }) const key = testTask.getKey() - const res = await garden.processTasks({ log: garden.log, tasks: [testTask], throwOnError: true }) + const res = await garden.processTasks({ tasks: [testTask], throwOnError: true }) const result = res.results[key] expect(result).to.exist @@ -122,7 +122,7 @@ describe("conftest provider", () => { }) const key = testTask.getKey() - const res = await garden.processTasks({ log: garden.log, tasks: [testTask], throwOnError: true }) + const res = await garden.processTasks({ tasks: [testTask], throwOnError: true }) const result = res.results[key] expect(result).to.exist @@ -151,7 +151,7 @@ describe("conftest provider", () => { }) const key = testTask.getKey() - const res = await garden.processTasks({ log: garden.log, tasks: [testTask], throwOnError: true }) + const res = await garden.processTasks({ tasks: [testTask], throwOnError: true }) const result = res.results[key] expect(result).to.exist diff --git a/plugins/pulumi/src/commands.ts b/plugins/pulumi/src/commands.ts index 6f30a67caf..b8deea4ce2 100644 --- a/plugins/pulumi/src/commands.ts +++ b/plugins/pulumi/src/commands.ts @@ -33,6 +33,7 @@ import { import { dedent, deline } from "@garden-io/sdk/build/src/util/string.js" import { BooleanParameter, parsePluginCommandArgs } from "@garden-io/sdk/build/src/util/cli.js" import fsExtra from "fs-extra" + const { copy, emptyDir, writeJSON } = fsExtra import { join } from "path" import { isBuildAction } from "@garden-io/core/build/src/actions/build.js" @@ -430,7 +431,7 @@ function makePulumiCommand({ name, commandDescription, beforeFn, runFn, afterFn }) ) - const results = (await garden.processTasks({ log, tasks, throwOnError: true })).results + const results = (await garden.processTasks({ tasks, throwOnError: true })).results let commandResult: any = {} if (afterFn) { diff --git a/plugins/terraform/test/terraform.ts b/plugins/terraform/test/terraform.ts index 893afaca9d..24a264ebc2 100644 --- a/plugins/terraform/test/terraform.ts +++ b/plugins/terraform/test/terraform.ts @@ -359,7 +359,7 @@ for (const terraformVersion of ["0.13.3", defaultTerraformVersion]) { async function deployStack(autoApply: boolean) { await garden.scanAndAddConfigs() - garden["actionConfigs"]["Deploy"]["tf"].spec.autoApply = autoApply + garden.actionConfigs["Deploy"]["tf"].spec.autoApply = autoApply graph = await garden.getConfigGraph({ log: garden.log, emit: false }) @@ -384,8 +384,8 @@ for (const terraformVersion of ["0.13.3", defaultTerraformVersion]) { async function runTestTask(autoApply: boolean, allowDestroy = false) { await garden.scanAndAddConfigs() - garden["actionConfigs"]["Deploy"]["tf"].spec.allowDestroy = allowDestroy - garden["actionConfigs"]["Deploy"]["tf"].spec.autoApply = autoApply + garden.actionConfigs["Deploy"]["tf"].spec.allowDestroy = allowDestroy + garden.actionConfigs["Deploy"]["tf"].spec.autoApply = autoApply graph = await garden.getConfigGraph({ log: garden.log, emit: false }) @@ -677,7 +677,7 @@ for (const terraformVersion of ["0.13.3", defaultTerraformVersion]) { }) await _garden.scanAndAddConfigs() - _garden["actionConfigs"]["Deploy"]["tf"].spec.autoApply = true + _garden.actionConfigs["Deploy"]["tf"].spec.autoApply = true const _graph = await _garden.getConfigGraph({ log: _garden.log, emit: false })