Skip to content

fabrics: propagate connect-all/discover errors to the exit status - #3957

Open
prabhakarpujeri wants to merge 1 commit into
linux-nvme:nvme-cli-2.xfrom
prabhakarpujeri:fix-2800-connect-all-exit-2x
Open

fabrics: propagate connect-all/discover errors to the exit status#3957
prabhakarpujeri wants to merge 1 commit into
linux-nvme:nvme-cli-2.xfrom
prabhakarpujeri:fix-2800-connect-all-exit-2x

Conversation

@prabhakarpujeri

Copy link
Copy Markdown

Fixes #2800 on the 2.x branch.

connect-all on 2.x drops every error from __discover() and friends:

  • discover_from_conf_file() ignores the __discover() return, overwrites ret with the disconnect result, and silently skips creation failures of the discovery controller (goto next)
  • __discover() returns 0 even when per-entry connects fail (only the "already connected" case was handled)
  • _discover_from_json_config_file() drops errors the same way

So with several targets in discovery.conf and one down, exit status is 0 and nvmf-autoconnect.service (Restart=on-failure) never retries — exactly the regression igaw analyzed on the issue (1.x accumulated the error per discovery.conf entry; 2.x ignored __discover's return).

Note: 3.x already has correct aggregation through the fabrics rework (eedb1c15d); this is the targeted 2.x fix, keeping last-error-wins semantics matching 1.x.

Test (local, 2.x branch)

discovery.conf: -t tcp -a 127.0.0.1 -s 18080 (refused instantly)

# pristine:  nvme connect-all --no-nbft ; echo $?   -> 0
# fixed:     nvme connect-all --no-nbft ; echo $?   -> 1

meson test suite: 39 pass, 0 fail (2 pre-existing expected failures). The NBFT path was exercised only with --no-nbft in this test loop; NBFT on the 2.x tip has a separate crash, see the other PR.

nvme-cli 2.x discards almost every error in the auto-discovery paths, so 'nvme connect-all' exits 0 even when the discovery controller or an individual entry fails to connect.  With nvmf-autoconnect.service this breaks Restart=on-failure setups.

This is a regression from 1.x, which accumulated errors from do_discover() over each discovery.conf entry and returned the last non-zero one.

Restore the accumulation at the four places that drop errors:

- __discover(): record per-entry connect failures (excluding ENVME_CONNECT_ALREADY, which is informational) and errors from the recursive discovery calls;
- discover_from_conf_file(): keep the return value of __discover() instead of overwriting it with the disconnect result, and treat a failure to create the discovery controller as an error, mirroring the argv path in nvmf_discover();
- _discover_from_json_config_file(): same treatment; its caller already aggregates.

The explicit single-target path (nvmf_discover with -t/-a/-s) already returns the error, and 3.x does this via the fabrics rework (eedb1c1); this restores the behavior on the 2.x branch.

Tested: discovery.conf with '-t tcp -a 127.0.0.1 -s 18080'; 'nvme connect-all --no-nbft' exits 1 with the fix and 0 without.

Fixes: linux-nvme#2800
Signed-off-by: Prabhakar Pujeri <prabhakar.pujeri@dell.com>
@igaw

igaw commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

I've deleted my previous comment because I thought it was for master, this PR is for 2.x

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