Skip to content

Commit

Permalink
fix: add better error logging for kubectl and rsync
Browse files Browse the repository at this point in the history
  • Loading branch information
edvald committed Apr 22, 2018
1 parent 141abe9 commit 212304a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/plugins/kubernetes/kubectl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class Kubectl {
let _timeout

const _reject = (msg: string) => {
const details = extend({ args, preparedArgs, msg }, <any>out)
const details = extend({ args, preparedArgs, msg, data: data.toString() }, <any>out)
const err = new RuntimeError(`Failed running 'kubectl ${args.join(" ")}'`, details)
reject(err)
}
Expand Down
15 changes: 13 additions & 2 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ import { spawn as _spawn } from "child_process"
import { existsSync, readFileSync, writeFileSync } from "fs"
import { join } from "path"
import { getLogger } from "./logger"
import { TimeoutError } from "./exceptions"
import {
TimeoutError,
GardenError,
} from "./exceptions"
import { PassThrough } from "stream"
import { isArray, isPlainObject, extend, mapValues, pickBy } from "lodash"
import highlight from "cli-highlight"
Expand All @@ -42,6 +45,10 @@ export function shutdown(code) {
}
}

export class RsyncError extends GardenError {
type = "rsync"
}

export type RsyncStdIOCallback = () => void

export type RsyncErrorCallback = (error: Error, code: string, cmd: string) => void
Expand All @@ -63,7 +70,11 @@ export function execRsyncCmd(rsyncCmd: RsyncCommand, stdoutHandler?: RsyncStdIOC
if (!error) {
resolve()
} else {
reject({ error, code, cmd })
reject(new RsyncError(`Unable to sync files`, {
error,
code,
cmd,
}))
}
}, stdoutHandler, stderrHandler)
})
Expand Down

0 comments on commit 212304a

Please sign in to comment.