Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion control/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,8 @@ def gw_info(self, args):
out_func(f"Gateway's group: {gw_info.group}")
if gw_info.hostname:
out_func(f"Gateway's host name: {gw_info.hostname}")
if not gw_info.gateway_initialization_over:
out_func("Gateway's initialization is still in progress")
out_func(f"Gateway's load balancing group: {gw_info.load_balancing_group}")
out_func(f"Gateway's address: {gw_info.addr}")
out_func(f"Gateway's port: {gw_info.port}")
Expand Down Expand Up @@ -1692,7 +1694,7 @@ def host_list(self, args):
if hosts_info.status == 0:
hosts_list = []
if hosts_info.allow_any_host:
hosts_list.append(["Any host", "n/a"])
hosts_list.append(["Any host", "n/a", "n/a"])
has_timeout = False
for h in hosts_info.hosts:
if h.disconnected_due_to_keepalive_timeout:
Expand Down
2 changes: 2 additions & 0 deletions control/grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -6344,6 +6344,7 @@ def get_gateway_info_safe(self, request, context):
cli_version_string = request.cli_version
addr = self.config.get_with_default("gateway", "addr", "")
port = self.config.get_with_default("gateway", "port", "")
initialization_over = self.gateway_state.is_initialization_over()
ret = pb2.gateway_info(cli_version=request.cli_version,
version=gw_version_string,
spdk_version=spdk_version_string,
Expand All @@ -6359,6 +6360,7 @@ def get_gateway_info_safe(self, request, context):
max_namespaces_per_subsystem=self.max_namespaces_per_subsystem,
max_hosts_per_subsystem=self.max_hosts_per_subsystem,
max_hosts=self.max_hosts,
gateway_initialization_over=initialization_over,
status=0,
error_message=os.strerror(0))
cli_ver = self.parse_version(cli_version_string)
Expand Down
1 change: 1 addition & 0 deletions control/proto/gateway.proto
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ message gateway_info {
optional uint32 max_hosts_per_subsystem = 15;
optional uint32 max_namespaces_per_subsystem = 16;
optional uint32 max_hosts = 17;
optional bool gateway_initialization_over = 18;
}

message cli_version {
Expand Down
9 changes: 9 additions & 0 deletions control/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -1125,9 +1125,13 @@ def __init__(self, config, local, omap, gateway_rpc_caller, crypto, id_text=""):
"break_update_interval_sec",
25)
self.update_is_active_lock = threading.Lock()
self.first_update_over = False
self.id_text = id_text
self.up_and_running = True

def is_initialization_over(self) -> bool:
return self.first_update_over

def add_namespace(self, subsystem_nqn: str, nsid: str, val: str):
"""Adds a namespace to the state data store."""
self.omap.add_namespace(subsystem_nqn, nsid, val)
Expand Down Expand Up @@ -1796,6 +1800,11 @@ def update(self) -> bool:
self.omap.set_local_version(omap_version)
self.logger.info(f"Update complete ({local_version} -> {omap_version}) "
f"({self.id_text}).")

if not self.first_update_over:
self.first_update_over = True
self.logger.info(f"Initialization is over ({self.id_text}).")

return True

def _group_by_prefix(self, state_update, prefix_list):
Expand Down
13 changes: 13 additions & 0 deletions tests/test_big_omap.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,20 @@ def test_big_omap(caplog, two_gateways):
f'"group": "{group_name}"' + "}"
)
gatewayB.serve()
caplog.clear()
time.sleep(1)
cli(["--server-port", portB, "--format", "json", "gateway", "info"])
assert '"gateway_initialization_over": false,' in caplog.text
time.sleep(waitForUpdate + sleep_delta)
while True:
retries = 5
caplog.clear()
cli(["--server-port", portB, "--format", "json", "gateway", "info"])
if '"gateway_initialization_over": true,' in caplog.text:
break
retries -= 1
assert retries > 0, "Gateway is not fully initialized after restart"
time.sleep(sleep_delta)
print("Verify resources after gateway restart")
while True:
retries = 3
Expand Down
Loading