post_crash() iterates auth_names trying each identity until one
succeeds. Previously it logged a WARNING for every failed attempt,
even when the next name succeeds. This is noisy in deployments
where only a subset of the auth names have keyrings (e.g. manual
deployments with only client.crash, or environments where
client.admin is not accessible to ceph-crash).
Improve the logging:
- For auth failures (EACCES), log at DEBUG level and continue to
the next name.
- For non-auth failures, log a WARNING and stop immediately —
trying other names won't help.
- If all names fail authentication, log a single WARNING with the
last stderr.
Retain the stderr check from
a77b47eeeb57 as a safeguard for mgr
commands that may return rc=0 with an error on stderr.
Signed-off-by: Kefu Chai <k.chai@proxmox.com>
# vim: ts=4 sw=4 expandtab
import argparse
+import errno
import grp
import logging
import os
stderr = stderr.decode()
rc = pr.wait()
f.close()
- if rc != 0 or stderr != "":
+ if rc == 0 and stderr == "":
+ break
+ if rc == errno.EACCES:
+ log.debug('post %s as %s failed: %s' % (path, n, stderr))
+ else:
log.warning('post %s as %s failed: %s' % (path, n, stderr))
- if rc == 0:
break
+ else:
+ log.warning('post %s failed: unable to authenticate as %s: %s'
+ % (path, ', '.join(auth_names), stderr))
return rc