Skip to content

doca_xplane: add new plugin#102

Merged
filanov merged 1 commit into
NVIDIA:mainfrom
qbarrand:xplane
Apr 19, 2026
Merged

doca_xplane: add new plugin#102
filanov merged 1 commit into
NVIDIA:mainfrom
qbarrand:xplane

Conversation

@qbarrand
Copy link
Copy Markdown

@qbarrand qbarrand commented Apr 2, 2026

Add plugins for DOCA XPlane.


Please place an 'X' inside each '[]' to confirm you adhere to our Contributor Guidelines

  • Is the commit message split over multiple lines and hard-wrapped at 72 characters?
  • Is the subject and message clear and concise?
  • Does the subject start with [plugin_name] if submitting a plugin patch or a [section_name] if part of the core sosreport code?
  • Does the commit contain a Signed-off-by: First Lastname email@example.com?
  • Are any related Issues or existing PRs properly referenced via a Closes (Issue) or Resolved (PR) line?
  • Are all passwords or private data gathered by this PR obfuscated?

Summary by CodeRabbit

  • New Features
    • Added DOCA XPlane diagnostics collection: gathers service configuration and unit info, runtime logs, client outputs (version and topology), and dynamic per-plane status/details.
    • CLI-based collection runs only when the client is available, parses topology to determine plane count, and halts further per-plane collection on client errors or malformed output.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 2, 2026

📝 Walkthrough

Walkthrough

New sosreport plugin adds DOCA XPlane diagnostics collection: copies service files and logs, conditionally runs doca-xplane-client commands, validates status/output JSON, and registers per-plane client command captures based on parsed topology.

Changes

Cohort / File(s) Summary
DOCA XPlane Plugin
sos/report/plugins/doca_xplane.py
Adds new plugin DocaXPlane with constants SERVICE_NAME, CLIENT_COMMAND; registers copy specs for /opt/mellanox/doca/services/xplane and /var/log/xplane; conditionally runs client commands (version, get-status, get-planes-summary, get-topology); validates CLI status, parses JSON to derive num_planes, and dynamically registers per-plane subcommand captures.

Sequence Diagram(s)

sequenceDiagram
    participant Plugin as DocaXPlane Plugin
    participant Sysroot as Sysroot/Filesystem
    participant Client as doca-xplane-client
    participant Logger as Logger

    Plugin->>Sysroot: add copy specs (/opt/.../xplane, /var/log/xplane)
    Plugin->>Sysroot: check executable `doca-xplane-client`
    alt client available
        Plugin->>Client: run `version`, `get-status`
        Client-->>Plugin: status + output (raw)
        Plugin->>Logger: log non-zero status and stop (if status != 0)
        alt status == 0
            Plugin->>Plugin: parse JSON output
            Plugin->>Logger: log JSON errors and stop (if parse fails)
            Plugin->>Client: register per-plane commands (for i in 0..num_planes-1)
        end
    else client missing
        Plugin->>Logger: skip CLI collection
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hop through logs and service trees,
I call the client, parse the seas,
Planes are counted, commands arranged,
JSON read and outputs ranged,
A rabbit's joy in data gleaned with ease.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly describes the main change: adding a new plugin for DOCA XPlane. It is concise, clear, and accurately reflects the changeset content.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Pylint (4.0.5)
sos/report/plugins/doca_xplane.py

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@sos/report/plugins/doca_xplane_client.py`:
- Around line 34-35: The code directly parses res["output"] into status and
accesses status["topologySummary"]["planes"], which can raise on invalid JSON or
missing keys; wrap json.loads(res["output"]) in a try/except catching
JSONDecodeError and other Exceptions, then validate that status is a dict and
contains "topologySummary" as a dict and "planes" as an int (or coerce/default
to 0/None) before assigning num_planes; on any parse/shape failure log a clear
warning including res["output"] and return or skip collection gracefully rather
than letting the plugin crash (refer to the variables/status keys status,
num_planes, and res["output"] to locate the change).
- Line 1: The file incorrectly imports List from ast; change the import to use
typing.List (e.g. replace "from ast import List" with "from typing import List")
or remove the import and use the native generic "list[str]" if you target Python
3.9+, so the type annotation(s) like the List[str] used in functions/classes
(see usages around the current List[str] at/near line 37) reference the proper
typing List rather than ast.List.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7251f158-8579-46bf-bb39-b85c7e8d7b5f

📥 Commits

Reviewing files that changed from the base of the PR and between f400586 and ffc83e2.

📒 Files selected for processing (2)
  • sos/report/plugins/doca_xplane.py
  • sos/report/plugins/doca_xplane_client.py

Comment thread sos/report/plugins/doca_xplane_client.py Outdated
Comment thread sos/report/plugins/doca_xplane_client.py Outdated
@qbarrand qbarrand changed the title Add doca_xplane and doca_xplane_client Add doca_xplane and doca_xplane_client Apr 2, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
sos/report/plugins/doca_xplane_client.py (1)

32-35: ⚠️ Potential issue | 🟠 Major

Harden JSON shape/type handling and avoid broad catch.

At Line 33-35, num_planes is assumed present and range-compatible, and Line 35 catches Exception. Please validate status shape and coerce/validate planes to int before range(num_planes), while catching specific parse/type errors.

Proposed fix
-        try:
-            status = json.loads(res["output"])
-            num_planes = status["topologySummary"]["planes"]
-        except Exception as e:
-            self._log_error(f"Failed to parse status: {e}")
-            return
+        try:
+            status = json.loads(res["output"])
+            topology_summary = status.get("topologySummary", {})
+            num_planes = int(topology_summary.get("planes", 0))
+            if num_planes < 0:
+                raise ValueError("planes must be >= 0")
+        except (json.JSONDecodeError, TypeError, ValueError, AttributeError) as e:
+            self._log_error(f"Failed to parse status: {e}")
+            return

Also applies to: 49-49

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@sos/report/plugins/doca_xplane_client.py` around lines 32 - 35, The current
try/except around json.loads(res["output"]) and num_planes assumes
status["topologySummary"]["planes"] exists and is an int and catches all
Exceptions; update the block to (1) catch specific exceptions (e.g.,
json.JSONDecodeError, KeyError, TypeError, ValueError) instead of a broad
Exception, (2) validate that status is a dict and that "topologySummary" is a
dict containing "planes", (3) coerce/validate planes to an integer (e.g.,
int(planes_value)) and ensure it's >=0 before using range(num_planes), and (4)
apply the same validation/coercion and specific-exception handling to the other
occurrence where num_planes is read (the second status/planes access) so both
places use the same robust checks.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@sos/report/plugins/doca_xplane_client.py`:
- Around line 32-35: The current try/except around json.loads(res["output"]) and
num_planes assumes status["topologySummary"]["planes"] exists and is an int and
catches all Exceptions; update the block to (1) catch specific exceptions (e.g.,
json.JSONDecodeError, KeyError, TypeError, ValueError) instead of a broad
Exception, (2) validate that status is a dict and that "topologySummary" is a
dict containing "planes", (3) coerce/validate planes to an integer (e.g.,
int(planes_value)) and ensure it's >=0 before using range(num_planes), and (4)
apply the same validation/coercion and specific-exception handling to the other
occurrence where num_planes is read (the second status/planes access) so both
places use the same robust checks.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4a171c9d-509b-4f63-b743-f32d8decb98e

📥 Commits

Reviewing files that changed from the base of the PR and between ffc83e2 and ea70b15.

📒 Files selected for processing (2)
  • sos/report/plugins/doca_xplane.py
  • sos/report/plugins/doca_xplane_client.py
✅ Files skipped from review due to trivial changes (1)
  • sos/report/plugins/doca_xplane.py

Copy link
Copy Markdown
Collaborator

@filanov filanov left a comment

Choose a reason for hiding this comment

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

I suggest to have a single plugin instead of spliting it

Comment thread sos/report/plugins/doca_xplane.py Outdated
Comment thread sos/report/plugins/doca_xplane.py Outdated
Comment thread sos/report/plugins/doca_xplane.py Outdated
Comment thread sos/report/plugins/doca_xplane.py Outdated
Comment thread sos/report/plugins/doca_xplane.py Outdated
@qbarrand qbarrand changed the title Add doca_xplane and doca_xplane_client doca_xplane: add new plugin Apr 17, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@sos/report/plugins/doca_xplane.py`:
- Around line 65-70: The current call to self.add_cmd_output eagerly builds
num_planes * len(subcommands) commands; clamp the fan-out by introducing a
MAX_PLANES constant (or config) and replace range(num_planes) with
range(min(num_planes, MAX_PLANES)) when constructing the list comprehension that
uses CLIENT_COMMAND, subcommands and num_planes; also emit a warning/log (e.g.,
via self.logger or processLogger) when num_planes is truncated so callers know
the output is limited.
- Around line 50-55: The try/except around json.loads and extracting
status["topologySummary"]["planes"] is too broad and does not validate
num_planes; update the block to catch specific exceptions (json.JSONDecodeError,
KeyError, TypeError, ValueError) when calling json.loads and accessing status
keys, then validate num_planes (the value from
status["topologySummary"]["planes"]) is an integer >= 0 before it's consumed by
the later range(...) list comprehension; if num_planes is a numeric string
attempt int(...) conversion, otherwise call self._log_error with a clear message
and return to avoid using an invalid value.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 0de75a25-7130-4835-afe9-97fe050af74b

📥 Commits

Reviewing files that changed from the base of the PR and between ea70b15 and 3c429ff.

📒 Files selected for processing (1)
  • sos/report/plugins/doca_xplane.py

Comment thread sos/report/plugins/doca_xplane.py
Comment thread sos/report/plugins/doca_xplane.py
Add a plugin for DOCA XPlane.

Signed-off-by: Quentin Barrand <qbarrand@nvidia.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
sos/report/plugins/doca_xplane.py (1)

42-44: Improve failure log context for get-status.

At Line 43, the error message drops the return code/output, which makes field debugging harder. Include command status and output snippet in the log.

Proposed patch
-        if res["status"] != 0:
-            self._log_error("Failed to get status")
+        if res["status"] != 0:
+            self._log_error(
+                "Failed to get status: "
+                f"rc={res.get('status')} output={res.get('output', '').strip()[:256]}"
+            )
             return
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@sos/report/plugins/doca_xplane.py` around lines 42 - 44, The current check in
the doca_xplane plugin swallows useful context when the get-status command
fails; update the failure logging in the block that checks res["status"] (and
calls self._log_error) to include the numeric return code and a short snippet of
the command output/error (e.g., res.get("output") or res.get("stderr") trimmed
to ~200 chars) so the message becomes something like "Failed to get status:
code=X, output='...'", and ensure you guard against missing keys when building
the message.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@sos/report/plugins/doca_xplane.py`:
- Around line 42-44: The current check in the doca_xplane plugin swallows useful
context when the get-status command fails; update the failure logging in the
block that checks res["status"] (and calls self._log_error) to include the
numeric return code and a short snippet of the command output/error (e.g.,
res.get("output") or res.get("stderr") trimmed to ~200 chars) so the message
becomes something like "Failed to get status: code=X, output='...'", and ensure
you guard against missing keys when building the message.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 1f5fba74-74ff-4e19-9d99-1254abb8d267

📥 Commits

Reviewing files that changed from the base of the PR and between 3c429ff and de2b212.

📒 Files selected for processing (1)
  • sos/report/plugins/doca_xplane.py

@filanov filanov merged commit ea2ad0f into NVIDIA:main Apr 19, 2026
7 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