stratis-storage/stratis-cli

Interpret stack trace upon timeout expiration

Closed this issue · 3 comments

When the timeout variable is set to a too-small value for a command, a DBusException is raised and the following stack traces are displayed. Instead, we should handle the exception and more concisely notify the user that a timeout expiration has occurred.

[gchin@to-be-determined stratis-cli]$ PYTHONPATH=./src STRATIS_DBUS_TIMEOUT="0" ./bin/stratis pool list
stratis encountered an unexpected error during execution. Please report the error and include in your report the stack trace shown below. 

Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/dbus_python_client_gen/_invokers.py", line 319, in dbus_func
    return dbus_method(*xformed_args, timeout=timeout)
  File "/usr/local/lib64/python3.7/site-packages/dbus/proxies.py", line 145, in __call__
    **keywords)
  File "/usr/local/lib64/python3.7/site-packages/dbus/connection.py", line 651, in call_blocking
    message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NoReply: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/gchin/stratis-storage/stratis-cli/src/stratis_cli/_main.py", line 43, in the_func
    result.func(result)
  File "/home/gchin/stratis-storage/stratis-cli/src/stratis_cli/_actions/_top.py", line 71, in list_pools
    managed_objects = ObjectManager.Methods.GetManagedObjects(proxy, {})
  File "/usr/lib/python3.7/site-packages/dbus_python_client_gen/_invokers.py", line 327, in dbus_func
    name, xformed_args)) from err
dbus_python_client_gen._errors.DPClientInvocationError: Error while invoking method "GetManagedObjects" belonging to interface "org.freedesktop.DBus.ObjectManager" with arguments ()

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "./bin/stratis", line 36, in <module>
    main()
  File "./bin/stratis", line 32, in main
    return run()(sys.argv[1:])
  File "/home/gchin/stratis-storage/stratis-cli/src/stratis_cli/_main.py", line 59, in the_func
    handle_error(err)
  File "/home/gchin/stratis-storage/stratis-cli/src/stratis_cli/_error_reporting.py", line 184, in handle_error
    raise err
  File "/home/gchin/stratis-storage/stratis-cli/src/stratis_cli/_main.py", line 54, in the_func
    raise StratisCliActionError(command_line_args, result) from err
stratis_cli._errors.StratisCliActionError: Action selected by command-line arguments ['pool', 'list'] which were parsed to Namespace(func=<function TopActions.list_pools at 0x7fa6aa9ff3b0>, propagate=False) failed

We can handle this in interpret_errors. The code can not know for certain that the failure is due to the timeout having elapsed stratisd having taken a very long time to perform an operation, so it will have to give a more generic error, something like: "stratis attempted communication with the daemon, stratisd, over the D-Bus, but stratisd did not respond in the allowed time." There are other examples where the code matches specific specific dbus errors already in interpret_errors, this should be another. It will be easiest to test by the approach here, which sets the D-Bus timeout impossibly small, so we might as well wait to address this until #252, #328 are completed.

Blocked by #252.

#252 was merged, so it should be easy to induce and test this error.