Skip to content

Commit efd6b97

Browse files
committed
update UpsertTracepoint, add TraceProgram for scoping tracepoint deployments to supported nodes
Signed-off-by: Benjamin Kilimnik <bkilimnik@pixielabs.ai>
1 parent e881a34 commit efd6b97

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

content/en/04-tutorials/04-custom-data/01-distributed-bpftrace-deployment.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,43 @@ If you'd like to filter the results to a particular service, modify line 67 to i
170170
df = df[px.contains(df['dst'], 'sock-shop')]
171171
```
172172

173+
### Deploying different BPFtrace programs depending on properties of the host
174+
175+
Pixie has introduced a `TraceProgram` object in the `pxtrace` module, which allows you to specify deployment restrictions for your BPFtrace programs. You can use the `TraceProgram` object to define a BPFtrace program and specify the kernel versions on which it should be deployed (more selectors may be added in the future).
176+
177+
The `TraceProgram` object currently accepts the following parameters:
178+
179+
- `program`: The BPFtrace program as a string.
180+
- `max_kernel`: The maximum kernel version on which the program should be deployed.
181+
- `min_kernel`: The minimum kernel version on which the program should be deployed.
182+
183+
You can use the `TraceProgram` object to deploy different BPFtrace programs based on the kernel version of the nodes in your cluster. For example, you might have one version of a BPFtrace program that works on kernel versions up to 5.18, and another version that works on kernel versions 5.19 and above. You can define two `TraceProgram` objects and use them both in the `UpsertTracepoint` function.
184+
185+
Here's an example:
186+
187+
```python
188+
import pxtrace
189+
import px
190+
191+
before_518_trace_program = pxtrace.TraceProgram(
192+
program="""$0""",
193+
max_kernel='5.18',
194+
)
195+
after_519_trace_program = pxtrace.TraceProgram(
196+
program="""$1""",
197+
min_kernel='5.19',
198+
)
199+
200+
table_name = 'tcp_drop_table'
201+
pxtrace.UpsertTracepoint('tcp_drop_tracer',
202+
table_name,
203+
[before_518_trace_program, after_519_trace_program],
204+
pxtrace.kprobe(),
205+
'10m')
206+
```
207+
208+
In this example, the `before_518_trace_program` will be deployed on nodes with kernel versions up to 5.18, and the `after_519_trace_program` will be deployed on nodes with kernel versions 5.19 and above.
209+
173210
### Tracepoint status
174211

175212
Run `px/tracepoint_status` to see the information about all of the tracepoints running on your cluster. The `STATUS` column can be used to debug why a tracepoint fails to deploy.

external/pxl_documentation.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,9 +1045,9 @@
10451045
},
10461046
{
10471047
"ident": "probe_fn",
1048-
"desc": "The tracepoint function.",
1048+
"desc": "The tracepoint function, BPFTrace program or pxtrace.TraceProgram to deploy.",
10491049
"types": [
1050-
"px.ProbeFn"
1050+
"Union[px.ProbeFn, str, pxtrace.TraceProgram, List[pxtrace.TraceProgram]]"
10511051
]
10521052
},
10531053
{

0 commit comments

Comments
 (0)