英文:
Does Helm also remove the created namespace if `helm install` fails and --atomic option has been used
问题
Helm 在使用 helm install
安装 release 时,如果使用了 --atomic
选项并且安装失败,是否也会移除已创建的命名空间?我在 Helm 帮助页面上找不到这方面的信息。
英文:
Does Helm also remove the created namespace if helm install
fails and --atomic
option has been used to install the release?
I am unable to find this information on Helm help pages.
答案1
得分: 1
命名空间未被删除。
在 Helm 源代码中,"helm.sh/helm/v3/pkg/action"
中包含了实际运行helm install
的主要逻辑。更具体地说,--atomic
的处理在(*Install).failRelease()
中,大致如下:
rel.SetStatus(release.StatusFailed, fmt.Sprintf("Release %q failed: %s", i.ReleaseName, err.Error()))
if i.Atomic {
uninstall := NewUninstall(i.cfg)
... uninstall.Run(i.ReleaseName) ...
}
i.recordRelease(rel)
这里非常重要的是最后一行。这调用了("helm.sh/helm/v3/pkg/storage".Storage).Update()
,记录了失败的发布事实,helm history
可以找到它。在正常的 Helm 配置中,这是在目标命名空间的一个 Secret 中。由于历史记录存储在命名空间的一个 Secret 中,因此无法删除该命名空间。
可以轻松搜索源代码以查找Atomic
设置,至少在install.go
中,它只执行两个操作,即隐式启用--wait
并在安装失败时运行helm uninstall
。但是,这两个操作都不会删除命名空间。
英文:
The namespace is not deleted.
In the Helm source, "helm.sh/helm/v3/pkg/action".Install
has the main logic that helm install
actually runs. The --atomic
handling more specifically is in (*Install).failRelease()
, which is approximately
rel.SetStatus(release.StatusFailed, fmt.Sprintf("Release %q failed: %s", i.ReleaseName, err.Error()))
if i.Atomic {
uninstall := NewUninstall(i.cfg)
... uninstall.Run(i.ReleaseName) ...
}
i.recordRelease(rel)
The very last line is important here. This calls through to (*"helm.sh/helm/v3/pkg/storage".Storage).Update()
, which records the fact of the failed release where helm history
can find it. With the normal Helm configuration, this is in a Secret in the target namespace. Since the history is recorded in a Secret in the namespace, the namespace can't be deleted.
It's easy to search the source for the Atomic
setting, and at least in install.go
the only two things it does are to implicitly enable --wait
and to run helm uninstall
if the install fails. But neither of those things delete the namespace.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论