Skip to content

osdtrace: add --id option to trace by OSD ID, drop -o#113

Merged
taodd merged 1 commit into
mainfrom
feature/trace-by-osd-id-v2
May 27, 2026
Merged

osdtrace: add --id option to trace by OSD ID, drop -o#113
taodd merged 1 commit into
mainfrom
feature/trace-by-osd-id-v2

Conversation

@taodd
Copy link
Copy Markdown
Owner

@taodd taodd commented May 27, 2026

Summary

  • Replace -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.
  • Mutually exclusive with -p; errors clearly on unknown / ambiguous / negative IDs.
  • Re-applies the work from the reverted PR osdtrace: support tracing specifically by OSD ID via --id option #110 with extra test coverage.

Test plan

  • make osdtrace builds cleanly
  • tests/test-id-option.sh — standalone negative-path test (no cluster needed); 5/5 cases pass locally: nonexistent ID, --id/-p conflict, non-numeric, negative, removed -o
  • tests/functional-test-microceph.sh — adds a second osdtrace run in parallel with the existing -p run, this one targeting OSD 2 via --id 2; verified by:
    • grep for the --id 2 resolved to PID … log line
    • existing verify_osdtrace_output row invariants
    • new verify_osdtrace_targets_only helper that asserts every captured row's osd_id equals the targeted ID (proves uprobes attached only to the requested PID, no others)
  • CI green

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.
@taodd taodd requested a review from Copilot May 27, 2026 08:06
@taodd taodd requested a review from pponnuvel May 27, 2026 08:06
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 --id parsing and resolution of OSD ID(s) → PID(s) via existing process discovery, and enforce --id vs -p mutual exclusivity.
  • Remove the old -o option 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 --id attaches only to the targeted OSD PID (via per-row osd_id assertions).

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 thread src/osdtrace.cc
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;
}
}
@taodd taodd merged commit 83dd228 into main May 27, 2026
49 of 50 checks passed
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.

2 participants