diff --git a/userspace/libsinsp/test/classes/sinsp_threadinfo.cpp b/userspace/libsinsp/test/classes/sinsp_threadinfo.cpp index 685f4198a72..37d6075a057 100644 --- a/userspace/libsinsp/test/classes/sinsp_threadinfo.cpp +++ b/userspace/libsinsp/test/classes/sinsp_threadinfo.cpp @@ -16,6 +16,7 @@ limitations under the License. */ #include +#include TEST(sinsp_threadinfo, get_main_thread) { @@ -126,10 +127,11 @@ TEST_F(sinsp_with_test_input, THRD_INFO_assign_children_to_a_nullptr) ASSERT_THREAD_INFO_PIDS(p3_t1_tid, p3_t1_pid, 0); } +#define RGX_POD "(pod[a-z0-9]{8}[-_][a-z0-9]{4}[-_][a-z0-9]{4}[-_][a-z0-9]{4}[-_][a-z0-9]{12})" + // This test asserts that our regex is solid against all possible cgroup layouts TEST(sinsp_threadinfo, check_pod_uid_regex) { - // RGX_POD is defined in `threadinfo.h` re2::RE2 pattern(RGX_POD, re2::RE2::POSIX); // CgroupV1, driver cgroup diff --git a/userspace/libsinsp/threadinfo.cpp b/userspace/libsinsp/threadinfo.cpp index cfec222b33f..d49b5e4297a 100644 --- a/userspace/libsinsp/threadinfo.cpp +++ b/userspace/libsinsp/threadinfo.cpp @@ -31,6 +31,9 @@ limitations under the License. #include "tracer_emitter.h" #endif +#include +#define RGX_POD "(pod[a-z0-9]{8}[-_][a-z0-9]{4}[-_][a-z0-9]{4}[-_][a-z0-9]{4}[-_][a-z0-9]{12})" + constexpr static const char* s_thread_table_name = "threads"; extern sinsp_evttables g_infotables; @@ -838,7 +841,6 @@ void sinsp_threadinfo::set_pod_uid() return; } -#ifndef _WIN32 // If `this->cgroups()` is not empty we should have at least the first element // An example of `this->cgroups()[0].second` layout is: // /kubelet.slice/kubelet-kubepods.slice/kubelet-kubepods-pod1b011081_6e8e_4839_b225_4685eae5fd59.slice/cri-containerd-2f92446a3fbfd0b7a73457b45e96c75a25c5e44e7b1bcec165712b906551c261.scope @@ -859,7 +861,6 @@ void sinsp_threadinfo::set_pod_uid() // The final `pod_uid` layout is: // 05869489-8c7f-45dc-9abd-1b1620787bb1 -#endif } sinsp_fdinfo_t* sinsp_threadinfo::add_fd(int64_t fd, sinsp_fdinfo_t *fdinfo) diff --git a/userspace/libsinsp/threadinfo.h b/userspace/libsinsp/threadinfo.h index eb39eeaecdc..62e1fa9881f 100644 --- a/userspace/libsinsp/threadinfo.h +++ b/userspace/libsinsp/threadinfo.h @@ -39,9 +39,6 @@ struct iovec { #include "internal_metrics.h" #include "state/table.h" #include "thread_group_info.h" -#include - -#define RGX_POD "(pod[a-z0-9]{8}[-_][a-z0-9]{4}[-_][a-z0-9]{4}[-_][a-z0-9]{4}[-_][a-z0-9]{12})" class sinsp_delays_info; class sinsp_tracerparser;