]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
msg/Messenger: use random nonce if CEPH_USE_RANDOM_NONCE or pid == 1
authorSage Weil <sage@newdream.net>
Sat, 27 Feb 2021 20:45:47 +0000 (15:45 -0500)
committerMichael Fritch <mfritch@suse.com>
Mon, 8 Mar 2021 14:34:35 +0000 (07:34 -0700)
If we are in a container, then we do not have a unique pid, and need to
use a random nonce.  We normally detect this if our pid is 1, but that
doesn't work when we have a init process--we'll (probably?) have a small
pid (in my tests, the OSDs were getting pid 7).

To be safe, also check for an environment variable set by cephadm.

This avoids problems that arise when we don't have a unique address.

Fixes: https://tracker.ceph.com/issues/49534
Signed-off-by: Sage Weil <sage@newdream.net>
(cherry picked from commit d18f60854e68d2060c1a3841299466f165f6552d)

src/msg/Messenger.cc

index 4e2ea96ebe20b16cb8326c7a0b73c3438d811af5..0b57891bd2d6210958fa72cd6b3bc2c5e6236c66 100644 (file)
@@ -21,7 +21,7 @@ Messenger *Messenger::create_client_messenger(CephContext *cct, string lname)
 uint64_t Messenger::get_pid_nonce()
 {
   uint64_t nonce = getpid();
-  if (nonce == 1) {
+  if (nonce == 1 || getenv("CEPH_USE_RANDOM_NONCE")) {
     // we're running in a container; use a random number instead!
     nonce = ceph::util::generate_random_number<uint64_t>();
   }