Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(helm): handle missing (null) values in version check #5307

Merged
merged 4 commits into from
Oct 27, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 19 additions & 13 deletions core/src/plugins/kubernetes/helm/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,19 +205,25 @@ export async function getReleaseStatus({

if (state === "ready") {
// Make sure the right version is deployed
values = JSON.parse(
await helm({
ctx,
log,
namespace,
args: ["get", "values", releaseName, "--output", "json"],
// do not send JSON output to Garden Cloud or CLI verbose log
emitLogEvents: false,
})
)

const deployedVersion = values[".garden"]?.version
deployedMode = values[".garden"]?.mode
const helmResponse = await helm({
ctx,
log,
namespace,
args: ["get", "values", releaseName, "--output", "json"],
// do not send JSON output to Garden Cloud or CLI verbose log
emitLogEvents: false,
})
values = JSON.parse(helmResponse)

let deployedVersion: string | undefined = undefined
// JSON.parse can return null
if (values !== null) {
vvagaytsev marked this conversation as resolved.
Show resolved Hide resolved
log.verbose(
`No helm values returned for release ${releaseName}. It looks like the relevant deployments were removed manually.`
vvagaytsev marked this conversation as resolved.
Show resolved Hide resolved
)
deployedVersion = values[".garden"]?.version
deployedMode = values[".garden"]?.mode
}

if (action.mode() !== deployedMode || !deployedVersion || deployedVersion !== action.versionString()) {
state = "outdated"
Expand Down