← Back to Pull requests

Allow deleting a host without disconnecting its connections. #1893

Merged
gbregman merged 10 files (1321 lines) on May 03, 2026 11:12 UTC
View on GitHub
gbregman gbregman commented on May 02, 2026 07:54 UTC
Author

Fixes #1885

Diff: 1321 lines (+951 / -370) across 10 files Reviewer: Hezko Review duration: 1638m
All Vouch review confidence checks passed
Residual risk 0.07 = Change Risk (0.62) × (1 − Review Confidence (0.89)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.62 · 1321 lines diff across 10 files
0.62
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.87 · 5 substantive comment(s)
0.87
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
89%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.400
Empty Description empty_description
0.060
Real PR Conversation Timeline
43 items
Copilot Copilot commented on code on May 02, 2026 08:02 UTC
Code Review
control/state.py:1
@@ -2098,6 +2139,7 @@ def update(self) -> bool:
                 # Find OMAP removals
                 removed_keys = local_state_keys - omap_state_keys
                 removed = {key: local_state_dict[key] for key in removed_keys}

removed.update(keep_connection) mixes added CONNECTED_HOST_PREFIX keys (injected via keep_connection) with actually removed keys from removed_keys. When a connected-host key is deleted from OMAP (e.g. host deletion without --keep-connections, or when the key is cleared), it will still be processed as a “removal” RPC, which (via control/server.py) calls set_keep_host_connected and can re-enable the flag on other gateways unexpectedly. Consider filtering out real CONNECTED_HOST_PREFIX removals from removed (or adding an explicit “clear” RPC/flag) so that only newly-added indications are applied before the host removal update.

Copilot Copilot commented on code on May 02, 2026 08:02 UTC
Code Review
control/server.py:1
@@ -1248,6 +1248,12 @@ def abort_server_on_update_error(rc: int, msg: str):
                                             ignore_unknown_fields=True)
                     rc = self.gateway_rpc.remove_host(req)
                 abort_server_on_update_error(rc.status, rc.error_message)
+            elif key.startswith(GatewayState.CONNECTED_HOST_PREFIX):
+                if not is_add_req:
+                    req = json_format.Parse(val, pb2.set_keep_host_connected_req(),
+                                            ignore_unknown_fields=True)
+                    rc = self.gateway_rpc.set_keep_host_connected(req)
+                    abort_server_on_update_error(rc.status, rc.error_message)

CONNECTED_HOST_PREFIX handling only runs when not is_add_req, and calls set_keep_host_connected. This means a connected-host key being removed from OMAP will also trigger set_keep_host_connected (re-setting the indication) even though the signal is being cleared. Either ignore removals for this prefix, or support clearing (e.g., add a boolean to the request / add a reset RPC) and call the appropriate action based on is_add_req.

Copilot Copilot commented on code on May 02, 2026 08:02 UTC
Code Review
control/state.py:1
@@ -306,6 +313,12 @@ def add_host(self, subsystem_nqn: str, host_nqn: str, val: str):
         key = GatewayState.build_host_key(subsystem_nqn, host_nqn)
         self._add_key(key, val)
 
+        # no need in connected host indication for this host
+        state = self.get_state()
+        for key in list(state.keys()):
+            if key == GatewayState.build_connected_host_key(subsystem_nqn, host_nqn):
+                self._remove_key(key)

add_host() scans the entire state (for key in list(state.keys())) just to delete a single exact key (build_connected_host_key(...)). This is unnecessarily expensive and harder to read than a direct membership check. Prefer computing the key once and removing it if present (e.g., key = build_connected_host_key(...); if key in state: _remove_key(key)).

Copilot Copilot commented on code on May 02, 2026 08:02 UTC
Code Review
control/grpc.py:1
@@ -5756,6 +5786,8 @@ def add_host_safe(self, request, context):
                         request, preserving_proto_field_name=True,
                         including_default_value_fields=True)
                     self.gateway_state.add_host(request.subsystem_nqn, request.host_nqn, json_req)
+                    self.gateway_state.remove_connected_host(request.subsystem_nqn,
+                                                             request.host_nqn)

This block removes PSK/DHCHAP host info unconditionally before (re)adding the host, but the connected-host OMAP key cleanup is handled twice: GatewayState.add_host() now removes the connected-host key, and then this code calls gateway_state.remove_connected_host(...) again. Consider dropping one of these paths to avoid redundant OMAP/local updates and extra RADOS operations.

Copilot Copilot commented on code on May 02, 2026 08:02 UTC
Code Review
tests/ha/keep_connection.sh:1
@@ -0,0 +1,314 @@
+#!/bin/bash
+
+. .env
+set -e
+set -x
+
+rpc=/usr/libexec/spdk/scripts/rpc.py
+GW1_NAME=$(docker ps --format '{{.ID}}\t{{.Names}}' | awk '$2 ~ /nvmeof/ && $2 ~ /1/ {print $1}')
+GW2_NAME=$(docker ps --format '{{.ID}}\t{{.Names}}' | awk '$2 ~ /nvmeof/ && $2 ~ /2/ {print $1}')
+ip1="$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$GW1_NAME")"
+ip2="$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$GW2_NAME")"
+
+function cephnvmf_func1()
+{
+    /usr/bin/docker compose run --rm nvmeof-cli --server-address ${ip1} --server-port ${NVMEOF_GW_PORT} $@
+}
+
+function cephnvmf_func2()
+{
+    /usr/bin/docker compose run --rm nvmeof-cli --server-address ${ip2} --server-port ${NVMEOF_GW_PORT} $@
+}
+
+echo "ℹ️  Starting bdevperf container"
+docker compose up -d bdevperf
+sleep 10
+make logs SVC=bdevperf
+BDEVPERF_SOCKET_LINE="$(make run SVC=bdevperf OPTS="--entrypoint=env" | grep BDEVPERF_SOCKET | tr -d '\n\r')"
+BDEVPERF_SOCKET="${BDEVPERF_SOCKET_LINE#BDEVPERF_SOCKET=}"
+make exec SVC=bdevperf OPTS=-T CMD="$rpc -v -s $BDEVPERF_SOCKET bdev_nvme_set_options -r -1"
+
+echo "ℹ️  Create resources"
+cephnvmf_func1 listener add --subsystem ${NQN} --host-name ${GW1_NAME} --traddr $ip1 --trsvcid 4430
+cephnvmf_func2 listener add --subsystem ${NQN} --host-name ${GW2_NAME} --traddr $ip2 --trsvcid 4430
+/usr/bin/docker compose run --rm nvmeof-cli --server-address ${ip1} --server-port ${NVMEOF_GW_PORT} host del --subsystem ${NQN} --host-nqn "*"
+cephnvmf_func1 namespace del --subsystem ${NQN} --nsid 2
+cephnvmf_func1 host add --subsystem ${NQN} --host-nqn ${NQN}host1
+sleep 20
+
+echo "ℹ️  Connect"
+devs=`make -s exec SVC=bdevperf OPTS=-T CMD="$rpc -v -s $BDEVPERF_SOCKET bdev_nvme_attach_controller -b Nvme0 -t tcp -a $ip1 -s 4420 -f ipv4 -n $NQN -q ${NQN}host1 -l -1 -o 10"`
+[[ "$devs" == "Nvme0n1" ]]
+
+echo "ℹ️  Verify connection"
+conns=$(cephnvmf_func1 --output stdio --format json connection list --subsystem $NQN)
+[[ `echo $conns | jq -r '.status'` == "0" ]]
+[[ `echo $conns | jq -r '.subsystem_nqn'` == "${NQN}" ]]
+[[ `echo $conns | jq -r '.connections[0].nqn'` == "${NQN}host1" ]]
+[[ `echo $conns | jq -r '.connections[0].trsvcid'` == "4420" ]]
+[[ `echo $conns | jq -r '.connections[0].traddr'` == "${ip1}" ]]
+[[ `echo $conns | jq -r '.connections[0].adrfam'` == "ipv4" ]]
+[[ `echo $conns | jq -r '.connections[0].trtype'` == "TCP" ]]
+[[ `echo $conns | jq -r '.connections[0].connected'` == "true" ]]
+[[ `echo $conns | jq -r '.connections[0].qpairs_count'` == "1" ]]
+[[ `echo $conns | jq -r '.connections[0].secure'` == "false" ]]
+[[ `echo $conns | jq -r '.connections[0].use_psk'` == "false" ]]
+[[ `echo $conns | jq -r '.connections[0].use_dhchap'` == "false" ]]
+[[ `echo $conns | jq -r '.connections[0].dhchap_controller_origin'` == "no_key" ]]
+[[ `echo $conns | jq -r '.connections[0].subsystem'` == "${NQN}" ]]
+[[ `echo $conns | jq -r '.connections[0].host_deleted'` == "false" ]]
+[[ `echo $conns | jq -r '.connections[1]'` == "null" ]]
+
+echo "ℹ️  Verify OMAP before host delete"
+set +e
+    make -s exec SVC=ceph OPTS=-T CMD="rados --pool rbd listomapvals nvmeof.state" | grep "connected-del-host"
+    if [[ $? -eq 0 ]]; then
+        echo "Shouldn't have connected host entry in OMAP before we delete the host"
+        exit 1
+    fi
+set -e
+
+echo "ℹ️  Delete host and keep connection"
+cephnvmf_func1 host del --subsystem ${NQN} --host-nqn ${NQN}host1 --keep-connections
+sleep 25
+grep "Received request to remove host ${NQN}host1 access from ${NQN}, force: False, keep connections: True, context: <grpc._server" /var/log/ceph/nvmeof-$GW1_NAME/nvmeof-log
+grep "Received request to remove host ${NQN}host1 access from ${NQN}, force: False, keep connections: True, context: None" /var/log/ceph/nvmeof-$GW2_NAME/nvmeof-log

The test greps for exact log lines including the Python context representation (e.g. context: <grpc._server...>). That formatting can vary across grpc/python versions and may make this HA test flaky even if behavior is correct. Prefer grepping for a stable substring (e.g. only keep connections: True/False) or validating the behavior via API output / OMAP state rather than log formatting details.

copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on May 02, 2026 08:02 UTC
Reviewer

Pull request overview

This PR implements the “delete host without disconnecting active connections” workflow (Issue #1885) to enable practical PSK rotation by deleting and re-adding a host while keeping existing sessions alive.

Changes:

  • Add keep_connections support to remove_host and propagate the intent across gateways via an OMAP “connected host” indication + new gRPC RPC.

  • Extend connection reporting with a host_deleted flag and surface it in CLI output.

  • Add an HA regression test (keep_connection) and run it in the GitHub Actions HA matrix.
  • Reviewed changes

    Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.

    <details>
    <summary>Show a summary per file</summary>

    | File | Description |
    | ---- | ----------- |
    | tests/ha/keep_connection.sh | New HA scenario covering “delete host but keep connection”, plus PSK rotation via delete+readd. |
    | control/proto/gateway.proto | Adds keep_connections to remove_host_req, introduces set_keep_host_connected RPC + host_deleted on connections. |
    | control/grpc.py | Implements keep-connections behavior, connected-host indication tracking, and host_deleted reporting. |
    | control/state.py | Adds OMAP key prefix + persistence helpers for connected-host indication; tweaks update flow ordering. |
    | control/server.py | Applies connected-host indication updates by calling the new RPC. |
    | control/cli.py | Adds --keep-connections to host del and marks deleted hosts in connection list output. |
    | lib/go/nvmeof/gateway.pb.go | Regenerated Go protobuf bindings reflecting proto changes. |
    | lib/go/nvmeof/gateway_grpc.pb.go | Regenerated Go gRPC bindings including set_keep_host_connected. |
    | .github/workflows/build-container.yml | Adds keep_connection to the HA test matrix. |
    </details>

    ---

    💡 <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>.

    gbregman gbregman commented on code on May 02, 2026 12:07 UTC
    Code Review
    control/state.py:1
    @@ -2098,6 +2139,7 @@ def update(self) -> bool:
                     # Find OMAP removals
                     removed_keys = local_state_keys - omap_state_keys
                     removed = {key: local_state_dict[key] for key in removed_keys}

    changed

    gbregman gbregman commented on code on May 02, 2026 12:08 UTC
    Code Review
    control/server.py:1
    @@ -1248,6 +1248,12 @@ def abort_server_on_update_error(rc: int, msg: str):
                                                 ignore_unknown_fields=True)
                         rc = self.gateway_rpc.remove_host(req)
                     abort_server_on_update_error(rc.status, rc.error_message)
    +            elif key.startswith(GatewayState.CONNECTED_HOST_PREFIX):
    +                if not is_add_req:
    +                    req = json_format.Parse(val, pb2.set_keep_host_connected_req(),
    +                                            ignore_unknown_fields=True)
    +                    rc = self.gateway_rpc.set_keep_host_connected(req)
    +                    abort_server_on_update_error(rc.status, rc.error_message)

    this was handled

    gbregman gbregman commented on code on May 02, 2026 12:10 UTC
    Code Review
    control/state.py:1
    @@ -306,6 +313,12 @@ def add_host(self, subsystem_nqn: str, host_nqn: str, val: str):
             key = GatewayState.build_host_key(subsystem_nqn, host_nqn)
             self._add_key(key, val)
     
    +        # no need in connected host indication for this host
    +        state = self.get_state()
    +        for key in list(state.keys()):
    +            if key == GatewayState.build_connected_host_key(subsystem_nqn, host_nqn):
    +                self._remove_key(key)

    changed

    gbregman gbregman commented on code on May 02, 2026 12:13 UTC
    Code Review
    control/grpc.py:1
    @@ -5756,6 +5786,8 @@ def add_host_safe(self, request, context):
                             request, preserving_proto_field_name=True,
                             including_default_value_fields=True)
                         self.gateway_state.add_host(request.subsystem_nqn, request.host_nqn, json_req)
    +                    self.gateway_state.remove_connected_host(request.subsystem_nqn,
    +                                                             request.host_nqn)

    changed

    gbregman gbregman commented on code on May 02, 2026 12:13 UTC
    Code Review
    tests/ha/keep_connection.sh:1
    @@ -0,0 +1,314 @@
    +#!/bin/bash
    +
    +. .env
    +set -e
    +set -x
    +
    +rpc=/usr/libexec/spdk/scripts/rpc.py
    +GW1_NAME=$(docker ps --format '{{.ID}}\t{{.Names}}' | awk '$2 ~ /nvmeof/ && $2 ~ /1/ {print $1}')
    +GW2_NAME=$(docker ps --format '{{.ID}}\t{{.Names}}' | awk '$2 ~ /nvmeof/ && $2 ~ /2/ {print $1}')
    +ip1="$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$GW1_NAME")"
    +ip2="$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$GW2_NAME")"
    +
    +function cephnvmf_func1()
    +{
    +    /usr/bin/docker compose run --rm nvmeof-cli --server-address ${ip1} --server-port ${NVMEOF_GW_PORT} $@
    +}
    +
    +function cephnvmf_func2()
    +{
    +    /usr/bin/docker compose run --rm nvmeof-cli --server-address ${ip2} --server-port ${NVMEOF_GW_PORT} $@
    +}
    +
    +echo "ℹ️  Starting bdevperf container"
    +docker compose up -d bdevperf
    +sleep 10
    +make logs SVC=bdevperf
    +BDEVPERF_SOCKET_LINE="$(make run SVC=bdevperf OPTS="--entrypoint=env" | grep BDEVPERF_SOCKET | tr -d '\n\r')"
    +BDEVPERF_SOCKET="${BDEVPERF_SOCKET_LINE#BDEVPERF_SOCKET=}"
    +make exec SVC=bdevperf OPTS=-T CMD="$rpc -v -s $BDEVPERF_SOCKET bdev_nvme_set_options -r -1"
    +
    +echo "ℹ️  Create resources"
    +cephnvmf_func1 listener add --subsystem ${NQN} --host-name ${GW1_NAME} --traddr $ip1 --trsvcid 4430
    +cephnvmf_func2 listener add --subsystem ${NQN} --host-name ${GW2_NAME} --traddr $ip2 --trsvcid 4430
    +/usr/bin/docker compose run --rm nvmeof-cli --server-address ${ip1} --server-port ${NVMEOF_GW_PORT} host del --subsystem ${NQN} --host-nqn "*"
    +cephnvmf_func1 namespace del --subsystem ${NQN} --nsid 2
    +cephnvmf_func1 host add --subsystem ${NQN} --host-nqn ${NQN}host1
    +sleep 20
    +
    +echo "ℹ️  Connect"
    +devs=`make -s exec SVC=bdevperf OPTS=-T CMD="$rpc -v -s $BDEVPERF_SOCKET bdev_nvme_attach_controller -b Nvme0 -t tcp -a $ip1 -s 4420 -f ipv4 -n $NQN -q ${NQN}host1 -l -1 -o 10"`
    +[[ "$devs" == "Nvme0n1" ]]
    +
    +echo "ℹ️  Verify connection"
    +conns=$(cephnvmf_func1 --output stdio --format json connection list --subsystem $NQN)
    +[[ `echo $conns | jq -r '.status'` == "0" ]]
    +[[ `echo $conns | jq -r '.subsystem_nqn'` == "${NQN}" ]]
    +[[ `echo $conns | jq -r '.connections[0].nqn'` == "${NQN}host1" ]]
    +[[ `echo $conns | jq -r '.connections[0].trsvcid'` == "4420" ]]
    +[[ `echo $conns | jq -r '.connections[0].traddr'` == "${ip1}" ]]
    +[[ `echo $conns | jq -r '.connections[0].adrfam'` == "ipv4" ]]
    +[[ `echo $conns | jq -r '.connections[0].trtype'` == "TCP" ]]
    +[[ `echo $conns | jq -r '.connections[0].connected'` == "true" ]]
    +[[ `echo $conns | jq -r '.connections[0].qpairs_count'` == "1" ]]
    +[[ `echo $conns | jq -r '.connections[0].secure'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[0].use_psk'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[0].use_dhchap'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[0].dhchap_controller_origin'` == "no_key" ]]
    +[[ `echo $conns | jq -r '.connections[0].subsystem'` == "${NQN}" ]]
    +[[ `echo $conns | jq -r '.connections[0].host_deleted'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[1]'` == "null" ]]
    +
    +echo "ℹ️  Verify OMAP before host delete"
    +set +e
    +    make -s exec SVC=ceph OPTS=-T CMD="rados --pool rbd listomapvals nvmeof.state" | grep "connected-del-host"
    +    if [[ $? -eq 0 ]]; then
    +        echo "Shouldn't have connected host entry in OMAP before we delete the host"
    +        exit 1
    +    fi
    +set -e
    +
    +echo "ℹ️  Delete host and keep connection"
    +cephnvmf_func1 host del --subsystem ${NQN} --host-nqn ${NQN}host1 --keep-connections
    +sleep 25
    +grep "Received request to remove host ${NQN}host1 access from ${NQN}, force: False, keep connections: True, context: <grpc._server" /var/log/ceph/nvmeof-$GW1_NAME/nvmeof-log
    +grep "Received request to remove host ${NQN}host1 access from ${NQN}, force: False, keep connections: True, context: None" /var/log/ceph/nvmeof-$GW2_NAME/nvmeof-log

    this is OK

    Copilot Copilot commented on code on May 02, 2026 12:19 UTC
    Code Review
    control/grpc.py:1
    @@ -5913,6 +5962,26 @@ def remove_host_safe(self, request, context):
                     self.remove_host_from_state(request.subsystem_nqn, request.host_nqn, context)
                     return pb2.req_status(status=errno.EINVAL, error_message=errmsg)
     
    +            if context:
    +                try:
    +                    if request.keep_connections:
    +                        set_connected_req = pb2.set_keep_host_connected_req(
    +                            subsystem_nqn=request.subsystem_nqn,
    +                            host_nqn=request.host_nqn)
    +                        json_req = json_format.MessageToJson(
    +                            set_connected_req, preserving_proto_field_name=True,
    +                            including_default_value_fields=True)
    +                        self.gateway_state.add_connected_host(request.subsystem_nqn,
    +                                                              request.host_nqn,
    +                                                              json_req)
    +                    else:
    +                        self.gateway_state.remove_connected_host(request.subsystem_nqn,
    +                                                                 request.host_nqn)
    +                        self.host_info.reset_connected_host_indication(request.subsystem_nqn,
    +                                                                       request.host_nqn)

    In remove_host_safe(), the decision to persist the CONNECTED_HOST_PREFIX/"keep host connected" indication is based on request.keep_connections, but the actual behavior is controlled by keep_conn (which is forced to False when the host isn’t currently connected). This can leave stale connected-del-host_* keys in OMAP even when there were no connections to keep (and can cause other gateways to set the in-memory indication unnecessarily, including on restart when no matching host removal follows). Use the effective keep_conn when deciding whether to add/remove the connected-host indication (and consider logging the effective value as well).

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on May 02, 2026 12:19 UTC
    Reviewer

    Pull request overview

    Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

    ---

    💡 <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>.

    gbregman gbregman commented on code on May 02, 2026 15:57 UTC
    Code Review
    control/grpc.py:1
    @@ -5913,6 +5962,26 @@ def remove_host_safe(self, request, context):
                     self.remove_host_from_state(request.subsystem_nqn, request.host_nqn, context)
                     return pb2.req_status(status=errno.EINVAL, error_message=errmsg)
     
    +            if context:
    +                try:
    +                    if request.keep_connections:
    +                        set_connected_req = pb2.set_keep_host_connected_req(
    +                            subsystem_nqn=request.subsystem_nqn,
    +                            host_nqn=request.host_nqn)
    +                        json_req = json_format.MessageToJson(
    +                            set_connected_req, preserving_proto_field_name=True,
    +                            including_default_value_fields=True)
    +                        self.gateway_state.add_connected_host(request.subsystem_nqn,
    +                                                              request.host_nqn,
    +                                                              json_req)
    +                    else:
    +                        self.gateway_state.remove_connected_host(request.subsystem_nqn,
    +                                                                 request.host_nqn)
    +                        self.host_info.reset_connected_host_indication(request.subsystem_nqn,
    +                                                                       request.host_nqn)

    This is OK. We only set the OMAP in one gateway. This gateway might not be connected to the host while another gateway is.

    Copilot Copilot commented on code on May 02, 2026 16:09 UTC
    Code Review
    control/grpc.py:1
    @@ -5956,6 +6025,17 @@ def remove_host(self, request, context=None):
                          f"from {request.subsystem_nqn}: "
             return self.execute_grpc_function(self.remove_host_safe, request, context, err_prefix)
     
    +    def set_keep_host_connected(self, request, context=None):
    +        """Set a connected host indication ."""

    Minor docstring formatting: there’s an extra space before the period in "Set a connected host indication .". Consider tightening it to avoid stray whitespace in generated docs/help.

    Copilot Copilot commented on code on May 02, 2026 16:09 UTC
    Code Review
    control/state.py:1
    @@ -306,6 +313,12 @@ def add_host(self, subsystem_nqn: str, host_nqn: str, val: str):
             key = GatewayState.build_host_key(subsystem_nqn, host_nqn)
             self._add_key(key, val)
     
    +        # no need in connected host indication for this host
    +        state = self.get_state()
    +        key = GatewayState.build_connected_host_key(subsystem_nqn, host_nqn)
    +        if key in state.keys():
    +            self._remove_key(key)

    if key in state.keys() is equivalent to if key in state but does an extra keys-view lookup and is less idiomatic. Since this code runs on every host add / connected-host cleanup, prefer if key in state: here (and similarly in remove_connected_host).

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on May 02, 2026 16:09 UTC
    Reviewer

    Pull request overview

    Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

    ---

    💡 <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>.

    gbregman gbregman commented on code on May 02, 2026 17:05 UTC
    Code Review
    control/grpc.py:1
    @@ -5956,6 +6025,17 @@ def remove_host(self, request, context=None):
                          f"from {request.subsystem_nqn}: "
             return self.execute_grpc_function(self.remove_host_safe, request, context, err_prefix)
     
    +    def set_keep_host_connected(self, request, context=None):
    +        """Set a connected host indication ."""

    changed

    gbregman gbregman commented on code on May 02, 2026 17:06 UTC
    Code Review
    control/state.py:1
    @@ -306,6 +313,12 @@ def add_host(self, subsystem_nqn: str, host_nqn: str, val: str):
             key = GatewayState.build_host_key(subsystem_nqn, host_nqn)
             self._add_key(key, val)
     
    +        # no need in connected host indication for this host
    +        state = self.get_state()
    +        key = GatewayState.build_connected_host_key(subsystem_nqn, host_nqn)
    +        if key in state.keys():
    +            self._remove_key(key)

    changed

    Copilot Copilot commented on code on May 02, 2026 17:14 UTC
    Code Review
    tests/ha/keep_connection.sh:1
    @@ -0,0 +1,314 @@
    +#!/bin/bash
    +
    +. .env
    +set -e
    +set -x
    +
    +rpc=/usr/libexec/spdk/scripts/rpc.py
    +GW1_NAME=$(docker ps --format '{{.ID}}\t{{.Names}}' | awk '$2 ~ /nvmeof/ && $2 ~ /1/ {print $1}')
    +GW2_NAME=$(docker ps --format '{{.ID}}\t{{.Names}}' | awk '$2 ~ /nvmeof/ && $2 ~ /2/ {print $1}')
    +ip1="$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$GW1_NAME")"
    +ip2="$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$GW2_NAME")"
    +
    +function cephnvmf_func1()
    +{
    +    /usr/bin/docker compose run --rm nvmeof-cli --server-address ${ip1} --server-port ${NVMEOF_GW_PORT} $@
    +}
    +
    +function cephnvmf_func2()
    +{
    +    /usr/bin/docker compose run --rm nvmeof-cli --server-address ${ip2} --server-port ${NVMEOF_GW_PORT} $@
    +}
    +
    +echo "ℹ️  Starting bdevperf container"
    +docker compose up -d bdevperf
    +sleep 10
    +make logs SVC=bdevperf
    +BDEVPERF_SOCKET_LINE="$(make run SVC=bdevperf OPTS="--entrypoint=env" | grep BDEVPERF_SOCKET | tr -d '\n\r')"
    +BDEVPERF_SOCKET="${BDEVPERF_SOCKET_LINE#BDEVPERF_SOCKET=}"
    +make exec SVC=bdevperf OPTS=-T CMD="$rpc -v -s $BDEVPERF_SOCKET bdev_nvme_set_options -r -1"
    +
    +echo "ℹ️  Create resources"
    +cephnvmf_func1 listener add --subsystem ${NQN} --host-name ${GW1_NAME} --traddr $ip1 --trsvcid 4430
    +cephnvmf_func2 listener add --subsystem ${NQN} --host-name ${GW2_NAME} --traddr $ip2 --trsvcid 4430
    +/usr/bin/docker compose run --rm nvmeof-cli --server-address ${ip1} --server-port ${NVMEOF_GW_PORT} host del --subsystem ${NQN} --host-nqn "*"
    +cephnvmf_func1 namespace del --subsystem ${NQN} --nsid 2
    +cephnvmf_func1 host add --subsystem ${NQN} --host-nqn ${NQN}host1
    +sleep 20
    +
    +echo "ℹ️  Connect"
    +devs=`make -s exec SVC=bdevperf OPTS=-T CMD="$rpc -v -s $BDEVPERF_SOCKET bdev_nvme_attach_controller -b Nvme0 -t tcp -a $ip1 -s 4420 -f ipv4 -n $NQN -q ${NQN}host1 -l -1 -o 10"`
    +[[ "$devs" == "Nvme0n1" ]]
    +
    +echo "ℹ️  Verify connection"
    +conns=$(cephnvmf_func1 --output stdio --format json connection list --subsystem $NQN)
    +[[ `echo $conns | jq -r '.status'` == "0" ]]
    +[[ `echo $conns | jq -r '.subsystem_nqn'` == "${NQN}" ]]
    +[[ `echo $conns | jq -r '.connections[0].nqn'` == "${NQN}host1" ]]
    +[[ `echo $conns | jq -r '.connections[0].trsvcid'` == "4420" ]]
    +[[ `echo $conns | jq -r '.connections[0].traddr'` == "${ip1}" ]]
    +[[ `echo $conns | jq -r '.connections[0].adrfam'` == "ipv4" ]]
    +[[ `echo $conns | jq -r '.connections[0].trtype'` == "TCP" ]]
    +[[ `echo $conns | jq -r '.connections[0].connected'` == "true" ]]
    +[[ `echo $conns | jq -r '.connections[0].qpairs_count'` == "1" ]]
    +[[ `echo $conns | jq -r '.connections[0].secure'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[0].use_psk'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[0].use_dhchap'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[0].dhchap_controller_origin'` == "no_key" ]]
    +[[ `echo $conns | jq -r '.connections[0].subsystem'` == "${NQN}" ]]
    +[[ `echo $conns | jq -r '.connections[0].host_deleted'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[1]'` == "null" ]]
    +
    +echo "ℹ️  Verify OMAP before host delete"
    +set +e
    +    make -s exec SVC=ceph OPTS=-T CMD="rados --pool rbd listomapvals nvmeof.state" | grep "connected-del-host"
    +    if [[ $? -eq 0 ]]; then
    +        echo "Shouldn't have connected host entry in OMAP before we delete the host"
    +        exit 1
    +    fi
    +set -e
    +
    +echo "ℹ️  Delete host and keep connection"
    +cephnvmf_func1 host del --subsystem ${NQN} --host-nqn ${NQN}host1 --keep-connections
    +sleep 25
    +grep "Received request to remove host ${NQN}host1 access from ${NQN}, force: False, keep connections: True, context: <grpc._server" /var/log/ceph/nvmeof-$GW1_NAME/nvmeof-log
    +grep "Received request to remove host ${NQN}host1 access from ${NQN}, force: False, keep connections: True, context: None" /var/log/ceph/nvmeof-$GW2_NAME/nvmeof-log
    +
    +echo "ℹ️  Verify connection after host delete"
    +conns=$(cephnvmf_func1 --output stdio --format json connection list --subsystem $NQN)
    +[[ `echo $conns | jq -r '.status'` == "0" ]]
    +[[ `echo $conns | jq -r '.subsystem_nqn'` == "${NQN}" ]]
    +[[ `echo $conns | jq -r '.connections[0].nqn'` == "${NQN}host1" ]]
    +[[ `echo $conns | jq -r '.connections[0].trsvcid'` == "4420" ]]
    +[[ `echo $conns | jq -r '.connections[0].traddr'` == "${ip1}" ]]
    +[[ `echo $conns | jq -r '.connections[0].adrfam'` == "ipv4" ]]
    +[[ `echo $conns | jq -r '.connections[0].trtype'` == "TCP" ]]
    +[[ `echo $conns | jq -r '.connections[0].connected'` == "true" ]]
    +[[ `echo $conns | jq -r '.connections[0].qpairs_count'` == "1" ]]
    +[[ `echo $conns | jq -r '.connections[0].secure'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[0].use_psk'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[0].use_dhchap'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[0].dhchap_controller_origin'` == "no_key" ]]
    +[[ `echo $conns | jq -r '.connections[0].subsystem'` == "${NQN}" ]]
    +[[ `echo $conns | jq -r '.connections[0].host_deleted'` == "true" ]]
    +[[ `echo $conns | jq -r '.connections[1]'` == "null" ]]
    +
    +echo "ℹ️  Verify OMAP after host delete"
    +make -s exec SVC=ceph OPTS=-T CMD="rados --pool rbd listomapvals nvmeof.state" | grep "connected-del-host"
    +
    +echo "ℹ️  Verify host list is empty after host delete"
    +hosts=$(cephnvmf_func1 --output stdio --format json host list --subsystem $NQN)
    +[[ `echo $hosts | jq -r '.status'` == "0" ]]
    +[[ `echo $hosts | jq -r '.hosts[1]'` == "null" ]]
    +
    +echo "ℹ️  Connect after host delete"
    +set +e
    +    make -s exec SVC=bdevperf OPTS=-T CMD="$rpc -v -s $BDEVPERF_SOCKET bdev_nvme_attach_controller -b Nvme1 -t tcp -a $ip1 -s 4430 -f ipv4 -n $NQN -q ${NQN}host1 -l -1 -o 10"
    +    if [[ $? -eq 0 ]]; then
    +        echo "Connection should fail after host delete"
    +        exit 1
    +    fi
    +set -e
    +
    +echo "ℹ️  Verify connection was unsuccessful"
    +conns=$(cephnvmf_func1 --output stdio --format json connection list --subsystem $NQN)
    +[[ `echo $conns | jq -r '.status'` == "0" ]]
    +[[ `echo $conns | jq -r '.subsystem_nqn'` == "${NQN}" ]]
    +[[ `echo $conns | jq -r '.connections[0].nqn'` == "${NQN}host1" ]]
    +[[ `echo $conns | jq -r '.connections[0].trsvcid'` == "4420" ]]
    +[[ `echo $conns | jq -r '.connections[0].traddr'` == "${ip1}" ]]
    +[[ `echo $conns | jq -r '.connections[0].adrfam'` == "ipv4" ]]
    +[[ `echo $conns | jq -r '.connections[0].trtype'` == "TCP" ]]
    +[[ `echo $conns | jq -r '.connections[0].connected'` == "true" ]]
    +[[ `echo $conns | jq -r '.connections[0].qpairs_count'` == "1" ]]
    +[[ `echo $conns | jq -r '.connections[0].secure'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[0].use_psk'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[0].use_dhchap'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[0].dhchap_controller_origin'` == "no_key" ]]
    +[[ `echo $conns | jq -r '.connections[0].subsystem'` == "${NQN}" ]]
    +[[ `echo $conns | jq -r '.connections[0].host_deleted'` == "true" ]]
    +[[ `echo $conns | jq -r '.connections[1]'` == "null" ]]
    +
    +echo "ℹ️  Re-add host"
    +cephnvmf_func1 host add --subsystem ${NQN} --host-nqn ${NQN}host1
    +sleep 20
    +
    +echo "ℹ️  Verify OMAP after host re-add"
    +set +e
    +    make -s exec SVC=ceph OPTS=-T CMD="rados --pool rbd listomapvals nvmeof.state" | grep "connected-del-host"
    +    if [[ $? -eq 0 ]]; then
    +        echo "Shouldn't have connected host entry in OMAP after we re-add the host"
    +        exit 1
    +    fi
    +set -e
    +
    +echo "ℹ️  Verify host list after host re-add"
    +hosts=$(cephnvmf_func1 --output stdio --format json host list --subsystem $NQN)
    +[[ `echo $hosts | jq -r '.status'` == "0" ]]
    +[[ `echo $hosts | jq -r '.subsystem_nqn'` == "$NQN" ]]
    +[[ `echo $hosts | jq -r '.hosts[0].nqn'` == "${NQN}host1" ]]
    +[[ `echo $hosts | jq -r '.hosts[1]'` == "null" ]]
    +
    +echo "ℹ️  Connect after host re-add"
    +make -s exec SVC=bdevperf OPTS=-T CMD="$rpc -v -s $BDEVPERF_SOCKET bdev_nvme_attach_controller -b Nvme1 -t tcp -a $ip1 -s 4430 -f ipv4 -n $NQN -q ${NQN}host1 -l -1 -o 10"
    +
    +echo "ℹ️  Verify connection list after re-add and second connect"
    +conns=$(cephnvmf_func1 --output stdio --format json connection list --subsystem $NQN)
    +[[ `echo $conns | jq -r '.status'` == "0" ]]
    +[[ `echo $conns | jq -r '.subsystem_nqn'` == "${NQN}" ]]
    +[[ `echo $conns | jq -r '.connections[0].nqn'` == "${NQN}host1" ]]
    +[[ `echo $conns | jq -r '.connections[0].trsvcid'` == "4420" ]]
    +[[ `echo $conns | jq -r '.connections[0].traddr'` == "${ip1}" ]]
    +[[ `echo $conns | jq -r '.connections[0].adrfam'` == "ipv4" ]]
    +[[ `echo $conns | jq -r '.connections[0].trtype'` == "TCP" ]]
    +[[ `echo $conns | jq -r '.connections[0].connected'` == "true" ]]
    +[[ `echo $conns | jq -r '.connections[0].qpairs_count'` == "1" ]]
    +[[ `echo $conns | jq -r '.connections[0].secure'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[0].use_psk'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[0].use_dhchap'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[0].dhchap_controller_origin'` == "no_key" ]]
    +[[ `echo $conns | jq -r '.connections[0].subsystem'` == "${NQN}" ]]
    +[[ `echo $conns | jq -r '.connections[0].host_deleted'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[1].nqn'` == "${NQN}host1" ]]
    +[[ `echo $conns | jq -r '.connections[1].trsvcid'` == "4430" ]]
    +[[ `echo $conns | jq -r '.connections[1].traddr'` == "${ip1}" ]]
    +[[ `echo $conns | jq -r '.connections[1].adrfam'` == "ipv4" ]]
    +[[ `echo $conns | jq -r '.connections[1].trtype'` == "TCP" ]]
    +[[ `echo $conns | jq -r '.connections[1].connected'` == "true" ]]
    +[[ `echo $conns | jq -r '.connections[1].qpairs_count'` == "1" ]]
    +[[ `echo $conns | jq -r '.connections[1].secure'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[1].use_psk'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[1].use_dhchap'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[1].dhchap_controller_origin'` == "no_key" ]]
    +[[ `echo $conns | jq -r '.connections[1].subsystem'` == "${NQN}" ]]
    +[[ `echo $conns | jq -r '.connections[1].host_deleted'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[2]'` == "null" ]]
    +
    +echo "ℹ️  Delete host and do not keep connection"
    +cephnvmf_func1 host del --subsystem ${NQN} --host-nqn ${NQN}host1
    +sleep 25
    +grep "Received request to remove host ${NQN}host1 access from ${NQN}, force: False, keep connections: False, context: <grpc._server" /var/log/ceph/nvmeof-$GW1_NAME/nvmeof-log
    +grep "Received request to remove host ${NQN}host1 access from ${NQN}, force: False, keep connections: False, context: None" /var/log/ceph/nvmeof-$GW2_NAME/nvmeof-log
    +
    +echo "ℹ️  Verify OMAP after second host delete"
    +set +e
    +    make -s exec SVC=ceph OPTS=-T CMD="rados --pool rbd listomapvals nvmeof.state" | grep "connected-del-host"
    +    if [[ $? -eq 0 ]]; then
    +        echo "Shouldn't have connected host entry in OMAP after we deleted the host without keep-connections"
    +        exit 1
    +    fi
    +set -e
    +
    +echo "ℹ️  Verify connection list is empty after second host delete"
    +conns=$(cephnvmf_func1 --output stdio --format json connection list --subsystem $NQN)
    +[[ `echo $conns | jq -r '.status'` == "0" ]]
    +[[ `echo $conns | jq -r '.connections[1]'` == "null" ]]

    The “Verify connection list is empty after second host delete” assertion checks .connections[1] == null, which can still pass if one connection remains at index 0. To ensure the list is empty, assert .connections[0] is null (or use .connections | length == 0).

    Copilot Copilot commented on code on May 02, 2026 17:14 UTC
    Code Review
    tests/ha/keep_connection.sh:1
    @@ -0,0 +1,314 @@
    +#!/bin/bash
    +
    +. .env
    +set -e
    +set -x
    +
    +rpc=/usr/libexec/spdk/scripts/rpc.py
    +GW1_NAME=$(docker ps --format '{{.ID}}\t{{.Names}}' | awk '$2 ~ /nvmeof/ && $2 ~ /1/ {print $1}')
    +GW2_NAME=$(docker ps --format '{{.ID}}\t{{.Names}}' | awk '$2 ~ /nvmeof/ && $2 ~ /2/ {print $1}')
    +ip1="$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$GW1_NAME")"
    +ip2="$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$GW2_NAME")"
    +
    +function cephnvmf_func1()
    +{
    +    /usr/bin/docker compose run --rm nvmeof-cli --server-address ${ip1} --server-port ${NVMEOF_GW_PORT} $@
    +}
    +
    +function cephnvmf_func2()
    +{
    +    /usr/bin/docker compose run --rm nvmeof-cli --server-address ${ip2} --server-port ${NVMEOF_GW_PORT} $@
    +}
    +
    +echo "ℹ️  Starting bdevperf container"
    +docker compose up -d bdevperf
    +sleep 10
    +make logs SVC=bdevperf
    +BDEVPERF_SOCKET_LINE="$(make run SVC=bdevperf OPTS="--entrypoint=env" | grep BDEVPERF_SOCKET | tr -d '\n\r')"
    +BDEVPERF_SOCKET="${BDEVPERF_SOCKET_LINE#BDEVPERF_SOCKET=}"
    +make exec SVC=bdevperf OPTS=-T CMD="$rpc -v -s $BDEVPERF_SOCKET bdev_nvme_set_options -r -1"
    +
    +echo "ℹ️  Create resources"
    +cephnvmf_func1 listener add --subsystem ${NQN} --host-name ${GW1_NAME} --traddr $ip1 --trsvcid 4430
    +cephnvmf_func2 listener add --subsystem ${NQN} --host-name ${GW2_NAME} --traddr $ip2 --trsvcid 4430
    +/usr/bin/docker compose run --rm nvmeof-cli --server-address ${ip1} --server-port ${NVMEOF_GW_PORT} host del --subsystem ${NQN} --host-nqn "*"
    +cephnvmf_func1 namespace del --subsystem ${NQN} --nsid 2
    +cephnvmf_func1 host add --subsystem ${NQN} --host-nqn ${NQN}host1
    +sleep 20
    +
    +echo "ℹ️  Connect"
    +devs=`make -s exec SVC=bdevperf OPTS=-T CMD="$rpc -v -s $BDEVPERF_SOCKET bdev_nvme_attach_controller -b Nvme0 -t tcp -a $ip1 -s 4420 -f ipv4 -n $NQN -q ${NQN}host1 -l -1 -o 10"`
    +[[ "$devs" == "Nvme0n1" ]]
    +
    +echo "ℹ️  Verify connection"
    +conns=$(cephnvmf_func1 --output stdio --format json connection list --subsystem $NQN)
    +[[ `echo $conns | jq -r '.status'` == "0" ]]
    +[[ `echo $conns | jq -r '.subsystem_nqn'` == "${NQN}" ]]
    +[[ `echo $conns | jq -r '.connections[0].nqn'` == "${NQN}host1" ]]
    +[[ `echo $conns | jq -r '.connections[0].trsvcid'` == "4420" ]]
    +[[ `echo $conns | jq -r '.connections[0].traddr'` == "${ip1}" ]]
    +[[ `echo $conns | jq -r '.connections[0].adrfam'` == "ipv4" ]]
    +[[ `echo $conns | jq -r '.connections[0].trtype'` == "TCP" ]]
    +[[ `echo $conns | jq -r '.connections[0].connected'` == "true" ]]
    +[[ `echo $conns | jq -r '.connections[0].qpairs_count'` == "1" ]]
    +[[ `echo $conns | jq -r '.connections[0].secure'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[0].use_psk'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[0].use_dhchap'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[0].dhchap_controller_origin'` == "no_key" ]]
    +[[ `echo $conns | jq -r '.connections[0].subsystem'` == "${NQN}" ]]
    +[[ `echo $conns | jq -r '.connections[0].host_deleted'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[1]'` == "null" ]]
    +
    +echo "ℹ️  Verify OMAP before host delete"
    +set +e
    +    make -s exec SVC=ceph OPTS=-T CMD="rados --pool rbd listomapvals nvmeof.state" | grep "connected-del-host"
    +    if [[ $? -eq 0 ]]; then
    +        echo "Shouldn't have connected host entry in OMAP before we delete the host"
    +        exit 1
    +    fi
    +set -e
    +
    +echo "ℹ️  Delete host and keep connection"
    +cephnvmf_func1 host del --subsystem ${NQN} --host-nqn ${NQN}host1 --keep-connections
    +sleep 25
    +grep "Received request to remove host ${NQN}host1 access from ${NQN}, force: False, keep connections: True, context: <grpc._server" /var/log/ceph/nvmeof-$GW1_NAME/nvmeof-log
    +grep "Received request to remove host ${NQN}host1 access from ${NQN}, force: False, keep connections: True, context: None" /var/log/ceph/nvmeof-$GW2_NAME/nvmeof-log
    +
    +echo "ℹ️  Verify connection after host delete"
    +conns=$(cephnvmf_func1 --output stdio --format json connection list --subsystem $NQN)
    +[[ `echo $conns | jq -r '.status'` == "0" ]]
    +[[ `echo $conns | jq -r '.subsystem_nqn'` == "${NQN}" ]]
    +[[ `echo $conns | jq -r '.connections[0].nqn'` == "${NQN}host1" ]]
    +[[ `echo $conns | jq -r '.connections[0].trsvcid'` == "4420" ]]
    +[[ `echo $conns | jq -r '.connections[0].traddr'` == "${ip1}" ]]
    +[[ `echo $conns | jq -r '.connections[0].adrfam'` == "ipv4" ]]
    +[[ `echo $conns | jq -r '.connections[0].trtype'` == "TCP" ]]
    +[[ `echo $conns | jq -r '.connections[0].connected'` == "true" ]]
    +[[ `echo $conns | jq -r '.connections[0].qpairs_count'` == "1" ]]
    +[[ `echo $conns | jq -r '.connections[0].secure'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[0].use_psk'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[0].use_dhchap'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[0].dhchap_controller_origin'` == "no_key" ]]
    +[[ `echo $conns | jq -r '.connections[0].subsystem'` == "${NQN}" ]]
    +[[ `echo $conns | jq -r '.connections[0].host_deleted'` == "true" ]]
    +[[ `echo $conns | jq -r '.connections[1]'` == "null" ]]
    +
    +echo "ℹ️  Verify OMAP after host delete"
    +make -s exec SVC=ceph OPTS=-T CMD="rados --pool rbd listomapvals nvmeof.state" | grep "connected-del-host"
    +
    +echo "ℹ️  Verify host list is empty after host delete"
    +hosts=$(cephnvmf_func1 --output stdio --format json host list --subsystem $NQN)
    +[[ `echo $hosts | jq -r '.status'` == "0" ]]
    +[[ `echo $hosts | jq -r '.hosts[1]'` == "null" ]]

    The “Verify host list is empty after host delete” assertion checks .hosts[1] == null, which will still pass if there is exactly one remaining host entry at index 0. To actually verify the list is empty, check .hosts[0] is null (or assert .hosts | length == 0).

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on May 02, 2026 17:14 UTC
    Reviewer

    Pull request overview

    Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

    ---

    💡 <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>.

    gbregman gbregman commented on code on May 02, 2026 17:27 UTC
    Code Review
    tests/ha/keep_connection.sh:1
    @@ -0,0 +1,314 @@
    +#!/bin/bash
    +
    +. .env
    +set -e
    +set -x
    +
    +rpc=/usr/libexec/spdk/scripts/rpc.py
    +GW1_NAME=$(docker ps --format '{{.ID}}\t{{.Names}}' | awk '$2 ~ /nvmeof/ && $2 ~ /1/ {print $1}')
    +GW2_NAME=$(docker ps --format '{{.ID}}\t{{.Names}}' | awk '$2 ~ /nvmeof/ && $2 ~ /2/ {print $1}')
    +ip1="$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$GW1_NAME")"
    +ip2="$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$GW2_NAME")"
    +
    +function cephnvmf_func1()
    +{
    +    /usr/bin/docker compose run --rm nvmeof-cli --server-address ${ip1} --server-port ${NVMEOF_GW_PORT} $@
    +}
    +
    +function cephnvmf_func2()
    +{
    +    /usr/bin/docker compose run --rm nvmeof-cli --server-address ${ip2} --server-port ${NVMEOF_GW_PORT} $@
    +}
    +
    +echo "ℹ️  Starting bdevperf container"
    +docker compose up -d bdevperf
    +sleep 10
    +make logs SVC=bdevperf
    +BDEVPERF_SOCKET_LINE="$(make run SVC=bdevperf OPTS="--entrypoint=env" | grep BDEVPERF_SOCKET | tr -d '\n\r')"
    +BDEVPERF_SOCKET="${BDEVPERF_SOCKET_LINE#BDEVPERF_SOCKET=}"
    +make exec SVC=bdevperf OPTS=-T CMD="$rpc -v -s $BDEVPERF_SOCKET bdev_nvme_set_options -r -1"
    +
    +echo "ℹ️  Create resources"
    +cephnvmf_func1 listener add --subsystem ${NQN} --host-name ${GW1_NAME} --traddr $ip1 --trsvcid 4430
    +cephnvmf_func2 listener add --subsystem ${NQN} --host-name ${GW2_NAME} --traddr $ip2 --trsvcid 4430
    +/usr/bin/docker compose run --rm nvmeof-cli --server-address ${ip1} --server-port ${NVMEOF_GW_PORT} host del --subsystem ${NQN} --host-nqn "*"
    +cephnvmf_func1 namespace del --subsystem ${NQN} --nsid 2
    +cephnvmf_func1 host add --subsystem ${NQN} --host-nqn ${NQN}host1
    +sleep 20
    +
    +echo "ℹ️  Connect"
    +devs=`make -s exec SVC=bdevperf OPTS=-T CMD="$rpc -v -s $BDEVPERF_SOCKET bdev_nvme_attach_controller -b Nvme0 -t tcp -a $ip1 -s 4420 -f ipv4 -n $NQN -q ${NQN}host1 -l -1 -o 10"`
    +[[ "$devs" == "Nvme0n1" ]]
    +
    +echo "ℹ️  Verify connection"
    +conns=$(cephnvmf_func1 --output stdio --format json connection list --subsystem $NQN)
    +[[ `echo $conns | jq -r '.status'` == "0" ]]
    +[[ `echo $conns | jq -r '.subsystem_nqn'` == "${NQN}" ]]
    +[[ `echo $conns | jq -r '.connections[0].nqn'` == "${NQN}host1" ]]
    +[[ `echo $conns | jq -r '.connections[0].trsvcid'` == "4420" ]]
    +[[ `echo $conns | jq -r '.connections[0].traddr'` == "${ip1}" ]]
    +[[ `echo $conns | jq -r '.connections[0].adrfam'` == "ipv4" ]]
    +[[ `echo $conns | jq -r '.connections[0].trtype'` == "TCP" ]]
    +[[ `echo $conns | jq -r '.connections[0].connected'` == "true" ]]
    +[[ `echo $conns | jq -r '.connections[0].qpairs_count'` == "1" ]]
    +[[ `echo $conns | jq -r '.connections[0].secure'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[0].use_psk'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[0].use_dhchap'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[0].dhchap_controller_origin'` == "no_key" ]]
    +[[ `echo $conns | jq -r '.connections[0].subsystem'` == "${NQN}" ]]
    +[[ `echo $conns | jq -r '.connections[0].host_deleted'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[1]'` == "null" ]]
    +
    +echo "ℹ️  Verify OMAP before host delete"
    +set +e
    +    make -s exec SVC=ceph OPTS=-T CMD="rados --pool rbd listomapvals nvmeof.state" | grep "connected-del-host"
    +    if [[ $? -eq 0 ]]; then
    +        echo "Shouldn't have connected host entry in OMAP before we delete the host"
    +        exit 1
    +    fi
    +set -e
    +
    +echo "ℹ️  Delete host and keep connection"
    +cephnvmf_func1 host del --subsystem ${NQN} --host-nqn ${NQN}host1 --keep-connections
    +sleep 25
    +grep "Received request to remove host ${NQN}host1 access from ${NQN}, force: False, keep connections: True, context: <grpc._server" /var/log/ceph/nvmeof-$GW1_NAME/nvmeof-log
    +grep "Received request to remove host ${NQN}host1 access from ${NQN}, force: False, keep connections: True, context: None" /var/log/ceph/nvmeof-$GW2_NAME/nvmeof-log
    +
    +echo "ℹ️  Verify connection after host delete"
    +conns=$(cephnvmf_func1 --output stdio --format json connection list --subsystem $NQN)
    +[[ `echo $conns | jq -r '.status'` == "0" ]]
    +[[ `echo $conns | jq -r '.subsystem_nqn'` == "${NQN}" ]]
    +[[ `echo $conns | jq -r '.connections[0].nqn'` == "${NQN}host1" ]]
    +[[ `echo $conns | jq -r '.connections[0].trsvcid'` == "4420" ]]
    +[[ `echo $conns | jq -r '.connections[0].traddr'` == "${ip1}" ]]
    +[[ `echo $conns | jq -r '.connections[0].adrfam'` == "ipv4" ]]
    +[[ `echo $conns | jq -r '.connections[0].trtype'` == "TCP" ]]
    +[[ `echo $conns | jq -r '.connections[0].connected'` == "true" ]]
    +[[ `echo $conns | jq -r '.connections[0].qpairs_count'` == "1" ]]
    +[[ `echo $conns | jq -r '.connections[0].secure'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[0].use_psk'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[0].use_dhchap'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[0].dhchap_controller_origin'` == "no_key" ]]
    +[[ `echo $conns | jq -r '.connections[0].subsystem'` == "${NQN}" ]]
    +[[ `echo $conns | jq -r '.connections[0].host_deleted'` == "true" ]]
    +[[ `echo $conns | jq -r '.connections[1]'` == "null" ]]
    +
    +echo "ℹ️  Verify OMAP after host delete"
    +make -s exec SVC=ceph OPTS=-T CMD="rados --pool rbd listomapvals nvmeof.state" | grep "connected-del-host"
    +
    +echo "ℹ️  Verify host list is empty after host delete"
    +hosts=$(cephnvmf_func1 --output stdio --format json host list --subsystem $NQN)
    +[[ `echo $hosts | jq -r '.status'` == "0" ]]
    +[[ `echo $hosts | jq -r '.hosts[1]'` == "null" ]]
    +
    +echo "ℹ️  Connect after host delete"
    +set +e
    +    make -s exec SVC=bdevperf OPTS=-T CMD="$rpc -v -s $BDEVPERF_SOCKET bdev_nvme_attach_controller -b Nvme1 -t tcp -a $ip1 -s 4430 -f ipv4 -n $NQN -q ${NQN}host1 -l -1 -o 10"
    +    if [[ $? -eq 0 ]]; then
    +        echo "Connection should fail after host delete"
    +        exit 1
    +    fi
    +set -e
    +
    +echo "ℹ️  Verify connection was unsuccessful"
    +conns=$(cephnvmf_func1 --output stdio --format json connection list --subsystem $NQN)
    +[[ `echo $conns | jq -r '.status'` == "0" ]]
    +[[ `echo $conns | jq -r '.subsystem_nqn'` == "${NQN}" ]]
    +[[ `echo $conns | jq -r '.connections[0].nqn'` == "${NQN}host1" ]]
    +[[ `echo $conns | jq -r '.connections[0].trsvcid'` == "4420" ]]
    +[[ `echo $conns | jq -r '.connections[0].traddr'` == "${ip1}" ]]
    +[[ `echo $conns | jq -r '.connections[0].adrfam'` == "ipv4" ]]
    +[[ `echo $conns | jq -r '.connections[0].trtype'` == "TCP" ]]
    +[[ `echo $conns | jq -r '.connections[0].connected'` == "true" ]]
    +[[ `echo $conns | jq -r '.connections[0].qpairs_count'` == "1" ]]
    +[[ `echo $conns | jq -r '.connections[0].secure'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[0].use_psk'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[0].use_dhchap'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[0].dhchap_controller_origin'` == "no_key" ]]
    +[[ `echo $conns | jq -r '.connections[0].subsystem'` == "${NQN}" ]]
    +[[ `echo $conns | jq -r '.connections[0].host_deleted'` == "true" ]]
    +[[ `echo $conns | jq -r '.connections[1]'` == "null" ]]
    +
    +echo "ℹ️  Re-add host"
    +cephnvmf_func1 host add --subsystem ${NQN} --host-nqn ${NQN}host1
    +sleep 20
    +
    +echo "ℹ️  Verify OMAP after host re-add"
    +set +e
    +    make -s exec SVC=ceph OPTS=-T CMD="rados --pool rbd listomapvals nvmeof.state" | grep "connected-del-host"
    +    if [[ $? -eq 0 ]]; then
    +        echo "Shouldn't have connected host entry in OMAP after we re-add the host"
    +        exit 1
    +    fi
    +set -e
    +
    +echo "ℹ️  Verify host list after host re-add"
    +hosts=$(cephnvmf_func1 --output stdio --format json host list --subsystem $NQN)
    +[[ `echo $hosts | jq -r '.status'` == "0" ]]
    +[[ `echo $hosts | jq -r '.subsystem_nqn'` == "$NQN" ]]
    +[[ `echo $hosts | jq -r '.hosts[0].nqn'` == "${NQN}host1" ]]
    +[[ `echo $hosts | jq -r '.hosts[1]'` == "null" ]]
    +
    +echo "ℹ️  Connect after host re-add"
    +make -s exec SVC=bdevperf OPTS=-T CMD="$rpc -v -s $BDEVPERF_SOCKET bdev_nvme_attach_controller -b Nvme1 -t tcp -a $ip1 -s 4430 -f ipv4 -n $NQN -q ${NQN}host1 -l -1 -o 10"
    +
    +echo "ℹ️  Verify connection list after re-add and second connect"
    +conns=$(cephnvmf_func1 --output stdio --format json connection list --subsystem $NQN)
    +[[ `echo $conns | jq -r '.status'` == "0" ]]
    +[[ `echo $conns | jq -r '.subsystem_nqn'` == "${NQN}" ]]
    +[[ `echo $conns | jq -r '.connections[0].nqn'` == "${NQN}host1" ]]
    +[[ `echo $conns | jq -r '.connections[0].trsvcid'` == "4420" ]]
    +[[ `echo $conns | jq -r '.connections[0].traddr'` == "${ip1}" ]]
    +[[ `echo $conns | jq -r '.connections[0].adrfam'` == "ipv4" ]]
    +[[ `echo $conns | jq -r '.connections[0].trtype'` == "TCP" ]]
    +[[ `echo $conns | jq -r '.connections[0].connected'` == "true" ]]
    +[[ `echo $conns | jq -r '.connections[0].qpairs_count'` == "1" ]]
    +[[ `echo $conns | jq -r '.connections[0].secure'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[0].use_psk'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[0].use_dhchap'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[0].dhchap_controller_origin'` == "no_key" ]]
    +[[ `echo $conns | jq -r '.connections[0].subsystem'` == "${NQN}" ]]
    +[[ `echo $conns | jq -r '.connections[0].host_deleted'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[1].nqn'` == "${NQN}host1" ]]
    +[[ `echo $conns | jq -r '.connections[1].trsvcid'` == "4430" ]]
    +[[ `echo $conns | jq -r '.connections[1].traddr'` == "${ip1}" ]]
    +[[ `echo $conns | jq -r '.connections[1].adrfam'` == "ipv4" ]]
    +[[ `echo $conns | jq -r '.connections[1].trtype'` == "TCP" ]]
    +[[ `echo $conns | jq -r '.connections[1].connected'` == "true" ]]
    +[[ `echo $conns | jq -r '.connections[1].qpairs_count'` == "1" ]]
    +[[ `echo $conns | jq -r '.connections[1].secure'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[1].use_psk'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[1].use_dhchap'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[1].dhchap_controller_origin'` == "no_key" ]]
    +[[ `echo $conns | jq -r '.connections[1].subsystem'` == "${NQN}" ]]
    +[[ `echo $conns | jq -r '.connections[1].host_deleted'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[2]'` == "null" ]]
    +
    +echo "ℹ️  Delete host and do not keep connection"
    +cephnvmf_func1 host del --subsystem ${NQN} --host-nqn ${NQN}host1
    +sleep 25
    +grep "Received request to remove host ${NQN}host1 access from ${NQN}, force: False, keep connections: False, context: <grpc._server" /var/log/ceph/nvmeof-$GW1_NAME/nvmeof-log
    +grep "Received request to remove host ${NQN}host1 access from ${NQN}, force: False, keep connections: False, context: None" /var/log/ceph/nvmeof-$GW2_NAME/nvmeof-log
    +
    +echo "ℹ️  Verify OMAP after second host delete"
    +set +e
    +    make -s exec SVC=ceph OPTS=-T CMD="rados --pool rbd listomapvals nvmeof.state" | grep "connected-del-host"
    +    if [[ $? -eq 0 ]]; then
    +        echo "Shouldn't have connected host entry in OMAP after we deleted the host without keep-connections"
    +        exit 1
    +    fi
    +set -e
    +
    +echo "ℹ️  Verify connection list is empty after second host delete"
    +conns=$(cephnvmf_func1 --output stdio --format json connection list --subsystem $NQN)
    +[[ `echo $conns | jq -r '.status'` == "0" ]]
    +[[ `echo $conns | jq -r '.connections[1]'` == "null" ]]

    changed

    gbregman gbregman commented on code on May 02, 2026 17:28 UTC
    Code Review
    tests/ha/keep_connection.sh:1
    @@ -0,0 +1,314 @@
    +#!/bin/bash
    +
    +. .env
    +set -e
    +set -x
    +
    +rpc=/usr/libexec/spdk/scripts/rpc.py
    +GW1_NAME=$(docker ps --format '{{.ID}}\t{{.Names}}' | awk '$2 ~ /nvmeof/ && $2 ~ /1/ {print $1}')
    +GW2_NAME=$(docker ps --format '{{.ID}}\t{{.Names}}' | awk '$2 ~ /nvmeof/ && $2 ~ /2/ {print $1}')
    +ip1="$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$GW1_NAME")"
    +ip2="$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$GW2_NAME")"
    +
    +function cephnvmf_func1()
    +{
    +    /usr/bin/docker compose run --rm nvmeof-cli --server-address ${ip1} --server-port ${NVMEOF_GW_PORT} $@
    +}
    +
    +function cephnvmf_func2()
    +{
    +    /usr/bin/docker compose run --rm nvmeof-cli --server-address ${ip2} --server-port ${NVMEOF_GW_PORT} $@
    +}
    +
    +echo "ℹ️  Starting bdevperf container"
    +docker compose up -d bdevperf
    +sleep 10
    +make logs SVC=bdevperf
    +BDEVPERF_SOCKET_LINE="$(make run SVC=bdevperf OPTS="--entrypoint=env" | grep BDEVPERF_SOCKET | tr -d '\n\r')"
    +BDEVPERF_SOCKET="${BDEVPERF_SOCKET_LINE#BDEVPERF_SOCKET=}"
    +make exec SVC=bdevperf OPTS=-T CMD="$rpc -v -s $BDEVPERF_SOCKET bdev_nvme_set_options -r -1"
    +
    +echo "ℹ️  Create resources"
    +cephnvmf_func1 listener add --subsystem ${NQN} --host-name ${GW1_NAME} --traddr $ip1 --trsvcid 4430
    +cephnvmf_func2 listener add --subsystem ${NQN} --host-name ${GW2_NAME} --traddr $ip2 --trsvcid 4430
    +/usr/bin/docker compose run --rm nvmeof-cli --server-address ${ip1} --server-port ${NVMEOF_GW_PORT} host del --subsystem ${NQN} --host-nqn "*"
    +cephnvmf_func1 namespace del --subsystem ${NQN} --nsid 2
    +cephnvmf_func1 host add --subsystem ${NQN} --host-nqn ${NQN}host1
    +sleep 20
    +
    +echo "ℹ️  Connect"
    +devs=`make -s exec SVC=bdevperf OPTS=-T CMD="$rpc -v -s $BDEVPERF_SOCKET bdev_nvme_attach_controller -b Nvme0 -t tcp -a $ip1 -s 4420 -f ipv4 -n $NQN -q ${NQN}host1 -l -1 -o 10"`
    +[[ "$devs" == "Nvme0n1" ]]
    +
    +echo "ℹ️  Verify connection"
    +conns=$(cephnvmf_func1 --output stdio --format json connection list --subsystem $NQN)
    +[[ `echo $conns | jq -r '.status'` == "0" ]]
    +[[ `echo $conns | jq -r '.subsystem_nqn'` == "${NQN}" ]]
    +[[ `echo $conns | jq -r '.connections[0].nqn'` == "${NQN}host1" ]]
    +[[ `echo $conns | jq -r '.connections[0].trsvcid'` == "4420" ]]
    +[[ `echo $conns | jq -r '.connections[0].traddr'` == "${ip1}" ]]
    +[[ `echo $conns | jq -r '.connections[0].adrfam'` == "ipv4" ]]
    +[[ `echo $conns | jq -r '.connections[0].trtype'` == "TCP" ]]
    +[[ `echo $conns | jq -r '.connections[0].connected'` == "true" ]]
    +[[ `echo $conns | jq -r '.connections[0].qpairs_count'` == "1" ]]
    +[[ `echo $conns | jq -r '.connections[0].secure'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[0].use_psk'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[0].use_dhchap'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[0].dhchap_controller_origin'` == "no_key" ]]
    +[[ `echo $conns | jq -r '.connections[0].subsystem'` == "${NQN}" ]]
    +[[ `echo $conns | jq -r '.connections[0].host_deleted'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[1]'` == "null" ]]
    +
    +echo "ℹ️  Verify OMAP before host delete"
    +set +e
    +    make -s exec SVC=ceph OPTS=-T CMD="rados --pool rbd listomapvals nvmeof.state" | grep "connected-del-host"
    +    if [[ $? -eq 0 ]]; then
    +        echo "Shouldn't have connected host entry in OMAP before we delete the host"
    +        exit 1
    +    fi
    +set -e
    +
    +echo "ℹ️  Delete host and keep connection"
    +cephnvmf_func1 host del --subsystem ${NQN} --host-nqn ${NQN}host1 --keep-connections
    +sleep 25
    +grep "Received request to remove host ${NQN}host1 access from ${NQN}, force: False, keep connections: True, context: <grpc._server" /var/log/ceph/nvmeof-$GW1_NAME/nvmeof-log
    +grep "Received request to remove host ${NQN}host1 access from ${NQN}, force: False, keep connections: True, context: None" /var/log/ceph/nvmeof-$GW2_NAME/nvmeof-log
    +
    +echo "ℹ️  Verify connection after host delete"
    +conns=$(cephnvmf_func1 --output stdio --format json connection list --subsystem $NQN)
    +[[ `echo $conns | jq -r '.status'` == "0" ]]
    +[[ `echo $conns | jq -r '.subsystem_nqn'` == "${NQN}" ]]
    +[[ `echo $conns | jq -r '.connections[0].nqn'` == "${NQN}host1" ]]
    +[[ `echo $conns | jq -r '.connections[0].trsvcid'` == "4420" ]]
    +[[ `echo $conns | jq -r '.connections[0].traddr'` == "${ip1}" ]]
    +[[ `echo $conns | jq -r '.connections[0].adrfam'` == "ipv4" ]]
    +[[ `echo $conns | jq -r '.connections[0].trtype'` == "TCP" ]]
    +[[ `echo $conns | jq -r '.connections[0].connected'` == "true" ]]
    +[[ `echo $conns | jq -r '.connections[0].qpairs_count'` == "1" ]]
    +[[ `echo $conns | jq -r '.connections[0].secure'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[0].use_psk'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[0].use_dhchap'` == "false" ]]
    +[[ `echo $conns | jq -r '.connections[0].dhchap_controller_origin'` == "no_key" ]]
    +[[ `echo $conns | jq -r '.connections[0].subsystem'` == "${NQN}" ]]
    +[[ `echo $conns | jq -r '.connections[0].host_deleted'` == "true" ]]
    +[[ `echo $conns | jq -r '.connections[1]'` == "null" ]]
    +
    +echo "ℹ️  Verify OMAP after host delete"
    +make -s exec SVC=ceph OPTS=-T CMD="rados --pool rbd listomapvals nvmeof.state" | grep "connected-del-host"
    +
    +echo "ℹ️  Verify host list is empty after host delete"
    +hosts=$(cephnvmf_func1 --output stdio --format json host list --subsystem $NQN)
    +[[ `echo $hosts | jq -r '.status'` == "0" ]]
    +[[ `echo $hosts | jq -r '.hosts[1]'` == "null" ]]

    changed

    Copilot Copilot commented on code on May 02, 2026 17:35 UTC
    Code Review
    control/state.py:1
    @@ -306,6 +313,12 @@ def add_host(self, subsystem_nqn: str, host_nqn: str, val: str):
             key = GatewayState.build_host_key(subsystem_nqn, host_nqn)
             self._add_key(key, val)
     
    +        # no need in connected host indication for this host

    The comment text is grammatically incorrect ("no need in...") which makes the intent harder to read. Please rephrase it (e.g., "no need for a connected-host indication for this host").

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on May 02, 2026 17:35 UTC
    Reviewer

    Pull request overview

    Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

    <details>
    <summary>Comments suppressed due to low confidence (1)</summary>

    control/state.py:327
    if key in state.keys() is less idiomatic and does an unnecessary keys-view lookup; if key in state is equivalent and clearer.

            state = self.get_state()
            key = GatewayState.build_host_key(subsystem_nqn, host_nqn)
            if key in state.keys():
                self._remove_key(key)
    

    </details>

    ---

    💡 <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>.

    gbregman gbregman commented on code on May 02, 2026 18:22 UTC
    Code Review
    control/state.py:1
    @@ -306,6 +313,12 @@ def add_host(self, subsystem_nqn: str, host_nqn: str, val: str):
             key = GatewayState.build_host_key(subsystem_nqn, host_nqn)
             self._add_key(key, val)
     
    +        # no need in connected host indication for this host

    changed

    Copilot Copilot commented on code on May 02, 2026 18:29 UTC
    Code Review
    tests/ha/keep_connection.sh:1
    @@ -0,0 +1,314 @@
    +#!/bin/bash
    +
    +. .env
    +set -e
    +set -x
    +
    +rpc=/usr/libexec/spdk/scripts/rpc.py
    +GW1_NAME=$(docker ps --format '{{.ID}}\t{{.Names}}' | awk '$2 ~ /nvmeof/ && $2 ~ /1/ {print $1}')
    +GW2_NAME=$(docker ps --format '{{.ID}}\t{{.Names}}' | awk '$2 ~ /nvmeof/ && $2 ~ /2/ {print $1}')
    +ip1="$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$GW1_NAME")"
    +ip2="$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$GW2_NAME")"
    +
    +function cephnvmf_func1()
    +{
    +    /usr/bin/docker compose run --rm nvmeof-cli --server-address ${ip1} --server-port ${NVMEOF_GW_PORT} $@
    +}
    +
    +function cephnvmf_func2()
    +{
    +    /usr/bin/docker compose run --rm nvmeof-cli --server-address ${ip2} --server-port ${NVMEOF_GW_PORT} $@

    In cephnvmf_func1/2, using $@ unquoted will do word-splitting and glob expansion on arguments (e.g., host NQNs like "*" if passed through these wrappers), which can lead to accidental argument mangling. Prefer forwarding args as "$@" so each original argument is preserved exactly.

    Copilot Copilot commented on code on May 02, 2026 18:29 UTC
    Code Review
    control/state.py:1
    @@ -1750,6 +1786,11 @@ def update(self) -> bool:
                                                                         omap_state_dict[key])
                     }
                     grouped_changed = self._group_by_prefix(changed, prefix_list)
    +                keep_connection = {
    +                    key: omap_state_dict[key]
    +                    for key in added_keys
    +                    if key.startswith(GatewayState.CONNECTED_HOST_PREFIX)
    +                }

    keep_connection is derived from added_keys, but the same CONNECTED_HOST_PREFIX keys remain in added/grouped_added, so _update_call_rpc(..., is_add_req=True) will still iterate over them (and control/server.py will effectively no-op). Consider removing these keys from added once extracted into keep_connection (or otherwise documenting the intentional no-op) to avoid redundant work and make the special-case handling clearer.

    Copilot Copilot commented on code on May 02, 2026 18:29 UTC
    Code Review
    control/server.py:1
    @@ -1248,6 +1248,12 @@ def abort_server_on_update_error(rc: int, msg: str):
                                                 ignore_unknown_fields=True)
                         rc = self.gateway_rpc.remove_host(req)
                     abort_server_on_update_error(rc.status, rc.error_message)
    +            elif key.startswith(GatewayState.CONNECTED_HOST_PREFIX):
    +                if not is_add_req:
    +                    req = json_format.Parse(val, pb2.set_keep_host_connected_req(),
    +                                            ignore_unknown_fields=True)
    +                    rc = self.gateway_rpc.set_keep_host_connected(req)
    +                    abort_server_on_update_error(rc.status, rc.error_message)

    For CONNECTED_HOST_PREFIX updates, the is_add_req path currently falls through without an explicit no-op, even though additions for this prefix are intentionally ignored (the signal is handled via the removal phase). Adding an explicit else: pass (or a short comment explaining why add-events are ignored) would make the intent clearer and reduce the chance of future regressions when this block is modified.

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on May 02, 2026 18:29 UTC
    Reviewer

    Pull request overview

    Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

    ---

    💡 <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>.

    Hezko Hezko commented on code on May 02, 2026 21:16 UTC
    Code Review
    control/cli.py:1
    @@ -2060,10 +2060,14 @@ def host_del(self, args):
             rc = 0
             ret_list = []
             out_func, err_func, wrn_func = self.get_output_functions(args)
    +        if args.keep_connections:
    +            if any(hnqn == "*" for hnqn in args.host_nqn):
    +                self.cli.parser.error("Can only keep existing connections for specific host NQNs")

    Maybe this is clearer? wdyt?

                    self.cli.parser.error("Can only keep existing connections for specific host NQNs, not '*'.")
    

    gbregman gbregman commented on code on May 02, 2026 23:18 UTC
    Code Review
    tests/ha/keep_connection.sh:1
    @@ -0,0 +1,314 @@
    +#!/bin/bash
    +
    +. .env
    +set -e
    +set -x
    +
    +rpc=/usr/libexec/spdk/scripts/rpc.py
    +GW1_NAME=$(docker ps --format '{{.ID}}\t{{.Names}}' | awk '$2 ~ /nvmeof/ && $2 ~ /1/ {print $1}')
    +GW2_NAME=$(docker ps --format '{{.ID}}\t{{.Names}}' | awk '$2 ~ /nvmeof/ && $2 ~ /2/ {print $1}')
    +ip1="$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$GW1_NAME")"
    +ip2="$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$GW2_NAME")"
    +
    +function cephnvmf_func1()
    +{
    +    /usr/bin/docker compose run --rm nvmeof-cli --server-address ${ip1} --server-port ${NVMEOF_GW_PORT} $@
    +}
    +
    +function cephnvmf_func2()
    +{
    +    /usr/bin/docker compose run --rm nvmeof-cli --server-address ${ip2} --server-port ${NVMEOF_GW_PORT} $@

    changed

    gbregman gbregman commented on code on May 02, 2026 23:21 UTC
    Code Review
    control/server.py:1
    @@ -1248,6 +1248,12 @@ def abort_server_on_update_error(rc: int, msg: str):
                                                 ignore_unknown_fields=True)
                         rc = self.gateway_rpc.remove_host(req)
                     abort_server_on_update_error(rc.status, rc.error_message)
    +            elif key.startswith(GatewayState.CONNECTED_HOST_PREFIX):
    +                if not is_add_req:
    +                    req = json_format.Parse(val, pb2.set_keep_host_connected_req(),
    +                                            ignore_unknown_fields=True)
    +                    rc = self.gateway_rpc.set_keep_host_connected(req)
    +                    abort_server_on_update_error(rc.status, rc.error_message)

    changed

    Copilot Copilot commented on code on May 02, 2026 23:27 UTC
    Code Review
    control/state.py:1
    @@ -1750,6 +1786,11 @@ def update(self) -> bool:
                                                                         omap_state_dict[key])
                     }
                     grouped_changed = self._group_by_prefix(changed, prefix_list)
    +                keep_connection = {
    +                    key: omap_state_dict[key]
    +                    for key in added_keys
    +                    if key.startswith(GatewayState.CONNECTED_HOST_PREFIX)
    +                }

    keep_connection keys (CONNECTED_HOST_PREFIX) are still included in the normal added/grouped_added flow, but are also injected into removed via removed.update(keep_connection) so they get handled during the removal phase. Since the add-phase handler for this prefix is a deliberate no-op, this results in redundant processing (and can introduce unnecessary break_update_interval delays) and makes the update logic harder to follow. Consider removing/popping CONNECTED_HOST_PREFIX keys from added once they’re captured in keep_connection, and add a short comment explaining that these “added” keys are intentionally applied during the removal phase to ensure ordering before host removal updates.

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on May 02, 2026 23:27 UTC
    Reviewer

    Pull request overview

    Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

    ---

    💡 <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>.

    gbregman gbregman commented on code on May 03, 2026 06:54 UTC
    Code Review
    control/state.py:1
    @@ -1750,6 +1786,11 @@ def update(self) -> bool:
                                                                         omap_state_dict[key])
                     }
                     grouped_changed = self._group_by_prefix(changed, prefix_list)
    +                keep_connection = {
    +                    key: omap_state_dict[key]
    +                    for key in added_keys
    +                    if key.startswith(GatewayState.CONNECTED_HOST_PREFIX)
    +                }

    this is fine. adding the code is not worth it as the usage of this will be quite rare

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on May 03, 2026 10:08 UTC
    Reviewer

    Pull request overview

    Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.

    ---

    💡 <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>.

    Hezko Hezko approved these changes on May 03, 2026 10:52 UTC
    Approved Reviewer

    Approved these changes.

    caroav caroav approved these changes on May 03, 2026 11:11 UTC
    Approved Reviewer

    Approved these changes.

    tchaikov tchaikov commented on Jul 09, 2026 06:09 UTC
    Reviewer

    @gbregman @baum hi Gil and Alexander, sorry for commenting on a merged pull request, but in this commit, we updated the spdk submodule to 611b10960d08a97d8d20863f176951ded8595fdb, which is not included in the ceph/spdk repo. but this commit is included a pull request not yet merged, see https://github.com/ceph/spdk/pull/17/commits . IMHO, this is not expected. i ran into this issue, when trying to package ceph, but consistenly ran into:

    $ git submodule update --init --recursive                                                
    fatal: remote error: upload-pack: not our ref 611b10960d08a97d8d20863f176951ded8595fdb                                         
    fatal: Fetched in submodule path 'spdk', but it did not contain 611b10960d08a97d8d20863f176951ded8595fdb. Direct fetching of that commit failed.
    

    gbregman gbregman commented on Jul 09, 2026 07:47 UTC
    Author

    @tchaikov yes, somehow I missed pushing this commit. Anyway, this doesn't seem relevant any more as we have two commits to the SPDK after that. So, if you take the latest version you should be OK.

    Reviewers
    Assignees
    gbregman gbregman
    Labels
    risk: low confidence: 89.3% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 62.2% (MEDIUM) · Higher = larger blast radius
    62.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 89.3% · Lower = rushed or shallow review
    89.3%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 6.7% · Safe to merge
    6.7%