Skip to content

Commit b44a8a3

Browse files
feat: support additional cgroup formats for container-id parsing (#222)
* Update docker container ID test to use a UUID that's 64 hex-chars long, as this is what other tracers are testing * Rename container::find_docker_container_id to container::find_container_id and update its implementation so that it is regex-based and covers the same set of inputs as other tracers, like Java and .NET -- the implementation is borrowed from the Java tracer * Add other cgroup file examples from the .NET Tracer * Fix formatting * Refactor to better align with Java implementation * Put back the get_cgroup_version and add temporary logging to confirm the f_type returned by the statfs call * Restore the cgroup logic, but also include TMPFS_MAGIC as a valid value for using our cgroup v1 lookup * Restore the previous substring approach and execute this first before invoking regex matching * Apply suggestions from code review Co-authored-by: Damien Mehala <[email protected]> * Move the regex string literals closer to their usage * Fix formatting --------- Co-authored-by: Damien Mehala <[email protected]>
1 parent 31f263f commit b44a8a3

File tree

3 files changed

+184
-23
lines changed

3 files changed

+184
-23
lines changed

src/datadog/platform_util.cpp

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#include "platform_util.h"
22

3+
#include <cassert>
34
#include <cstdint>
45
#include <fstream>
6+
#include <regex>
57

68
// clang-format off
79
#if defined(__x86_64__) || defined(_M_X64)
@@ -291,6 +293,7 @@ namespace {
291293
#if defined(__linux__) || defined(__unix__)
292294
/// Magic numbers from linux/magic.h:
293295
/// <https://github.com/torvalds/linux/blob/ca91b9500108d4cf083a635c2e11c884d5dd20ea/include/uapi/linux/magic.h#L71>
296+
constexpr uint64_t TMPFS_MAGIC = 0x01021994;
294297
constexpr uint64_t CGROUP_SUPER_MAGIC = 0x27e0eb;
295298
constexpr uint64_t CGROUP2_SUPER_MAGIC = 0x63677270;
296299

@@ -330,27 +333,29 @@ Optional<Cgroup> get_cgroup_version() {
330333
return nullopt;
331334
}
332335

333-
if (buf.f_type == CGROUP_SUPER_MAGIC)
336+
if (buf.f_type == CGROUP_SUPER_MAGIC || buf.f_type == TMPFS_MAGIC)
334337
return Cgroup::v1;
335338
else if (buf.f_type == CGROUP2_SUPER_MAGIC)
336339
return Cgroup::v2;
337340

338341
return nullopt;
339342
}
340343

341-
Optional<std::string> find_docker_container_id_from_cgroup() {
344+
Optional<std::string> find_container_id_from_cgroup() {
342345
auto cgroup_fd = std::ifstream("/proc/self/cgroup", std::ios::in);
343346
if (!cgroup_fd.is_open()) return nullopt;
344347

345-
return find_docker_container_id(cgroup_fd);
348+
return find_container_id(cgroup_fd);
346349
}
347350
#endif
348351
} // namespace
349352

350-
Optional<std::string> find_docker_container_id(std::istream& source) {
353+
Optional<std::string> find_container_id(std::istream& source) {
354+
std::string line;
355+
356+
// Look for Docker container IDs in the basic format: `docker-<uuid>.scope`.
351357
constexpr std::string_view docker_str = "docker-";
352358

353-
std::string line;
354359
while (std::getline(source, line)) {
355360
// Example:
356361
// `0::/system.slice/docker-abcdef0123456789abcdef0123456789.scope`
@@ -366,23 +371,46 @@ Optional<std::string> find_docker_container_id(std::istream& source) {
366371
}
367372
}
368373

374+
// Reset the stream to the beginning.
375+
source.clear();
376+
source.seekg(0);
377+
378+
// Perform a second pass using a regular expression for matching container IDs
379+
// in a Fargate environment. This two-step approach is used because STL
380+
// `regex` is relatively slow, so we avoid using it unless necessary.
381+
static const std::string uuid_regex_str =
382+
"[0-9a-f]{8}[-_][0-9a-f]{4}[-_][0-9a-f]{4}[-_][0-9a-f]{4}[-_][0-9a-f]{12}"
383+
"|(?:[0-9a-f]{8}(?:-[0-9a-f]{4}){4}$)";
384+
static const std::string container_regex_str = "[0-9a-f]{64}";
385+
static const std::string task_regex_str = "[0-9a-f]{32}-\\d+";
386+
static const std::regex path_reg("(?:.+)?(" + uuid_regex_str + "|" +
387+
container_regex_str + "|" + task_regex_str +
388+
")(?:\\.scope)?$");
389+
390+
while (std::getline(source, line)) {
391+
// Example:
392+
// `0::/system.slice/docker-abcdef0123456789abcdef0123456789.scope`
393+
std::smatch match;
394+
if (std::regex_match(line, match, path_reg) && match.size() == 2) {
395+
assert(match.ready());
396+
assert(match.size() == 2);
397+
398+
return match.str(1);
399+
}
400+
}
401+
369402
return nullopt;
370403
}
371404

372405
Optional<ContainerID> get_id() {
373406
#if defined(__linux__) || defined(__unix__)
374-
if (is_running_in_host_namespace()) {
375-
// Not in a container, no need to continue.
376-
return nullopt;
377-
}
378-
379407
auto maybe_cgroup = get_cgroup_version();
380408
if (!maybe_cgroup) return nullopt;
381409

382410
ContainerID id;
383411
switch (*maybe_cgroup) {
384412
case Cgroup::v1: {
385-
if (auto maybe_id = find_docker_container_id_from_cgroup()) {
413+
if (auto maybe_id = find_container_id_from_cgroup()) {
386414
id.value = *maybe_id;
387415
id.type = ContainerID::Type::container_id;
388416
break;
@@ -392,9 +420,12 @@ Optional<ContainerID> get_id() {
392420
// inode.
393421
[[fallthrough]];
394422
case Cgroup::v2: {
395-
if (auto maybe_inode = get_inode("/sys/fs/cgroup")) {
396-
id.type = ContainerID::Type::cgroup_inode;
397-
id.value = std::to_string(*maybe_inode);
423+
if (!is_running_in_host_namespace()) {
424+
auto maybe_inode = get_inode("/sys/fs/cgroup");
425+
if (maybe_inode) {
426+
id.type = ContainerID::Type::cgroup_inode;
427+
id.value = std::to_string(*maybe_inode);
428+
}
398429
}
399430
}; break;
400431
}

src/datadog/platform_util.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@ struct ContainerID final {
8484
std::string value;
8585
};
8686

87-
/// Find the docker container ID from a given source.
87+
/// Find the container ID from a given source.
8888
/// This function is exposed mainly for testing purposes.
8989
///
90-
/// @param source The input from which to read the Docker container ID.
91-
/// @return An Optional containing the Docker container ID if found, otherwise
90+
/// @param source The input from which to read the container ID.
91+
/// @return An Optional containing the container ID if found, otherwise
9292
/// nothing.
93-
Optional<std::string> find_docker_container_id(std::istream& source);
93+
Optional<std::string> find_container_id(std::istream& source);
9494

9595
/// Function to retrieve the container metadata.
9696
///

test/test_platform_util.cpp

Lines changed: 135 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ PLATFORM_UTIL_TEST("find docker container ID") {
1919
{__LINE__, "empty inputs", "", nullopt},
2020
{__LINE__, "no docker container ID", "coucou", nullopt},
2121
{__LINE__, "one line with docker container ID",
22-
"0::/system.slice/docker-abcdef0123456789abcdef0123456789.scope",
23-
"abcdef0123456789abcdef0123456789"},
22+
"0::/system.slice/"
23+
"docker-"
24+
"cde7c2bab394630a42d73dc610b9c57415dced996106665d427f6d0566594411.scope",
25+
"cde7c2bab394630a42d73dc610b9c57415dced996106665d427f6d0566594411"},
2426
{__LINE__, "multiline wihtout docker container ID", R"(
2527
0::/
2628
10:memory:/user.slice/user-0.slice/session-14.scope
@@ -41,22 +43,150 @@ PLATFORM_UTIL_TEST("find docker container ID") {
4143
9:hugetlb:/
4244
8:cpuset:/
4345
7:pids:/user.slice/user-0.slice/session-14.scope
44-
3:cpu:/system.slice/docker-abcdef0123456789abcdef0123456789.scope
46+
3:cpu:/system.slice/docker-cde7c2bab394630a42d73dc610b9c57415dced996106665d427f6d0566594411.scope
4547
6:freezer:/
4648
5:net_cls,net_prio:/
4749
4:perf_event:/
4850
3:cpu,cpuacct:/user.slice/user-0.slice/session-14.scope
4951
2:devices:/user.slice/user-0.slice/session-14.scope
5052
1:name=systemd:/user.slice/user-0.slice/session-14.scope
5153
)",
52-
"abcdef0123456789abcdef0123456789"},
54+
"cde7c2bab394630a42d73dc610b9c57415dced996106665d427f6d0566594411"},
5355
}));
5456

5557
CAPTURE(test_case.name);
5658

5759
std::istringstream is(test_case.input);
5860

59-
auto maybe_container_id = container::find_docker_container_id(is);
61+
auto maybe_container_id = container::find_container_id(is);
62+
if (test_case.expected_container_id.has_value()) {
63+
REQUIRE(maybe_container_id.has_value());
64+
CHECK(*maybe_container_id == *test_case.expected_container_id);
65+
} else {
66+
CHECK(!maybe_container_id.has_value());
67+
}
68+
}
69+
70+
PLATFORM_UTIL_TEST("find multiline container IDs") {
71+
struct TestCase {
72+
size_t line;
73+
std::string_view name;
74+
std::string input;
75+
Optional<std::string> expected_container_id;
76+
};
77+
78+
auto test_case = GENERATE(values<TestCase>({
79+
{__LINE__, "Docker", R"(
80+
13:name=systemd:/docker/3726184226f5d3147c25fdeab5b60097e378e8a720503a5e19ecfdf29f869860
81+
12:pids:/docker/3726184226f5d3147c25fdeab5b60097e378e8a720503a5e19ecfdf29f869860
82+
11:hugetlb:/docker/3726184226f5d3147c25fdeab5b60097e378e8a720503a5e19ecfdf29f869860
83+
10:net_prio:/docker/3726184226f5d3147c25fdeab5b60097e378e8a720503a5e19ecfdf29f869860
84+
9:perf_event:/docker/3726184226f5d3147c25fdeab5b60097e378e8a720503a5e19ecfdf29f869860
85+
8:net_cls:/docker/3726184226f5d3147c25fdeab5b60097e378e8a720503a5e19ecfdf29f869860
86+
7:freezer:/docker/3726184226f5d3147c25fdeab5b60097e378e8a720503a5e19ecfdf29f869860
87+
6:devices:/docker/3726184226f5d3147c25fdeab5b60097e378e8a720503a5e19ecfdf29f869860
88+
5:memory:/docker/3726184226f5d3147c25fdeab5b60097e378e8a720503a5e19ecfdf29f869860
89+
4:blkio:/docker/3726184226f5d3147c25fdeab5b60097e378e8a720503a5e19ecfdf29f869860
90+
3:cpuacct:/docker/3726184226f5d3147c25fdeab5b60097e378e8a720503a5e19ecfdf29f869860
91+
2:cpu:/docker/3726184226f5d3147c25fdeab5b60097e378e8a720503a5e19ecfdf29f869860
92+
1:cpuset:/docker/3726184226f5d3147c25fdeab5b60097e378e8a720503a5e19ecfdf29f869860
93+
)",
94+
"3726184226f5d3147c25fdeab5b60097e378e8a720503a5e19ecfdf29f869860"},
95+
{__LINE__, "Kubernetes", R"(
96+
11:perf_event:/kubepods/besteffort/pod3d274242-8ee0-11e9-a8a6-1e68d864ef1a/3e74d3fd9db4c9dd921ae05c2502fb984d0cde1b36e581b13f79c639da4518a1
97+
10:pids:/kubepods/besteffort/pod3d274242-8ee0-11e9-a8a6-1e68d864ef1a/3e74d3fd9db4c9dd921ae05c2502fb984d0cde1b36e581b13f79c639da4518a1
98+
9:memory:/kubepods/besteffort/pod3d274242-8ee0-11e9-a8a6-1e68d864ef1a/3e74d3fd9db4c9dd921ae05c2502fb984d0cde1b36e581b13f79c639da4518a1
99+
8:cpu,cpuacct:/kubepods/besteffort/pod3d274242-8ee0-11e9-a8a6-1e68d864ef1a/3e74d3fd9db4c9dd921ae05c2502fb984d0cde1b36e581b13f79c639da4518a1
100+
7:blkio:/kubepods/besteffort/pod3d274242-8ee0-11e9-a8a6-1e68d864ef1a/3e74d3fd9db4c9dd921ae05c2502fb984d0cde1b36e581b13f79c639da4518a1
101+
6:cpuset:/kubepods/besteffort/pod3d274242-8ee0-11e9-a8a6-1e68d864ef1a/3e74d3fd9db4c9dd921ae05c2502fb984d0cde1b36e581b13f79c639da4518a1
102+
5:devices:/kubepods/besteffort/pod3d274242-8ee0-11e9-a8a6-1e68d864ef1a/3e74d3fd9db4c9dd921ae05c2502fb984d0cde1b36e581b13f79c639da4518a1
103+
4:freezer:/kubepods/besteffort/pod3d274242-8ee0-11e9-a8a6-1e68d864ef1a/3e74d3fd9db4c9dd921ae05c2502fb984d0cde1b36e581b13f79c639da4518a1
104+
3:net_cls,net_prio:/kubepods/besteffort/pod3d274242-8ee0-11e9-a8a6-1e68d864ef1a/3e74d3fd9db4c9dd921ae05c2502fb984d0cde1b36e581b13f79c639da4518a1
105+
2:hugetlb:/kubepods/besteffort/pod3d274242-8ee0-11e9-a8a6-1e68d864ef1a/3e74d3fd9db4c9dd921ae05c2502fb984d0cde1b36e581b13f79c639da4518a1
106+
1:name=systemd:/kubepods/besteffort/pod3d274242-8ee0-11e9-a8a6-1e68d864ef1a/3e74d3fd9db4c9dd921ae05c2502fb984d0cde1b36e581b13f79c639da4518a1
107+
1:name=systemd:/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod2d3da189_6407_48e3_9ab6_78188d75e609.slice/docker-3e74d3fd9db4c9dd921ae05c2502fb984d0cde1b36e581b13f79c639da4518a1.scope
108+
)",
109+
"3e74d3fd9db4c9dd921ae05c2502fb984d0cde1b36e581b13f79c639da4518a1"},
110+
{__LINE__, "Ecs", R"(
111+
9:perf_event:/ecs/haissam-ecs-classic/5a0d5ceddf6c44c1928d367a815d890f/38fac3e99302b3622be089dd41e7ccf38aff368a86cc339972075136ee2710ce
112+
8:memory:/ecs/haissam-ecs-classic/5a0d5ceddf6c44c1928d367a815d890f/38fac3e99302b3622be089dd41e7ccf38aff368a86cc339972075136ee2710ce
113+
7:hugetlb:/ecs/haissam-ecs-classic/5a0d5ceddf6c44c1928d367a815d890f/38fac3e99302b3622be089dd41e7ccf38aff368a86cc339972075136ee2710ce
114+
6:freezer:/ecs/haissam-ecs-classic/5a0d5ceddf6c44c1928d367a815d890f/38fac3e99302b3622be089dd41e7ccf38aff368a86cc339972075136ee2710ce
115+
5:devices:/ecs/haissam-ecs-classic/5a0d5ceddf6c44c1928d367a815d890f/38fac3e99302b3622be089dd41e7ccf38aff368a86cc339972075136ee2710ce
116+
4:cpuset:/ecs/haissam-ecs-classic/5a0d5ceddf6c44c1928d367a815d890f/38fac3e99302b3622be089dd41e7ccf38aff368a86cc339972075136ee2710ce
117+
3:cpuacct:/ecs/haissam-ecs-classic/5a0d5ceddf6c44c1928d367a815d890f/38fac3e99302b3622be089dd41e7ccf38aff368a86cc339972075136ee2710ce
118+
2:cpu:/ecs/haissam-ecs-classic/5a0d5ceddf6c44c1928d367a815d890f/38fac3e99302b3622be089dd41e7ccf38aff368a86cc339972075136ee2710ce
119+
1:blkio:/ecs/haissam-ecs-classic/5a0d5ceddf6c44c1928d367a815d890f/38fac3e99302b3622be089dd41e7ccf38aff368a86cc339972075136ee2710ce
120+
)",
121+
"38fac3e99302b3622be089dd41e7ccf38aff368a86cc339972075136ee2710ce"},
122+
{__LINE__, "Fargate1Dot3", R"(
123+
11:hugetlb:/ecs/55091c13-b8cf-4801-b527-f4601742204d/432624d2150b349fe35ba397284dea788c2bf66b885d14dfc1569b01890ca7da
124+
10:pids:/ecs/55091c13-b8cf-4801-b527-f4601742204d/432624d2150b349fe35ba397284dea788c2bf66b885d14dfc1569b01890ca7da
125+
9:cpuset:/ecs/55091c13-b8cf-4801-b527-f4601742204d/432624d2150b349fe35ba397284dea788c2bf66b885d14dfc1569b01890ca7da
126+
8:net_cls,net_prio:/ecs/55091c13-b8cf-4801-b527-f4601742204d/432624d2150b349fe35ba397284dea788c2bf66b885d14dfc1569b01890ca7da
127+
7:cpu,cpuacct:/ecs/55091c13-b8cf-4801-b527-f4601742204d/432624d2150b349fe35ba397284dea788c2bf66b885d14dfc1569b01890ca7da
128+
6:perf_event:/ecs/55091c13-b8cf-4801-b527-f4601742204d/432624d2150b349fe35ba397284dea788c2bf66b885d14dfc1569b01890ca7da
129+
5:freezer:/ecs/55091c13-b8cf-4801-b527-f4601742204d/432624d2150b349fe35ba397284dea788c2bf66b885d14dfc1569b01890ca7da
130+
4:devices:/ecs/55091c13-b8cf-4801-b527-f4601742204d/432624d2150b349fe35ba397284dea788c2bf66b885d14dfc1569b01890ca7da
131+
3:blkio:/ecs/55091c13-b8cf-4801-b527-f4601742204d/432624d2150b349fe35ba397284dea788c2bf66b885d14dfc1569b01890ca7da
132+
2:memory:/ecs/55091c13-b8cf-4801-b527-f4601742204d/432624d2150b349fe35ba397284dea788c2bf66b885d14dfc1569b01890ca7da
133+
1:name=systemd:/ecs/55091c13-b8cf-4801-b527-f4601742204d/432624d2150b349fe35ba397284dea788c2bf66b885d14dfc1569b01890ca7da
134+
)",
135+
"432624d2150b349fe35ba397284dea788c2bf66b885d14dfc1569b01890ca7da"},
136+
{__LINE__, "Fargate1Dot4", R"(
137+
11:hugetlb:/ecs/34dc0b5e626f2c5c4c5170e34b10e765-1234567890
138+
10:pids:/ecs/34dc0b5e626f2c5c4c5170e34b10e765-1234567890
139+
9:cpuset:/ecs/34dc0b5e626f2c5c4c5170e34b10e765-1234567890
140+
8:net_cls,net_prio:/ecs/34dc0b5e626f2c5c4c5170e34b10e765-1234567890
141+
7:cpu,cpuacct:/ecs/34dc0b5e626f2c5c4c5170e34b10e765-1234567890
142+
6:perf_event:/ecs/34dc0b5e626f2c5c4c5170e34b10e765-1234567890
143+
5:freezer:/ecs/34dc0b5e626f2c5c4c5170e34b10e765-1234567890
144+
4:devices:/ecs/34dc0b5e626f2c5c4c5170e34b10e765-1234567890
145+
3:blkio:/ecs/34dc0b5e626f2c5c4c5170e34b10e765-1234567890
146+
2:memory:/ecs/34dc0b5e626f2c5c4c5170e34b10e765-1234567890
147+
1:name=systemd:/ecs/34dc0b5e626f2c5c4c5170e34b10e765-1234567890
148+
)",
149+
"34dc0b5e626f2c5c4c5170e34b10e765-1234567890"},
150+
{__LINE__, "EksNodegroup", R"(
151+
11:blkio:/kubepods.slice/kubepods-pod9508fe66_7675_4003_b7c9_d83e9f8f85e5.slice/cri-containerd-26cfbe35e08b24f053011af4ada23d8fcbf81f27f8331a94f56de5b677c903e4.scope
152+
10:cpuset:/kubepods.slice/kubepods-pod9508fe66_7675_4003_b7c9_d83e9f8f85e5.slice/cri-containerd-26cfbe35e08b24f053011af4ada23d8fcbf81f27f8331a94f56de5b677c903e4.scope
153+
9:perf_event:/kubepods.slice/kubepods-pod9508fe66_7675_4003_b7c9_d83e9f8f85e5.slice/cri-containerd-26cfbe35e08b24f053011af4ada23d8fcbf81f27f8331a94f56de5b677c903e4.scope
154+
8:memory:/kubepods.slice/kubepods-pod9508fe66_7675_4003_b7c9_d83e9f8f85e5.slice/cri-containerd-26cfbe35e08b24f053011af4ada23d8fcbf81f27f8331a94f56de5b677c903e4.scope
155+
7:pids:/kubepods.slice/kubepods-pod9508fe66_7675_4003_b7c9_d83e9f8f85e5.slice/cri-containerd-26cfbe35e08b24f053011af4ada23d8fcbf81f27f8331a94f56de5b677c903e4.scope
156+
6:cpu,cpuacct:/kubepods.slice/kubepods-pod9508fe66_7675_4003_b7c9_d83e9f8f85e5.slice/cri-containerd-26cfbe35e08b24f053011af4ada23d8fcbf81f27f8331a94f56de5b677c903e4.scope
157+
5:net_cls,net_prio:/kubepods.slice/kubepods-pod9508fe66_7675_4003_b7c9_d83e9f8f85e5.slice/cri-containerd-26cfbe35e08b24f053011af4ada23d8fcbf81f27f8331a94f56de5b677c903e4.scope
158+
4:devices:/kubepods.slice/kubepods-pod9508fe66_7675_4003_b7c9_d83e9f8f85e5.slice/cri-containerd-26cfbe35e08b24f053011af4ada23d8fcbf81f27f8331a94f56de5b677c903e4.scope
159+
3:freezer:/kubepods.slice/kubepods-pod9508fe66_7675_4003_b7c9_d83e9f8f85e5.slice/cri-containerd-26cfbe35e08b24f053011af4ada23d8fcbf81f27f8331a94f56de5b677c903e4.scope
160+
2:hugetlb:/kubepods.slice/kubepods-pod9508fe66_7675_4003_b7c9_d83e9f8f85e5.slice/cri-containerd-26cfbe35e08b24f053011af4ada23d8fcbf81f27f8331a94f56de5b677c903e4.scope
161+
1:name=systemd:/kubepods.slice/kubepods-pod9508fe66_7675_4003_b7c9_d83e9f8f85e5.slice/cri-containerd-26cfbe35e08b24f053011af4ada23d8fcbf81f27f8331a94f56de5b677c903e4.scope
162+
)",
163+
"26cfbe35e08b24f053011af4ada23d8fcbf81f27f8331a94f56de5b677c903e4"},
164+
{__LINE__, "PcfContainer1", R"(
165+
12:memory:/system.slice/garden.service/garden/6f265890-5165-7fab-6b52-18d1
166+
11:rdma:/
167+
10:freezer:/garden/6f265890-5165-7fab-6b52-18d1
168+
9:hugetlb:/garden/6f265890-5165-7fab-6b52-18d1
169+
8:pids:/system.slice/garden.service/garden/6f265890-5165-7fab-6b52-18d1
170+
7:perf_event:/garden/6f265890-5165-7fab-6b52-18d1
171+
6:cpu,cpuacct:/system.slice/garden.service/garden/6f265890-5165-7fab-6b52-18d1
172+
5:net_cls,net_prio:/garden/6f265890-5165-7fab-6b52-18d1
173+
4:cpuset:/garden/6f265890-5165-7fab-6b52-18d1
174+
3:blkio:/system.slice/garden.service/garden/6f265890-5165-7fab-6b52-18d1
175+
2:devices:/system.slice/garden.service/garden/6f265890-5165-7fab-6b52-18d1
176+
1:name=systemd:/system.slice/garden.service/garden/6f265890-5165-7fab-6b52-18d1
177+
)",
178+
"6f265890-5165-7fab-6b52-18d1"},
179+
{__LINE__, "PcfContainer2", R"(
180+
1:name=systemd:/system.slice/garden.service/garden/6f265890-5165-7fab-6b52-18d1
181+
)",
182+
"6f265890-5165-7fab-6b52-18d1"},
183+
}));
184+
185+
CAPTURE(test_case.name);
186+
187+
std::istringstream is(test_case.input);
188+
189+
auto maybe_container_id = container::find_container_id(is);
60190
if (test_case.expected_container_id.has_value()) {
61191
REQUIRE(maybe_container_id.has_value());
62192
CHECK(*maybe_container_id == *test_case.expected_container_id);

0 commit comments

Comments
 (0)