osdtrace: add --id option to trace by OSD ID, drop -o#113
Merged
Conversation
Replaces -o (userspace post-filter) with --id <id1,id2,...> that resolves
OSD IDs to PIDs via discovery and attaches uprobes only to those PIDs.
Mutually exclusive with -p; errors on unknown / ambiguous / negative IDs.
Tests:
- tests/test-id-option.sh: standalone negative-path checks (no cluster).
- tests/functional-test-microceph.sh: parallel --id 2 run alongside -p,
asserted via new verify_osdtrace_targets_only helper.
There was a problem hiding this comment.
Pull request overview
This PR updates osdtrace to support targeted tracing by Ceph OSD ID(s) via a new --id <id1,id2,...> option, replacing the former -o <osd-id> userspace filter, and adds test coverage to validate the new behavior.
Changes:
- Add
--idparsing and resolution of OSD ID(s) → PID(s) via existing process discovery, and enforce--idvs-pmutual exclusivity. - Remove the old
-ooption and the corresponding userspace post-filtering in the event handler. - Add negative-path argument-parsing tests and extend the MicroCeph functional test to validate that
--idattaches only to the targeted OSD PID (via per-rowosd_idassertions).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/test-id-option.sh | Adds standalone negative-path tests for --id, --id/-p conflict, invalid values, and removed -o. |
| tests/lib/verify-trace-output.sh | Adds verify_osdtrace_targets_only to assert captured rows only contain targeted osd_id values. |
| tests/functional-test-microceph.sh | Runs a second osdtrace instance using --id and verifies resolver log + targets-only invariant. |
| src/osdtrace.cc | Implements --id option, resolves IDs to PIDs in main(), removes -o and userspace OSD-ID filtering. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1135
to
+1149
| std::stringstream ss(optarg); | ||
| std::string token; | ||
| while (std::getline(ss, token, ',')) { | ||
| try { | ||
| int id = stoi(token); | ||
| if (id < 0) { | ||
| std::cerr << "Invalid --id value (must be non-negative): " << token << std::endl; | ||
| return -1; | ||
| } | ||
| requested_osd_ids.insert(id); | ||
| } catch (...) { | ||
| std::cerr << "Invalid --id value: " << token << std::endl; | ||
| return -1; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
-o <osd-id>(a userspace post-filter that still attached uprobes globally) with--id <id1,id2,...>that resolves OSD IDs to PIDs via the existing process-discovery code and attaches uprobes only to those PIDs.-p; errors clearly on unknown / ambiguous / negative IDs.Test plan
make osdtracebuilds cleanlytests/test-id-option.sh— standalone negative-path test (no cluster needed); 5/5 cases pass locally: nonexistent ID,--id/-pconflict, non-numeric, negative, removed-otests/functional-test-microceph.sh— adds a second osdtrace run in parallel with the existing-prun, this one targeting OSD 2 via--id 2; verified by:--id 2 resolved to PID …log lineverify_osdtrace_outputrow invariantsverify_osdtrace_targets_onlyhelper that asserts every captured row'sosd_idequals the targeted ID (proves uprobes attached only to the requested PID, no others)