Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
Signed-off-by: Andrea Terzolo <[email protected]>
  • Loading branch information
Andreagit97 committed Oct 3, 2023
1 parent 3879f58 commit 50080ae
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 3 additions & 1 deletion userspace/libsinsp/test/classes/sinsp_threadinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ limitations under the License.
*/

#include <test/helpers/threads_helpers.h>
#include <re2/re2.h>

TEST(sinsp_threadinfo, get_main_thread)
{
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions userspace/libsinsp/threadinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ limitations under the License.
#include "tracer_emitter.h"
#endif

#include <re2/re2.h>
#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;
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions userspace/libsinsp/threadinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ struct iovec {
#include "internal_metrics.h"
#include "state/table.h"
#include "thread_group_info.h"
#include <re2/re2.h>

#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;
Expand Down

0 comments on commit 50080ae

Please sign in to comment.