在我的集群中,我使用编织通量和他们的通量舵手运算符来管理我的集群。
但是,当我在 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
的代码
GetUpgradableRelease
后出现警告unable to proceed with release
// 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.
如果版本具有Status_FAILED
状态,它会返回错误release requires a rollback before it can be upgraded
(请参阅 release.go#89 (
UNHEALTHY
状态阻止发布
正如flux
开发人员在 #2265 中提到的,没有办法滚动到UNHEALTHY
状态。
这不是一个错误,但我可以看到你的期望来自哪里。
Flux 只会向前移动健康的版本,其中一个原因是为了确保我们不会陷入失败的循环,因此
--force
标志不用于强制升级不健康的资源(您应该为此使用回滚功能(,而是开发用于升级图表,例如向后不兼容的更改(例如,对不可变字段的更改, 需要先删除资源,请参阅#1760(。结论:
forceUpgrade
是受尊重的,但不能用于强制升级处于UNHEALTHY
状态的版本。
反转
正如作者建议的那样,您应该使用rollback
功能
有时,Helm 操作员发布的版本可能会失败,可以通过在 HelmRelease 资源上将
.spec.rollback.enable
设置为 true 来自动回滚失败的版本。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.
启用后,Helm 运算符将检测到错误的升级并执行回滚,除非检测到值和/或图表的变化,否则它不会尝试新的升级。
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