![SaltStack:如果 dpkg 失败,则没有可用的错误消息](https://linux22.com/image/741907/SaltStack%EF%BC%9A%E5%A6%82%E6%9E%9C%20dpkg%20%E5%A4%B1%E8%B4%A5%EF%BC%8C%E5%88%99%E6%B2%A1%E6%9C%89%E5%8F%AF%E7%94%A8%E7%9A%84%E9%94%99%E8%AF%AF%E6%B6%88%E6%81%AF.png)
我收到此消息来自salt-ssh
ID: apache
Function: pkg.installed
Result: False
Comment: Problem encountered installing package(s). Additional info follows:
errors:
- Running scope as unit: run-r62a347a4ff4d4aa398bd0b516ba4fb59.scope
E: Sub-process /usr/bin/dpkg returned an error code (1)
Started: 15:47:16.154590
Duration: 9726.732 ms
Changes:
如何看清问题的根源?
我已经使用过--log-level=all
,但仍然看不到有意义的错误消息。
我不认为dpkg
错误代码会默默存在而不在 stdout/stderr 上打印一些消息。
我猜测 salt-stack 会将重要的错误消息丢弃在某处。
答案1
我拼凑了这个包装器:
https://github.com/guettli/wrap_and_log_calls
现在我salt-ssh
再次运行并搜索非零的“ret:”行。
我发现:
Parent: python2.7 /var/tmp/.root_dcdf8c_salt/salt-call --retcode-passthrough --local --metadata --out json -l quiet -c /var/tmp/.root_dcdf8c_salt -- state.pkg /var/tmp/.root_dcdf8c_salt/salt
_state.tgz test=None pkg_sum=7683cfdcaf0ef6b6c907889fab738da83b6f897fe02387251db02a25f541e4ca hash_type=sha256
Parent: /usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold -o DPkg::Options::=--force-confdef install openssl-foo-bar-user.cert
Parent: python /usr/bin/dpkg --force-confold --force-confdef --status-fd 70 --no-triggers --unpack --auto-deconfigure /var/cache/apt/archives/openssl-foo-bar-user.cert_1-2_all.deb
stdout:
(Reading database ... 365773 files and directories currently installed.)
Preparing to unpack .../openssl-foo-bar-user.cert_1-2_all.deb ...
Unpacking openssl-foo-bar-user.cert (1-2) ...
stderr:
dpkg: error processing archive /var/cache/apt/archives/openssl-foo-bar-user.cert_1-2_all.deb (--unpack):
trying to overwrite '/etc/ssl/server/foo-bar_user.pem', which is also in package server-certificates-user 2-2.1
dpkg-deb (subprocess): decompressing archive member: lzma write error: Broken pipe
dpkg-deb: error: <decompress> subprocess returned error exit status 2
Errors were encountered while processing:
/var/cache/apt/archives/openssl-foo-bar-user.cert_1-2_all.deb
现在我知道问题出在自定义(非公共)dpkgopenssl-foo-bar-user.cert
如果 salt-stack 下次能立即告诉我真正的原因,那就太好了。这并不难,只要不隐藏 stdout/stderr 就行了 :-)