Skip to content

Commit 6251ac4

Browse files
Remove the host namespace check since it stops us from working on Docker Desktop.
1 parent d6e9297 commit 6251ac4

File tree

1 file changed

+3
-19
lines changed

1 file changed

+3
-19
lines changed

src/datadog/platform_util.cpp

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ constexpr uint64_t CGROUP2_SUPER_MAGIC = 0x63677270;
302302

303303
/// Magic number from linux/proc_ns.h:
304304
/// <https://github.com/torvalds/linux/blob/5859a2b1991101d6b978f3feb5325dad39421f29/include/linux/proc_ns.h#L41-L49>
305-
constexpr ino_t HOST_CGROUP_NAMESPACE_INODE = 0xeffffffb;
305+
// constexpr ino_t HOST_CGROUP_NAMESPACE_INODE = 0xeffffffb;
306306

307307
/// Represents the cgroup version of the current process.
308308
enum class Cgroup : char { v1, v2 };
@@ -316,19 +316,6 @@ Optional<ino_t> get_inode(std::string_view path) {
316316
return buf.st_ino;
317317
}
318318

319-
// Host namespace inode number are hardcoded, which allows for dectection of
320-
// whether the binary is running in host or not. However, it does not work when
321-
// running in a Docker in Docker environment.
322-
bool is_running_in_host_namespace() {
323-
// linux procfs file that represents the cgroup namespace of the current
324-
// process.
325-
if (auto inode = get_inode("/proc/self/ns/cgroup")) {
326-
return *inode == HOST_CGROUP_NAMESPACE_INODE;
327-
}
328-
329-
return false;
330-
}
331-
332319
Optional<Cgroup> get_cgroup_version() {
333320
struct statfs buf;
334321

@@ -389,11 +376,8 @@ Optional<std::string> find_container_id(std::istream& source,
389376

390377
Optional<ContainerID> get_id(const std::shared_ptr<tracing::Logger>& logger) {
391378
#if defined(__linux__) || defined(__unix__)
392-
if (is_running_in_host_namespace()) {
393-
// Not in a container, no need to continue.
394-
logger->log_error("Not in a container, no need to continue.");
395-
return nullopt;
396-
}
379+
// Comment out the host namespace check, following the algorithm from other tracers.
380+
// This should allow us to detect containers running in Docker Desktop.
397381

398382
auto maybe_cgroup = get_cgroup_version();
399383
if (!maybe_cgroup) {

0 commit comments

Comments
 (0)