Skip to content

Commit 8c6b79f

Browse files
authored
Merge branch 'devel' into fix_rebalance_logs
2 parents cbbb15f + db5a1d9 commit 8c6b79f

18 files changed

+891
-242
lines changed

.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,5 @@ DHCHAP_KEY6="DHHC-1:01:Bu4tZd7X2oW7XxmVH5tGCdoS30pDX6bZvexHYoudeVlJW9yz:"
101101
DHCHAP_KEY7="DHHC-1:01:JPJkDQ2po2FfLmKYlTF/sJ2HzVO/FKWxgXKE/H6XfL8ogQ1T:"
102102
DHCHAP_KEY8="DHHC-1:01:e0B0vDxKleDzYVtG42xqFvoWZfiufkoywmfRKrETzayRdf1j:"
103103
DHCHAP_KEY9="DHHC-1:01:KD+sfH3/o2bRQoV0ESjBUywQlMnSaYpZISUbVa0k0nsWpNST:"
104+
DHCHAP_KEY10="DHHC-1:00:rWf0ZFYO7IgWGttM8w6jUrAY4cTQyqyXPdmxHeOSve3w5QU9:"
105+
DHCHAP_KEY11="DHHC-1:02:j3uUz05r5aQy42vX4tDXqVf9HgUPPdEp3kXTgUWl9EphsG7jwpr9KSIt3bmRLXBijPTIDQ==:"

.github/workflows/build-container.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ jobs:
133133
strategy:
134134
fail-fast: false
135135
matrix:
136-
test: ["cli", "cli_change_lb", "cli_change_keys", "state", "multi_gateway", "server", "grpc", "omap_lock", "log_files", "nsid", "psk", "dhchap"]
136+
test: ["cli", "cli_change_lb", "cli_change_keys", "cli_change_ns_visibility", "state", "multi_gateway", "server", "grpc", "omap_lock", "log_files", "nsid", "psk", "dhchap"]
137137
runs-on: ubuntu-latest
138138
env:
139139
HUGEPAGES: 512 # for multi gateway test, approx 256 per gateway instance

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,14 +294,21 @@ client_cert = ./client.crt
294294
295295
### Huge-Pages
296296
297-
[DPDK requires hugepages](https://doc.dpdk.org/guides/linux_gsg/sys_reqs.html#linux-gsg-hugepages) to be set up:
297+
[DPDK uses by default hugepages](https://doc.dpdk.org/guides/linux_gsg/sys_reqs.html#linux-gsg-hugepages) to be set up:
298298
299299
```bash
300300
sh -c 'echo 4096 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages'
301301
```
302302
303303
This is automatically done in the `make setup` step. The amount of hugepages can be configured with `make setup HUGEPAGES=512`.
304304
305+
ℹ️ **Info:** To eliminate the dependency on huge pages, set [mem_size=4096](https://github.com/ceph/ceph-nvmeof/blob/bf83ae504e77358944c8a0150d390cf66086fa2b/tests/ceph-nvmeof.no-huge.conf#L68) (memory size in megabytes) in the spdk section of the ceph-nvmeof.conf file. See the [example](https://github.com/ceph/ceph-nvmeof/blob/devel/tests/ceph-nvmeof.no-huge.conf) configuration file for reference.
306+
307+
```ini
308+
[spdk]
309+
mem_size=4096
310+
```
311+
305312
## Development
306313
307314
### Set-up

ceph-nvmeof.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ max_ns_to_change_lb_grp = 8
3232
#verify_nqns = True
3333
#allowed_consecutive_spdk_ping_failures = 1
3434
#spdk_ping_interval_in_seconds = 2.0
35-
#max_hosts_per_namespace = 1
35+
#max_hosts_per_namespace = 8
3636
#max_namespaces_with_netmask = 1000
3737
#max_subsystems = 128
3838
#max_namespaces = 1024

control/cli.py

Lines changed: 86 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,7 @@ def gw_set_log_level(self, args):
506506
gw_actions.append({"name" : "get_log_level", "args" : [], "help" : "Get gateway's log level"})
507507
gw_actions.append({"name" : "set_log_level", "args" : gw_set_log_level_args, "help" : "Set gateway's log level"})
508508
gw_choices = get_actions(gw_actions)
509+
509510
@cli.cmd(gw_actions)
510511
def gw(self, args):
511512
"""Gateway commands"""
@@ -596,8 +597,6 @@ def spdk_log_level_get(self, args):
596597

597598
def spdk_log_level_set(self, args):
598599
"""Set SPDK log levels and nvmf log flags"""
599-
rc = 0
600-
errmsg = ""
601600

602601
out_func, err_func = self.get_output_functions(args)
603602
log_level = None
@@ -655,6 +654,7 @@ def spdk_log_level_set(self, args):
655654
spdk_log_actions.append({"name" : "set", "args" : spdk_log_set_args, "help" : "Set SPDK log levels and nvmf log flags"})
656655
spdk_log_actions.append({"name" : "disable", "args" : spdk_log_disable_args, "help" : "Disable SPDK nvmf log flags"})
657656
spdk_log_choices = get_actions(spdk_log_actions)
657+
658658
@cli.cmd(spdk_log_actions)
659659
def spdk_log_level(self, args):
660660
"""SPDK nvmf log level commands"""
@@ -691,7 +691,7 @@ def subsystem_add(self, args):
691691
new_nqn = ""
692692
try:
693693
new_nqn = ret.nqn
694-
except Exception as ex: # In case of an old gateway the returned value wouldn't have the nqn field
694+
except Exception: # In case of an old gateway the returned value wouldn't have the nqn field
695695
pass
696696
if not new_nqn:
697697
new_nqn = args.subsystem
@@ -826,7 +826,6 @@ def subsystem_list(self, args):
826826
def subsystem_change_key(self, args):
827827
"""Change subsystem's inband authentication key."""
828828

829-
rc = 0
830829
out_func, err_func = self.get_output_functions(args)
831830

832831
req = pb2.change_subsystem_key_req(subsystem_nqn=args.subsystem, dhchap_key=args.dhchap_key)
@@ -884,6 +883,7 @@ def subsystem_change_key(self, args):
884883
subsystem_actions.append({"name" : "list", "args" : subsys_list_args, "help" : "List subsystems"})
885884
subsystem_actions.append({"name" : "change_key", "args" : subsys_change_key_args, "help" : "Change subsystem key"})
886885
subsystem_choices = get_actions(subsystem_actions)
886+
887887
@cli.cmd(subsystem_actions)
888888
def subsystem(self, args):
889889
"""Subsystem commands"""
@@ -1026,11 +1026,11 @@ def listener_list(self, args):
10261026
if args.format == "text" or args.format == "plain":
10271027
if listeners_info.status == 0:
10281028
listeners_list = []
1029-
for l in listeners_info.listeners:
1030-
adrfam = GatewayEnumUtils.get_key_from_value(pb2.AddressFamily, l.adrfam)
1029+
for lstnr in listeners_info.listeners:
1030+
adrfam = GatewayEnumUtils.get_key_from_value(pb2.AddressFamily, lstnr.adrfam)
10311031
adrfam = self.format_adrfam(adrfam)
1032-
secure = "Yes" if l.secure else "No"
1033-
listeners_list.append([l.host_name, l.trtype, adrfam, f"{l.traddr}:{l.trsvcid}", secure])
1032+
secure = "Yes" if lstnr.secure else "No"
1033+
listeners_list.append([lstnr.host_name, lstnr.trtype, adrfam, f"{lstnr.traddr}:{lstnr.trsvcid}", secure])
10341034
if len(listeners_list) > 0:
10351035
if args.format == "text":
10361036
table_format = "fancy_grid"
@@ -1086,6 +1086,7 @@ def listener_list(self, args):
10861086
listener_actions.append({"name" : "del", "args" : listener_del_args, "help" : "Delete a listener"})
10871087
listener_actions.append({"name" : "list", "args" : listener_list_args, "help" : "List listeners"})
10881088
listener_choices = get_actions(listener_actions)
1089+
10891090
@cli.cmd(listener_actions)
10901091
def listener(self, args):
10911092
"""Listener commands"""
@@ -1216,7 +1217,6 @@ def host_del(self, args):
12161217
def host_change_key(self, args):
12171218
"""Change host's inband authentication keys."""
12181219

1219-
rc = 0
12201220
out_func, err_func = self.get_output_functions(args)
12211221

12221222
if args.host_nqn == "*":
@@ -1327,6 +1327,7 @@ def host_list(self, args):
13271327
host_actions.append({"name" : "list", "args" : host_list_args, "help" : "List subsystem's host access"})
13281328
host_actions.append({"name" : "change_key", "args" : host_change_key_args, "help" : "Change host's inband authentication keys"})
13291329
host_choices = get_actions(host_actions)
1330+
13301331
@cli.cmd(host_actions)
13311332
def host(self, args):
13321333
"""Host commands"""
@@ -1406,6 +1407,7 @@ def connection_list(self, args):
14061407
connection_actions = []
14071408
connection_actions.append({"name" : "list", "args" : connection_list_args, "help" : "List active connections"})
14081409
connection_choices = get_actions(connection_actions)
1410+
14091411
@cli.cmd(connection_actions)
14101412
def connection(self, args):
14111413
"""Connection commands"""
@@ -1601,7 +1603,7 @@ def get_size_in_bytes(self, sz):
16011603
try:
16021604
sz = sz.strip()
16031605
int_size = int(sz)
1604-
except:
1606+
except Exception:
16051607
self.cli.parser.error(f"Size {sz} must be numeric")
16061608

16071609
int_size *= multiply
@@ -1638,14 +1640,15 @@ def ns_list(self, args):
16381640
lb_group = "<n/a>"
16391641
else:
16401642
lb_group = str(ns.load_balancing_group)
1641-
if ns.no_auto_visible:
1643+
if ns.auto_visible:
1644+
visibility = "All Hosts"
1645+
else:
16421646
if len(ns.hosts) > 0:
1647+
visibility = ""
16431648
for hst in ns.hosts:
1644-
visibility = break_string(hst, ":", 2) + "\n"
1649+
visibility += "· " + break_string(hst, ":", 2) + "\n"
16451650
else:
1646-
visibility = "Selective"
1647-
else:
1648-
visibility = "All Hosts"
1651+
visibility = "Restrictive"
16491652

16501653
namespaces_list.append([ns.nsid,
16511654
break_string(ns.bdev_name, "-", 2),
@@ -1850,7 +1853,7 @@ def ns_change_load_balancing_group(self, args):
18501853

18511854
def get_qos_limit_str_value(self, qos_limit):
18521855
if qos_limit == 0:
1853-
return "unlimited"
1856+
return "unset"
18541857
else:
18551858
return str(qos_limit)
18561859

@@ -1977,7 +1980,7 @@ def ns_del_host(self, args):
19771980

19781981
if args.format == "text" or args.format == "plain":
19791982
if ret.status == 0:
1980-
out_func(f"Deleting host {args.host_nqn} from namespace {args.nsid} on {args.subsystem}: Successful")
1983+
out_func(f"Deleting host {one_host_nqn} from namespace {args.nsid} on {args.subsystem}: Successful")
19811984
else:
19821985
err_func(f"{ret.error_message}")
19831986
elif args.format == "json" or args.format == "yaml":
@@ -2001,6 +2004,61 @@ def ns_del_host(self, args):
20012004

20022005
return rc
20032006

2007+
def ns_change_visibility(self, args):
2008+
"""Change namespace visibility."""
2009+
2010+
out_func, err_func = self.get_output_functions(args)
2011+
if args.nsid <= 0:
2012+
self.cli.parser.error("nsid value must be positive")
2013+
2014+
if not args.auto_visible and not args.no_auto_visible:
2015+
self.cli.parser.error("Either --auto-visible or --no-auto-visible should be specified")
2016+
2017+
if args.auto_visible and args.no_auto_visible:
2018+
self.cli.parser.error("--auto-visible and --no-auto-visible are mutually exclusive")
2019+
2020+
if args.auto_visible:
2021+
auto_visible = True
2022+
elif args.no_auto_visible:
2023+
auto_visible = False
2024+
else:
2025+
assert False
2026+
2027+
try:
2028+
change_visibility_req = pb2.namespace_change_visibility_req(subsystem_nqn=args.subsystem,
2029+
nsid=args.nsid, auto_visible=auto_visible,
2030+
force=args.force)
2031+
ret = self.stub.namespace_change_visibility(change_visibility_req)
2032+
except Exception as ex:
2033+
ret = pb2.req_status(status = errno.EINVAL, error_message = f"Failure changing namespace visibility:\n{ex}")
2034+
2035+
if auto_visible:
2036+
vis_text = "\"visible to all hosts\""
2037+
else:
2038+
vis_text = "\"visible to selected hosts\""
2039+
if args.format == "text" or args.format == "plain":
2040+
if ret.status == 0:
2041+
out_func(f"Changing visibility of namespace {args.nsid} in {args.subsystem} to {vis_text}: Successful")
2042+
else:
2043+
err_func(f"{ret.error_message}")
2044+
elif args.format == "json" or args.format == "yaml":
2045+
ret_str = json_format.MessageToJson(
2046+
ret,
2047+
indent=4,
2048+
including_default_value_fields=True,
2049+
preserving_proto_field_name=True)
2050+
if args.format == "json":
2051+
out_func(f"{ret_str}")
2052+
elif args.format == "yaml":
2053+
obj = json.loads(ret_str)
2054+
out_func(yaml.dump(obj))
2055+
elif args.format == "python":
2056+
return ret
2057+
else:
2058+
assert False
2059+
2060+
return ret.status
2061+
20042062
ns_common_args = [
20052063
argument("--subsystem", "-n", help="Subsystem NQN", required=True),
20062064
]
@@ -2034,6 +2092,12 @@ def ns_del_host(self, args):
20342092
argument("--nsid", help="Namespace ID", type=int, required=True),
20352093
argument("--load-balancing-group", "-l", help="Load balancing group", type=int, required=True),
20362094
]
2095+
ns_change_visibility_args_list = ns_common_args + [
2096+
argument("--nsid", help="Namespace ID", type=int, required=True),
2097+
argument("--auto-visible", help="Visible to all hosts", action='store_true', required=False),
2098+
argument("--no-auto-visible", help="Visible to selected hosts only", action='store_true', required=False),
2099+
argument("--force", help="Change visibility of namespace even if there hosts added to it or active connections on the subsystem", action='store_true', required=False),
2100+
]
20372101
ns_set_qos_args_list = ns_common_args + [
20382102
argument("--nsid", help="Namespace ID", type=int, required=True),
20392103
argument("--rw-ios-per-second", help="R/W IOs per second limit, 0 means unlimited", type=int),
@@ -2059,7 +2123,9 @@ def ns_del_host(self, args):
20592123
ns_actions.append({"name" : "set_qos", "args" : ns_set_qos_args_list, "help" : "Set QOS limits for a namespace"})
20602124
ns_actions.append({"name" : "add_host", "args" : ns_add_host_args_list, "help" : "Add a host to a namespace"})
20612125
ns_actions.append({"name" : "del_host", "args" : ns_del_host_args_list, "help" : "Delete a host from a namespace"})
2126+
ns_actions.append({"name" : "change_visibility", "args" : ns_change_visibility_args_list, "help" : "Change visibility for a namespace"})
20622127
ns_choices = get_actions(ns_actions)
2128+
20632129
@cli.cmd(ns_actions, ["ns"])
20642130
def namespace(self, args):
20652131
"""Namespace commands"""
@@ -2081,6 +2147,8 @@ def namespace(self, args):
20812147
return self.ns_add_host(args)
20822148
elif args.action == "del_host":
20832149
return self.ns_del_host(args)
2150+
elif args.action == "change_visibility":
2151+
return self.ns_change_visibility(args)
20842152
if not args.action:
20852153
self.cli.parser.error(f"missing action for namespace command (choose from {GatewayClient.ns_choices})")
20862154

@@ -2135,5 +2203,6 @@ def main(args=None) -> int:
21352203

21362204
return main_common(client, parsed_args)
21372205

2206+
21382207
if __name__ == "__main__":
21392208
sys.exit(main())

0 commit comments

Comments
 (0)