helm error: release requires a rollback before it can be upgraded

helm error: release requires a rollback before it can be upgraded

在我的集群中,我使用 weave flux 及其 flux-helm-operator 以 gitops 方式管理我的集群。

但是,当我在 flux git 存储库中更改图表时,我经常遇到以下错误消息:

ts=2019-09-25T11:54:37.604506452Z caller=chartsync.go:328 component=chartsync
warning="unable to proceed with release" 
resource=mychart:helmrelease/mychart release=mychart
err="release requires a rollback before it can be upgraded (FAILED)"

我不确定这在 helm 中是什么意思,但无论如何,我不应该 运行 任何 helm 命令,因为发布是由 flux 管理的,所以我想知道处理的正确方法是什么这个生产错误

(除了删除版本并等待 flux 重新创建它)

一个解释清楚的答案将被接受,谢谢。

让我们深入研究 helm-operator

的代码

警告 unable to proceed with releaseGetUpgradableRelease

之后出现
    // GetUpgradableRelease returns a release if the current state of it
    // allows an upgrade, a descriptive error if it is not allowed, or
    // nil if the release does not exist.

它 returns 错误 release requires a rollback before it can be upgraded 如果版本具有 Status_FAILED 状态(参见 release.go#89

UNHEALTHY 状态块释放

作为 flux 开发者 mentioned in #2265,无法滚动到 UNHEALTHY 状态。

This is not a bug but I can see where your expectation is coming from.

Flux will only move healthy releases forward, one of the reasons for this is to ensure we do not end up in a loop of failure, the --force flag is thus not intended to be used to force the upgrade of an unhealthy resource (you should use the rollback feature for this) but was developed to make it possible to upgrade charts with e.g. backwards incompatible changes (changes on immutable fields for example, which require a resource to be removed first, see #1760).

Conclusion: the forceUpgrade is honoured, but can not be used to force the upgrade of a release in an UNHEALTHY state.

Rollback

按照作者的建议,您应该使用 rollback 功能

From time to time a release made by the Helm operator may fail, it is possible to automate the rollback of a failed release by setting .spec.rollback.enable to true on the HelmRelease resource.

Note: a successful rollback of a Helm chart containing a StatefulSet resource is known to be tricky, and one of the main reasons automated rollbacks are not enabled by default for all HelmReleases. Verify a manual rollback of your Helm chart does not cause any problems before enabling it.

When enabled, the Helm operator will detect a faulty upgrade and perform a rollback, it will not attempt a new upgrade unless it detects a change in values and/or the chart.

apiVersion: flux.weave.works/v1beta1
kind: HelmRelease
# metadata: ...
spec:
  # Listed values are the defaults.
  rollback:
    # If set, will perform rollbacks for this release.
    enable: false
    # If set, will force resource update through delete/recreate if
    # needed.
    force: false
    # Prevent hooks from running during rollback.
    disableHooks: false
    # Time in seconds to wait for any individual Kubernetes operation.
    timeout: 300
    # If set, will wait until all Pods, PVCs, Services, and minimum
    # number of Pods of a Deployment are in a ready state before
    # marking the release as successful. It will wait for as long
    # as the set timeout.
    wait: false