discovery: notify every pending host, not just the first one #1977
Pull request overview
This PR fixes Discovery Service AEN delivery so that all hosts with a parked AER (persistent discovery connection) get notified when subsystems/listeners change, rather than only the first eligible connection being notified (or notifications aborting early on send errors). It also makes the notification loop concurrency-safe by holding self.lock while traversing conn_vals, avoiding races with connection reaping.
Changes:
recv_async set and send the “Discovery Log Page Change” async event to each one (no early return after the first send).self.lock while walking self.conn_vals to avoid concurrent mutation while notifying.BrokenPipeError / OSError, log and continue notifying other hosts instead of aborting the whole notification pass.---
💡 <a href="/ceph/ceph-nvmeof/new/devel?filename=.github/instructions/*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.
The BrokenPipeError log message doesn’t identify which discovery connection/controller disconnected, which makes triage difficult now that notifications iterate over all connections.
This exception log would be more actionable if it included which connection triggered the OSError (e.g., socket/fileno), especially since the loop continues to notify other hosts.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
fixed
incorporated.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Looks good to me
We will update the state of this PR after more testing
lgtm
@leonidc may i learn how the test is going? is there anything i can do on my end?
@leonidc may i learn how the test is going? is there anything i can do on my end?
@tchaikov sorry for the delay. we have some additional automation that is not a part of upstream yet that we use. Most of the tests are covered in teuthology but we also want to verify using the additional tests. Will run it an update in few days max.
@tchaikov please merge it. Some tests failed because of a known regression introduced last week to ceph main (see https://github.com/ceph/ceph/pull/70461). Other than that testing looks good.
Approved these changes.
The updated notification loop changes behavior from “notify first parked AER only” to “notify every connection with a parked AER and continue past send failures”. There isn’t test coverage validating (a) all pending discovery connections are notified on a state update and (b) a send failure on one connection does not prevent others from being notified, which is the core regression being fixed here.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
@tchaikov please merge it. Some tests failed because of a known regression introduced last week to ceph main (see ceph/ceph#70461). Other than that testing looks good.
@caroav hi Aviv, thanks for reviewing this change and approving it. but i am not able to merge it, as you noticed, some tests failed, and they are "required" to pass. i just rebased against devel HEAD in hope to retrigger the test.
nvmeof_accept() sets each discovery socket to non-blocking (conn.setblocking(False)), but _state_notify_update() uses sendall() directly. On non-blocking sockets, sendall() can raise BlockingIOError (EAGAIN) and may do partial writes before failing, which risks sending a truncated PDU/CQE and corrupting framing. Consider forcing the socket to blocking just for this small AEN send (under the lock) so the payload is sent atomically, or implement a proper buffered write path.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
leonidc
tchaikov
_state_notify_update() returned right after completing the async event of the first connection with a parked AER, on the error paths too, so when a subsystem or listener change fired, only one of the hosts with a persistent discovery connection learned about it; the rest kept waiting on AERs that never complete. A dead connection was worse: BrokenPipeError returned before any remaining host was notified.
AENs complete per controller, so send the Discovery Log Page Change notice to every parked AER: loop over all connections, continue past send failures, and let the keep-alive reaper collect the dead ones.
Take self.lock while walking conn_vals, like every other accessor (nvmeof_tcp_connection, nvmeof_accept, handle_timeout): this function runs on the state-update thread, racing the reaper's del. The payload is a 40-byte AEN on a non-blocking socket, so holding the lock across the loop is fine.
break_interval stays unused: it paces heavy RPC batches in server.py's version of this callback, but here it would only delay notifications, and sleeping under the lock would stall the request path.
Fixes #1976