Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get local state and not OMAP's for ANA processing #274

Merged
merged 1 commit into from
Oct 22, 2023
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
5 changes: 2 additions & 3 deletions control/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,8 @@ def delete_bdev(self, args):
argument("-n", "--subnqn", help="Subsystem NQN", required=True),
argument("-s", "--serial", help="Serial number", required=False),
argument("-m", "--max-namespaces", help="Maximum number of namespaces", type=int, default=0, required=False),
argument("-a", "--ana-reporting", help="Enable ANA reporting", type=bool, default=False, required=False),
argument("-t", "--enable-ha", help="Enable automatic HA" , type=bool, default=False, required=False),

argument("-a", "--ana-reporting", help="Enable ANA reporting", action='store_true', required=False),
argument("-t", "--enable-ha", help="Enable automatic HA", action='store_true', required=False),
])
def create_subsystem(self, args):
"""Creates a subsystem."""
Expand Down
24 changes: 15 additions & 9 deletions control/grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,15 +533,21 @@ def create_listener_safe(self, request, context=None):
context.set_details(f"{ex}")
return pb2.req_status()

state = self.gateway_state.omap.get_state()
for key,val in state.items():
if (key.startswith(self.gateway_state.omap.SUBSYSTEM_PREFIX + request.nqn)):
self.logger.debug(f"values of key: {key} val: {val} \n")
req = json_format.Parse(val, pb2.create_subsystem_req())
self.logger.info(f" enable_ha :{req.enable_ha} \n")
break

if req.enable_ha:
state = self.gateway_state.local.get_state()
req = None
subsys = state.get(self.gateway_state.local.SUBSYSTEM_PREFIX + request.nqn)
if subsys:
self.logger.debug(f"value of sub-system: {subsys}")
try:
req = json_format.Parse(subsys, pb2.create_subsystem_req())
self.logger.info(f"enable_ha: {req.enable_ha}")
except Exception:
self.logger.error(f"Got exception trying to parse subsystem: {ex}")
pass
else:
self.logger.info(f"No sub-system for {request.nqn}")

if req and req.enable_ha:
for x in range (MAX_ANA_GROUPS):
try:
ret = rpc_nvmf.nvmf_subsystem_listener_set_ana_state(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def test_create_bdev_ana(self, caplog, gateway):


def test_create_subsystem_ana(self, caplog, gateway):
cli(["create_subsystem", "-n", subsystem, "-a", "true", "-t", "true"])
cli(["create_subsystem", "-n", subsystem, "-a", "-t"])
assert "Failed to create" not in caplog.text
cli(["get_subsystems"])
assert serial not in caplog.text
Expand Down