Skip to content

Added cgid capture to stirling with testing - #1681

Merged
vihangm merged 10 commits into
pixie-io:mainfrom
tewaro:stirling-cgids
Oct 3, 2023
Merged

vihangm merged 10 commits into
pixie-io:mainfrom
tewaro:stirling-cgids

Conversation

@tewaro

@tewaro tewaro commented Aug 18, 2023 •

Copy link
Copy Markdown
Contributor

Summary: Added Capturing of Cgroup ids to the ebpf probes in the socket tracer. This includes modifications to data structures for communicating that information to userspace and other data tables. It also includes some minimal testing for ensuring that cgroup ids are captured correctly. The reason for this change is given in the design document for the solution to this issue: in short it is the first step in using cgids rather than pids to associate a particular piece of communication data with the correct pod.

Test Plan: Added Cgroup id capture checks to existing socket_tracer tests.

Type of change: /kind Feature expansion

Signed-off-as: AdityaAtulTewari adityaatewari@gmail.com

@tewaro
tewaro requested a review from a team as a code owner August 18, 2023 21:58
@tewaro
tewaro had a problem deploying to pr-actions-approval August 18, 2023 21:59 — with GitHub Actions Error
Signed-off-by: AdityaAtulTewari <adityaatewari@gmail.com>
@tewaro
tewaro temporarily deployed to pr-actions-approval August 18, 2023 22:06 — with GitHub Actions Inactive
@vihangm
vihangm requested a review from a team August 21, 2023 01:01
@tewaro
tewaro had a problem deploying to pr-actions-approval August 21, 2023 15:52 — with GitHub Actions Error
Signed-off-by: AdityaAtulTewari <adityaatewari@gmail.com>
@tewaro
tewaro had a problem deploying to pr-actions-approval August 21, 2023 15:52 — with GitHub Actions Error
@tewaro
tewaro temporarily deployed to pr-actions-approval August 24, 2023 14:47 — with GitHub Actions Inactive
@ddelnano

Copy link
Copy Markdown
Member

@AdityaAtulTewari and I discussed this already but for those here, I'm planning to review this but it won't be until tomorrow or Monday.

@ddelnano

Copy link
Copy Markdown
Member

@pixie-io/maintainers in the meantime would we be able to let the CI jobs run? @AdityaAtulTewari is interested in seeing if there are any failures to address.

Signed-off-by: AdityaAtulTewari <adityaatewari@gmail.com>
@tewaro
tewaro temporarily deployed to pr-actions-approval August 24, 2023 17:31 — with GitHub Actions Inactive
Signed-off-by: AdityaAtulTewari <adityaatewari@gmail.com>
@tewaro
tewaro temporarily deployed to pr-actions-approval August 24, 2023 22:16 — with GitHub Actions Inactive
Signed-off-by: AdityaAtulTewari <adityaatewari@gmail.com>
@tewaro
tewaro temporarily deployed to pr-actions-approval August 25, 2023 02:08 — with GitHub Actions Inactive
Signed-off-by: AdityaAtulTewari <adityaatewari@gmail.com>
@tewaro
tewaro temporarily deployed to pr-actions-approval August 25, 2023 02:30 — with GitHub Actions Inactive

@ddelnano ddelnano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AdityaAtulTewari really appreciate the contribution and excited to address this short lived process issue! I have a few minor comments and some thoughts about the timeline for this fix's development.

We had previously discussed writing a trace bpf test that would exhibit this short lived process behavior. I think it's important to develop that before we make the change to store the cgroup ids (this PR). Essentially my thoughts are that we would take your containerized application from this branch, create a new trace bpf test with it and then follow it up with this change to verify it results in the records we expect.

I believe it's important to have confidence that a problematic application fails our existing pid based assertions but works with the cgroup id ones.

Comment on lines 1440 to 1445
r.Append<r.ColIndex("time_")>(entry.resp.timestamp_ns);
r.Append<r.ColIndex("upid")>(upid.value());
r.Append<r.ColIndex("cgid")>(conn_id.cgid);
r.Append<r.ColIndex("remote_addr")>(conn_tracker.remote_endpoint().AddrStr());
r.Append<r.ColIndex("remote_port")>(conn_tracker.remote_endpoint().port());
r.Append<r.ColIndex("trace_role")>(conn_tracker.role());

@ddelnano ddelnano Aug 25, 2023 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are many shared fields amongst each data table definition and record builder. This seems like a good opportunity to provide a mechanism for adding new columns in the future. We could define a macro like so:

#define APPEND_SKT_TRACER_COLS(timestamp, upid, conn_tracker) \
  r.Append<r.ColIndex("time_")>(entry.resp.timestamp_ns); \
  r.Append<r.ColIndex("upid")>(upid.value()); \
  r.Append<r.ColIndex("remote_addr")>(conn_tracker.remote_endpoint().AddrStr()); \
  r.Append<r.ColIndex("remote_port")>(conn_tracker.remote_endpoint().port()); \
  r.Append<r.ColIndex("trace_role")>(conn_tracker.role());

Another approach would be to create a similar method on the RecordBuilder class. I think I prefer the macro one better because it's not a socket specific construct and these shared fields aren't universally applicable to all data tables.

I don't feel strongly about incorporating this into your change, however, it would be great to have a mechanism to ensure new tables include all the relevant "socket tracer" columns.

@tewaro
tewaro temporarily deployed to pr-actions-approval September 22, 2023 05:16 — with GitHub Actions Inactive
Signed-off-by: AdityaAtulTewari <adityaatewari@gmail.com>
Signed-off-by: AdityaAtulTewari <adityaatewari@gmail.com>
@tewaro

tewaro commented Sep 22, 2023

Copy link
Copy Markdown
Contributor Author

We had previously discussed writing a trace bpf test that would exhibit this short lived process behavior. I think it's important to develop that before we make the change to store the cgroup ids (this PR). Essentially my thoughts are that we would take your containerized application from this branch, create a new trace bpf test with it and then follow it up with this change to verify it results in the records we expect.

This change does not fix the race condition, it just exposes the cgroup id so that a future pr can. The changes are broken up this way as it allows me to break apart the solution to this problem into easier to design pieces. I'm happy to add that test to the change in progress that fixes the issue. However I don't think it is appropriate here because it will still fail.

@tewaro
tewaro requested a review from ddelnano September 26, 2023 14:05
Signed-off-by: AdityaAtulTewari <adityaatewari@gmail.com>
@tewaro
tewaro temporarily deployed to pr-actions-approval September 26, 2023 14:36 — with GitHub Actions Inactive

@ddelnano ddelnano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test suite still needs to pass, but the changes look good to me pending that 👍

We will need to regenerate the data table docs with the following
tool: //src/carnot/docstring/tables:datatables. Happy to help with that after this is merged.

@ddelnano

Copy link
Copy Markdown
Member

cc @etep since I believe you are interested in reviewing this as well.

@tewaro tewaro changed the title Added cgid capture to stirling with minimal testing Added cgid capture to stirling with testing Sep 29, 2023
Comment thread src/stirling/core/canonical_types.h Resolved
Signed-off-by: AdityaAtulTewari <adityaatewari@gmail.com>
@tewaro
tewaro temporarily deployed to pr-actions-approval October 1, 2023 00:06 — with GitHub Actions Inactive
@ddelnano
ddelnano requested a review from a team October 2, 2023 16:28
@vihangm
vihangm merged commit 2a2349f into pixie-io:main Oct 3, 2023
benkilimnik added a commit to benkilimnik/pixie-privy that referenced this pull request Oct 16, 2023
benkilimnik added a commit to benkilimnik/pixie-privy that referenced this pull request Oct 16, 2023
Signed-off-by: Benjamin Kilimnik <bkilimnik@pixielabs.ai>
benkilimnik added a commit to benkilimnik/pixie-privy that referenced this pull request Oct 16, 2023
Signed-off-by: Benjamin Kilimnik <bkilimnik@pixielabs.ai>
aimichelle pushed a commit that referenced this pull request Oct 17, 2023
Summary: Revert cgid capture

This change reverts capturing Cgroup ids from
2a2349f.
Many of the 4.14 kernel tests have [BPF compilation
errors](https://app.buildbuddy.io/invocation/075de8d0-d161-4ff6-8b74-123c6da66778#):
`HINT: bpf_get_current_cgroup_id missing (added in Linux 4.18)`.
Perplexingly, GitHub seems to show these tests as [passing despite the
failures](https://github.com/pixie-io/pixie/actions/runs/6366478258/job/17320729511).

Relevant Issues: #1638 #1739

Type of change: /kind bug

Test Plan: Running CI

Signed-off-by: Benjamin Kilimnik <bkilimnik@pixielabs.ai>
ddelnano pushed a commit to k8sstormcenter/pixie that referenced this pull request Feb 25, 2026
Summary: Added Capturing of Cgroup ids to the ebpf probes in the socket
tracer. This includes modifications to data structures for communicating
that information to userspace and other data tables. It also includes
some minimal testing for ensuring that cgroup ids are captured
correctly. The reason for this change is given in the design document
for the solution to this
[issue](pixie-io#1638): in short it is
the first step in using cgids rather than pids to associate a particular
piece of communication data with the correct pod.

Test Plan: Added Cgroup id capture checks to existing `socket_tracer`
tests.

Type of change: /kind Feature expansion

Signed-off-by: AdityaAtulTewari <adityaatewari@gmail.com>
ddelnano pushed a commit to k8sstormcenter/pixie that referenced this pull request Feb 25, 2026
…ixie-io#1738)

Summary: Revert cgid capture

This change reverts capturing Cgroup ids from
pixie-io@2a2349f.
Many of the 4.14 kernel tests have [BPF compilation
errors](https://app.buildbuddy.io/invocation/075de8d0-d161-4ff6-8b74-123c6da66778#):
`HINT: bpf_get_current_cgroup_id missing (added in Linux 4.18)`.
Perplexingly, GitHub seems to show these tests as [passing despite the
failures](https://github.com/pixie-io/pixie/actions/runs/6366478258/job/17320729511).

Relevant Issues: pixie-io#1638 pixie-io#1739

Type of change: /kind bug

Test Plan: Running CI

Signed-off-by: Benjamin Kilimnik <bkilimnik@pixielabs.ai>
ddelnano pushed a commit to k8sstormcenter/pixie that referenced this pull request Feb 25, 2026
Summary: Added Capturing of Cgroup ids to the ebpf probes in the socket
tracer. This includes modifications to data structures for communicating
that information to userspace and other data tables. It also includes
some minimal testing for ensuring that cgroup ids are captured
correctly. The reason for this change is given in the design document
for the solution to this
[issue](pixie-io#1638): in short it is
the first step in using cgids rather than pids to associate a particular
piece of communication data with the correct pod.

Test Plan: Added Cgroup id capture checks to existing `socket_tracer`
tests.

Type of change: /kind Feature expansion

Signed-off-by: AdityaAtulTewari <adityaatewari@gmail.com>
ddelnano pushed a commit to k8sstormcenter/pixie that referenced this pull request Feb 25, 2026
…ixie-io#1738)

Summary: Revert cgid capture

This change reverts capturing Cgroup ids from
pixie-io@2a2349f.
Many of the 4.14 kernel tests have [BPF compilation
errors](https://app.buildbuddy.io/invocation/075de8d0-d161-4ff6-8b74-123c6da66778#):
`HINT: bpf_get_current_cgroup_id missing (added in Linux 4.18)`.
Perplexingly, GitHub seems to show these tests as [passing despite the
failures](https://github.com/pixie-io/pixie/actions/runs/6366478258/job/17320729511).

Relevant Issues: pixie-io#1638 pixie-io#1739

Type of change: /kind bug

Test Plan: Running CI

Signed-off-by: Benjamin Kilimnik <bkilimnik@pixielabs.ai>
entlein pushed a commit to k8sstormcenter/pixie that referenced this pull request Jun 2, 2026
Summary: Added Capturing of Cgroup ids to the ebpf probes in the socket
tracer. This includes modifications to data structures for communicating
that information to userspace and other data tables. It also includes
some minimal testing for ensuring that cgroup ids are captured
correctly. The reason for this change is given in the design document
for the solution to this
[issue](pixie-io#1638): in short it is
the first step in using cgids rather than pids to associate a particular
piece of communication data with the correct pod.

Test Plan: Added Cgroup id capture checks to existing `socket_tracer`
tests.

Type of change: /kind Feature expansion

Signed-off-by: AdityaAtulTewari <adityaatewari@gmail.com>
entlein pushed a commit to k8sstormcenter/pixie that referenced this pull request Jun 2, 2026
…ixie-io#1738)

Summary: Revert cgid capture

This change reverts capturing Cgroup ids from
pixie-io@2e7a758.
Many of the 4.14 kernel tests have [BPF compilation
errors](https://app.buildbuddy.io/invocation/075de8d0-d161-4ff6-8b74-123c6da66778#):
`HINT: bpf_get_current_cgroup_id missing (added in Linux 4.18)`.
Perplexingly, GitHub seems to show these tests as [passing despite the
failures](https://github.com/pixie-io/pixie/actions/runs/6366478258/job/17320729511).

Relevant Issues: pixie-io#1638 pixie-io#1739

Type of change: /kind bug

Test Plan: Running CI

Signed-off-by: Benjamin Kilimnik <bkilimnik@pixielabs.ai>

This branch was previously deployed

1 inactive deployment
pr-actions-approval — 2f14742c Deployed Oct 1, 2023 by tewaro
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants