snap 发出的“警告:无法创建用户数据目录:无法确定 SELinux 状态:无法获取 SELinux 挂载路径”警告

snap 发出的“警告:无法创建用户数据目录:无法确定 SELinux 状态:无法获取 SELinux 挂载路径”警告

我在 WSL2 上运行 Ubuntu 20.04,每次运行时helm都会收到以下警告:

cmd_run.go:1046:警告:无法创建用户数据目录:无法确定 SELinux 状态:无法获取 SELinux 挂载路径:尾部字段数量不正确,预期为 3,但实际为 4

搜索此错误没有得到任何有意义的结果。我该如何消除此警告?

Ubuntu 版本:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.6 LTS
Release:        20.04
Codename:       focal

Helm 版本(已删除警告):

$ helm version
version.BuildInfo{Version:"v3.10.1", GitCommit:"9f88ccb6aee40b9a0535fcc7efea6055e1ef72c9", GitTreeState:"clean", GoVersion:"go1.18.7"}

我也将此问题报告给 Helm,而一位合作者认为这与 snap 有关,而不一定与 helm 有关。

因此我使用 运行了 helm SNAP_CONFINE_DEBUG=yes,这是我得到的输出:

$ SNAP_CONFINE_DEBUG=yes helm ls
2023/04/14 02:34:53.395489 system_key.go:129: cannot determine nfs usage in generateSystemKey: cannot parse mountinfo: incorrect number of tail fields, expected 3 but found 4
2023/04/14 02:34:53.399251 cmd_run.go:1046: WARNING: cannot create user data directory: cannot determine SELinux status: failed to obtain SELinux mount path: incorrect number of tail fields, expected 3 but found 4
DEBUG: -- snap startup {"stage":"snap-confine enter", "time":"1681419893.460473"}
DEBUG: umask reset, old umask was  022
DEBUG: security tag: snap.helm.helm
DEBUG: executable:   /snap/snapd/18596/usr/lib/snapd/snap-exec
DEBUG: confinement:  classic
DEBUG: base snap:    core18
DEBUG: ruid: 1000, euid: 0, suid: 0
DEBUG: rgid: 1000, egid: 1000, sgid: 1000
DEBUG: apparmor extensions to the system are not available
DEBUG: -- snap startup {"stage":"snap-confine mount namespace start", "time":"1681419893.461157"}
DEBUG: preparing classic execution environment
DEBUG: -- snap startup {"stage":"snap-confine mount namespace finish", "time":"1681419893.461195"}
DEBUG: set_effective_identity uid:1000 (change: yes), gid:1000 (change: yes)
DEBUG: creating user data directory: /home/samslk/snap/helm/372
DEBUG: ruid: 1000, euid: 1000, suid: 0
DEBUG: setting capabilities bounding set
DEBUG: regaining SYS_ADMIN
DEBUG: loading bpf program for security tag snap.helm.helm
DEBUG: read 14 bytes from /var/lib/snapd/seccomp/bpf//snap.helm.helm.bin
DEBUG: clearing SYS_ADMIN
DEBUG: execv(/snap/snapd/18596/usr/lib/snapd/snap-exec, /snap/snapd/18596/usr/lib/snapd/snap-exec...)
DEBUG:  argv[1] = helm
DEBUG:  argv[2] = ls
DEBUG: umask restored to  022
DEBUG: working directory restored to /home/samslk/experiments/misc/helm-tutorial
DEBUG: -- snap startup {"stage":"snap-confine to snap-exec", "time":"1681419893.461324"}

...normal helm output from this point onwards

因此,看起来警告确实来自 snap,因为 helm 可执行文件直到稍后才由 snap 启动。

我该如何修复/抑制这个问题?

答案1

最后我不得不从 snap 中移除 helm。

sudo snap remove helm

并安装它按照 Helm 文档中的说明使用脚本

# This command may change for the helm version.
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash

效果非常好。遗憾的是,我找不到 snap 的问题所在。

PS此外,重定向错误输出(例如helm .... 2>/dev/null:)不是一个选项,因为它也会抑制来自helm本身的有价值的错误消息。

相关内容