feat: explain required install with no planned resource changes#645
feat: explain required install with no planned resource changes#645Sharvash wants to merge 4 commits into
Conversation
The `release plan install` command now explains why a release must still be installed even when no Kubernetes resource changes are planned. Previously, the plan command only printed a yellow warning saying it must still install the release, without explaining why. Users had no way to know whether the cause was a failed previous release, changed values, updated manifests, or something else. The `IsReleaseUpToDate` function now returns a typed `ReleaseOutdatedReason` alongside the existing boolean result. The reasons surfaced are: - there is no previously deployed release - the previously deployed release was not successful - the release notes changed - the release values changed - the release hooks changed - the release manifests changed The single function that already decides whether a release is up to date now also returns the reason, so there is no duplicated logic. Only the `release plan install` command surfaces the reason; the "skipped, already as desired" messages of the install and rollback commands are unchanged. Table-driven unit tests cover every branch of `IsReleaseUpToDate` and the message-builder guard (no dangling " because" when the reason is empty). Build, lint, and test pipeline is green. Closes werf#512 Signed-off-by: Alexey Gorovenko <sharvashinho@gmail.com>
4566520 to
f0c844c
Compare
| // Check if the new Release is up-to-date compared to the old Release. It doesn't check any | ||
| // resources of the release in the cluster, just compares Release objects. | ||
| func IsReleaseUpToDate(oldRel, newRel *helmrelease.Release) (bool, error) { | ||
| func IsReleaseUpToDate(oldRel, newRel *helmrelease.Release) (bool, ReleaseOutdatedReason, error) { |
There was a problem hiding this comment.
I like the idea generally, but I wonder if we can make it cleaner. Later I'd like to be able to also show (at least in some cases) diffs on what changed, e.g. which values changed exactly or in what way manifests changed.
Maybe we shouldn't return isUpToDate + reason, but should return IsReleaseUpToDateResult instead? It can encapsulate both, can also contain additional info for displaying stuff later.
There was a problem hiding this comment.
Done, IsReleaseUpToDate now returns an IsReleaseUpToDateResult that carries UpToDate and Reason, instead of the separate bool and reason. That gives us a place to add the diff details later (which values changed, how the manifests differ) without touching the signature again.
IsReleaseUpToDate now returns (IsReleaseUpToDateResult, error) instead of (bool, ReleaseOutdatedReason, error). The struct carries the UpToDate flag and the Reason a release is outdated, replacing the positional (bool, reason) pair that every caller had to destructure by hand. All callers in pkg/action are updated accordingly. Behavior is unchanged: the same checks yield the same verdict and reason as before. Signed-off-by: Alexey Gorovenko <sharvashinho@gmail.com>
32b4716 to
feba3bd
Compare
nelm's
release plan installcommand now explains why a release must still be installed even when no Kubernetes resource changes are planned.Previously, when the plan found no resource changes but the release still had to be installed, it printed only a generic yellow warning:
There was no way to tell what triggered the install — a failed previous release, changed values, updated manifests, or something else.
IsReleaseUpToDateis the single place that decides whether a release is up to date. It now returns a typedReleaseOutdatedReasonnext to its boolean result instead of just(bool, error), and the check is split into separate guard clauses that each return their specific reason:release plan installappends the reason to the existing warning through a smallreleaseMustInstallMessagehelper, so it now reads:The helper leaves the message untouched when the reason is empty, so there is never a dangling " because". The
release installandrelease rollbackcommands ignore the reason and keep their current "already as desired" messages unchanged.Table-driven unit tests cover every branch of
IsReleaseUpToDateand the message-builder guard. Build, lint and unit tests are green.Closes #512