From: Ilya Dryomov Date: Sun, 19 Sep 2021 10:28:37 +0000 (+0200) Subject: auth,mon: don't log "unable to find a keyring" error when key is given X-Git-Tag: v15.2.15~6^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a88b10154585c799932897df3baf90d2856e87d8;p=ceph.git auth,mon: don't log "unable to find a keyring" error when key is given This error is logged even if --key or --keyring are specified and confuses users because the command actually does its job and exits with success. This primarily affects "rbd mirror pool peer bootstrap import" command and rbd-mirror and cephfs-mirror daemons which connect to the remote cluster with just mon_host and key: $ rbd mirror pool peer bootstrap import mypool tokenfile ... -1 auth: unable to find a keyring on /etc/ceph/..keyring,/etc/ceph/.keyring,/etc/ceph/keyring,/etc/ceph/keyring.bin,: (2) No such file or directory ... -1 auth: unable to find a keyring on /etc/ceph/..keyring,/etc/ceph/.keyring,/etc/ceph/keyring,/etc/ceph/keyring.bin,: (2) No such file or directory ... -1 auth: unable to find a keyring on /etc/ceph/..keyring,/etc/ceph/.keyring,/etc/ceph/keyring,/etc/ceph/keyring.bin,: (2) No such file or directory Local cluster commands are affected too: $ rados --no-config-file --mon-host $MON_HOST --key $KEY lspools ... -1 auth: unable to find a keyring on /etc/ceph/ceph.client.admin.keyring,/etc/ceph/ceph.keyring,/etc/ceph/keyring,/etc/ceph/keyring.bin: (2) No such file or directory ... -1 auth: unable to find a keyring on /etc/ceph/ceph.client.admin.keyring,/etc/ceph/ceph.keyring,/etc/ceph/keyring,/etc/ceph/keyring.bin: (2) No such file or directory ... -1 auth: unable to find a keyring on /etc/ceph/ceph.client.admin.keyring,/etc/ceph/ceph.keyring,/etc/ceph/keyring,/etc/ceph/keyring.bin: (2) No such file or directory ... -1 auth: unable to find a keyring on /etc/ceph/ceph.client.admin.keyring,/etc/ceph/ceph.keyring,/etc/ceph/keyring,/etc/ceph/keyring.bin: (2) No such file or directory ... -1 auth: unable to find a keyring on /etc/ceph/ceph.client.admin.keyring,/etc/ceph/ceph.keyring,/etc/ceph/keyring,/etc/ceph/keyring.bin: (2) No such file or directory ... -1 auth: unable to find a keyring on /etc/ceph/ceph.client.admin.keyring,/etc/ceph/ceph.keyring,/etc/ceph/keyring,/etc/ceph/keyring.bin: (2) No such file or directory ... -1 auth: unable to find a keyring on /etc/ceph/ceph.client.admin.keyring,/etc/ceph/ceph.keyring,/etc/ceph/keyring,/etc/ceph/keyring.bin: (2) No such file or directory ... -1 auth: unable to find a keyring on /etc/ceph/ceph.client.admin.keyring,/etc/ceph/ceph.keyring,/etc/ceph/keyring,/etc/ceph/keyring.bin: (2) No such file or directory ... -1 auth: unable to find a keyring on /etc/ceph/ceph.client.admin.keyring,/etc/ceph/ceph.keyring,/etc/ceph/keyring,/etc/ceph/keyring.bin: (2) No such file or directory device_health_metrics rbd This was introduced in commit 98a2e5c59daa ("rados: translate errno to str in CLI"). Fixes: https://tracker.ceph.com/issues/51628 Signed-off-by: Ilya Dryomov (cherry picked from commit 70aa026b097d919b41b2a1221d73b326557f75e3) --- diff --git a/src/auth/KeyRing.cc b/src/auth/KeyRing.cc index a2833183633a..a49cf5094ffa 100644 --- a/src/auth/KeyRing.cc +++ b/src/auth/KeyRing.cc @@ -41,7 +41,7 @@ int KeyRing::from_ceph_context(CephContext *cct) if (ret < 0) lderr(cct) << "failed to load " << filename << ": " << cpp_strerror(ret) << dendl; - } else { + } else if (conf->key.empty() && conf->keyfile.empty()) { lderr(cct) << "unable to find a keyring on " << conf->keyring << ": " << cpp_strerror(ret) << dendl; } diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index b32af4ba8092..dc2153fac7b2 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -5906,8 +5906,6 @@ int Monitor::mkfs(bufferlist& osdmapbl) r = ceph_resolve_file_search(g_conf()->keyring, keyring_filename); if (r) { - derr << "unable to find a keyring file on " << g_conf()->keyring - << ": " << cpp_strerror(r) << dendl; if (g_conf()->key != "") { string keyring_plaintext = "[mon.]\n\tkey = " + g_conf()->key + "\n\tcaps mon = \"allow *\"\n"; @@ -5923,7 +5921,9 @@ int Monitor::mkfs(bufferlist& osdmapbl) return -EINVAL; } } else { - return -ENOENT; + derr << "unable to find a keyring on " << g_conf()->keyring + << ": " << cpp_strerror(r) << dendl; + return r; } } else { r = keyring.load(g_ceph_context, keyring_filename);