]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/util.cc: add CONTAINER_NAME processing for metadata 25383/head
authorDan Mick <dan.mick@redhat.com>
Wed, 31 Oct 2018 03:50:53 +0000 (20:50 -0700)
committerDan Mick <dan.mick@redhat.com>
Mon, 3 Dec 2018 22:34:34 +0000 (14:34 -0800)
Kubernetes clusters use POD_NAME; simple containers should be
distinguishable and don't have 'pods'.

Signed-off-by: Dan Mick <dan.mick@redhat.com>
src/common/util.cc

index d0fbee5e3fc0693f36d8467f21433b535f4dc029..68545840e7d799a4a9ba133f64cf14434e643347 100644 (file)
@@ -154,15 +154,24 @@ void collect_sys_info(map<string, string> *m, CephContext *cct)
   }
 
   // but wait, am i in a container?
+  bool in_container = false;
+
   if (const char *pod_name = getenv("POD_NAME")) {
     (*m)["pod_name"] = pod_name;
+    in_container = true;
+  }
+  if (const char *container_name = getenv("CONTAINER_NAME")) {
+    (*m)["container_name"] = container_name;
+    in_container = true;
+  }
+  if (in_container) {
     if (const char *node_name = getenv("NODE_NAME")) {
       (*m)["container_hostname"] = u.nodename;
       (*m)["hostname"] = node_name;
     }
-  }
-  if (const char *ns = getenv("POD_NAMESPACE")) {
-    (*m)["pod_namespace"] = ns;
+    if (const char *ns = getenv("POD_NAMESPACE")) {
+      (*m)["pod_namespace"] = ns;
+    }
   }
 
 #ifdef __APPLE__