Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

pkg/helm: add wrapper to get the Helm history we expect #1515

Merged
merged 1 commit into from
Jun 30, 2021

Conversation

iaguis
Copy link
Contributor

@iaguis iaguis commented Jun 28, 2021

We expect to get the history in descending order by version and limited
to 1 version to get the last version so we can ensure the user has the
last version of the Helm chart.

However, it turns out the Helm API doesn't honor the Max config parameter and
returns the Helm history in a non-deterministic order.

This adds a wrapper function that sorts what the Helm API returns in the
way we expect and uses that.

Fixes #1442

@iaguis iaguis requested review from surajssd and invidian June 28, 2021 14:37
@iaguis iaguis force-pushed the iaguis/fix-pre-release-checks branch 2 times, most recently from fcbdaee to 54860bf Compare June 28, 2021 14:57
Copy link
Member

@invidian invidian left a comment

Choose a reason for hiding this comment

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

Hmm, content of the PR does not match the title.

@iaguis
Copy link
Contributor Author

iaguis commented Jun 28, 2021

Sorry, pushed to the wrong branch 😅

Copy link
Member

@invidian invidian left a comment

Choose a reason for hiding this comment

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

Just some nits, otherwise looks OK

cli/cmd/cluster/cluster.go Show resolved Hide resolved
pkg/helm/history.go Outdated Show resolved Hide resolved
pkg/helm/history.go Outdated Show resolved Hide resolved
pkg/helm/history_internal_test.go Outdated Show resolved Hide resolved
@iaguis iaguis force-pushed the iaguis/fix-pre-release-checks branch from 54860bf to d0209a0 Compare June 28, 2021 16:11
@iaguis iaguis requested a review from invidian June 28, 2021 16:11
Copy link
Member

@invidian invidian left a comment

Choose a reason for hiding this comment

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

One nit, otherwise looks good 👍 Nice and clear addition, and well tested 👌

pkg/helm/history.go Outdated Show resolved Hide resolved
We expect to get the history in descending order by version and limited
to 1 version to get the last version so we can ensure the user has the
last version of the Helm chart.

However, it turns out the Helm API doesn't honor the Max config parameter and
returns the Helm history in a non-deterministic order.

This adds a wrapper function that sorts what the Helm API returns in the
way we expect and uses that.

Fixes #1442
@iaguis iaguis force-pushed the iaguis/fix-pre-release-checks branch from d0209a0 to bea4a93 Compare June 29, 2021 08:45
@iaguis iaguis requested a review from invidian June 29, 2021 08:45
Copy link
Member

@invidian invidian left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Copy link
Member

@surajssd surajssd left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -309,9 +310,9 @@ func (c controlplaneUpdater) ensureComponent(component, namespace string) error
}

histClient := action.NewHistory(actionConfig)
histClient.Max = 1
histMax := 1
Copy link
Member

Choose a reason for hiding this comment

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

What if the last one in the history was not a successful deploy? Do we want the last one in the history or the last successful deploy in the history?

Copy link
Member

Choose a reason for hiding this comment

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

Good point 😐

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could check for the last "deployed" instance.

Copy link
Member

Choose a reason for hiding this comment

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

I'd say it's out of scope for this PR? Maybe create an issue and create a follow-up PR? This PR fixes existing assumed functionality, while suggestion from @surajssd changes the behavior from existing one, although I agree what we do right now is not fully correct.

Copy link
Member

Choose a reason for hiding this comment

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

Alright sure, lets move forward. But yeah we will need a func that give the last successful deploy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@iaguis iaguis merged commit c37d991 into master Jun 30, 2021
@invidian invidian deleted the iaguis/fix-pre-release-checks branch June 30, 2021 09:59
@invidian invidian added the bug Something isn't working label Jul 16, 2021
@invidian invidian added this to the v0.9.0 milestone Jul 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lokoctl's pre-update checks rolls back to older Kubernetes version unnecessarily
3 participants