Open sscargal opened 5 years ago
"all" is a specific keyword, but the bus is otherwise allowed to be named by a driver specific "provider" name which is free form. So, "ndctl list --bus=All" is asking ndctl to find a bus with the provider name of "All".
A third option is to just return ENOENT on empty "ndctl list" results to say that it failed to list anything rather than it successfully ran with the given filter.
Is that also true for Regions and Namespaces?
# ndctl destroy-namespace -f All
error destroying namespaces: No such device or address
destroyed 0 namespaces
# ndctl destroy-namespace -f all
destroyed 4 namespaces
destroy-namespace is operating on existing namespaces. create-namespace is a single operation where ndctl tries to search for a capacity to satisfy that single request if the user does not specify it.
Consider these invocations:
ndctl destroy-namespace -r all all ndctl create-namespace -r all
In the destroy-case there is a list of targets after the "-r all" filter parameter. create-namespace does not support a list of targets because the targets don't exist yet. I do agree the man page does not make this distinction so that can be cleaned up, but this otherwise needs an explicit option to tell ndctl to repeat the create operation.
In ndctl v66 and earlier, command-line argument and option processing is very strict as we use
strcmp()
. See/ndctl/namespace.c
for example.This causes undesirable behavior for the user. For example, the following works as expected because it adheres to the documentation and code implementation:
But if we run the following command, we get no output, no error, and no indication the user did anything wrong (except camel-case the
All
option):The user doesn't know what to do here. This is a major issue for scripts and automated deployment environments such as Puppet, Ansible, etc as the
ndctl
command exited gracefully even though it did nothing. Most scripts check the return code from commands to know if it was successful or failed with an error.For this issue, we could either:
strcasecmp()
instead ofstrcmp()
(where it makes sense to do so). This would be the easiest to implement while maintaining current functionality, or