rhel - Podman pod 几天后消失,但进程仍在运行并在给定端口上侦听
问题描述
我正在运行一个 Elasticsearch 容器作为 Podman pod 使用podman play kube
和一个yaml
pod 的定义。Pod 已创建,三个节点的集群已创建,一切都按预期工作。但是:Podman pod 在闲置几天后死亡。
Podmanpodman ps
命令说:
ERRO[0000] Error refreshing container af05fafe31f6bfb00c2599255c47e35813ecf5af9bbe6760ae8a4abffd343627: error acquiring lock 1 for container af05fafe31f6bfb00c2599255c47e35813ecf5af9bbe6760ae8a4abffd343627: file exists
ERRO[0000] Error refreshing container b4620633d99f156bb59eb327a918220d67145f8198d1c42b90d81e6cc29cbd6b: error acquiring lock 2 for container b4620633d99f156bb59eb327a918220d67145f8198d1c42b90d81e6cc29cbd6b: file exists
ERRO[0000] Error refreshing pod 389b0c34313d9b23ecea3faa0e494e28413bd15566d66297efa9b5065e025262: error retrieving lock 0 for pod 389b0c34313d9b23ecea3faa0e494e28413bd15566d66297efa9b5065e025262: file exists
POD ID NAME STATUS CREATED INFRA ID # OF CONTAINERS
389b0c34313d elasticsearch-pod Created 1 week ago af05fafe31f6 2
奇怪的是,如果我们试图找到在端口 9200 或 9300 上侦听的进程 id,该进程仍在侦听:
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp6 0 0 :::9200 :::* LISTEN 1328607/containers-
tcp6 0 0 :::9300 :::* LISTEN 1328607/containers-
挂起的进程 ID(并使进程仍在侦听):
user+ 1339220 0.0 0.1 45452 8284 ? S Jan11 2:19 /bin/slirp4netns --disable-host-loopback --mtu 65520 --enable-sandbox --enable-seccomp -c -e 3 -r 4 --netns-type=path /tmp/run-1002/netns/cni-e4bb2146-d04e-c3f1-9207-380a234efa1f tap0
我对 pod 执行的唯一操作是常规:,podman pod stop
即启动 pod。podman pod rm
podman play kube
是什么导致 Podman 出现这种奇怪的行为?什么可能导致锁无法正确释放?
系统信息:
NAME="Red Hat Enterprise Linux"
VERSION="8.3 (Ootpa)"
ID="rhel"
ID_LIKE="fedora"
VERSION_ID="8.3"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Red Hat Enterprise Linux 8.3 (Ootpa)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:redhat:enterprise_linux:8.3:GA"
HOME_URL="https://www.redhat.com/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 8"
REDHAT_BUGZILLA_PRODUCT_VERSION=8.3
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="8.3"
Red Hat Enterprise Linux release 8.3 (Ootpa)
Red Hat Enterprise Linux release 8.3 (Ootpa)
Podman
版本:
podman --version
podman version 2.2.1
解决方案
对我有用的解决方法是在/usr/lib/tmpfiles.d/和/etc/tmpfiles.d/下从 Podman 存储库 [1] 添加此配置文件,这样我们就可以防止删除 Podman 临时文件从 /tmp 目录 [2]。如 [3] 中所述,当系统崩溃或容器未正确关闭时,CNI 还会将网络信息留在/var/lib/cni/networks中。此行为已在最新的 Podman 版本 [4] 中得到修复,并且在使用无根 Podman 时会发生。
解决方法
首先,检查为您的 Podman 无根用户设置的 runRoot 默认目录:
podman info | grep runRoot
创建临时配置文件:
sudo vim /usr/lib/tmpfiles.d/podman.conf
添加以下内容,将 /tmp/podman-run-* 替换为默认的 runRoot 目录。例如,如果您的输出是 /tmp/run-6695/containers 然后使用:x /tmp/run-*
# /tmp/podman-run-* directory can contain content for Podman containers that have run
# for many days. This following line prevents systemd from removing this content.
x /tmp/podman-run-*
x /tmp/containers-user-*
D! /run/podman 0700 root root
D! /var/lib/cni/networks
将临时文件从 /usr/lib/tmpfiles.d 复制到 /etc/tmpfiles.d/
sudo cp -p /usr/lib/tmpfiles.d/podman.conf /etc/tmpfiles.d/
根据您的配置完成所有步骤后,错误应该会消失。
参考
推荐阅读
- php - 如何在 php 中创建动态字符串,如示例?
- postgresql - KeystoneJS 5 中 Knex 适配器的 Postgresql 错误:'错误:无法读取未定义的属性'find''
- mysql - 错误代码1111:组函数sql的使用无效
- python - 使用正则表达式从使用 Python 的日志文件中提取文件名
- c++ - 编译时收到警告
- scala - 访问无法访问类型信息的类时出现错误
- node.js - Twilio Call,为 xml 使用自定义端点
- swift - Swift:解码从 GameKit 发送的消息
- office365 - 用于 Office 365 的本地解决方案的 Office 插件部署
- iis-10 - 禁用 IIS10 的“Vary”标头