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 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 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,23 @@ 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}. Is this release managed outside of garden?`)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we log this when the values are null?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, right :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed this in 8605647.

deployedVersion = values[".garden"]?.version
deployedMode = values[".garden"]?.mode
}

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