Skip to content

Receptor doesn't fail gracefully when the data directory is not writable #195

@elyezer

Description

@elyezer

Trying to run receptor ping and not specifying a writable data directory it fails with the following message:

$ receptor ping foo
ERROR 2020-03-30 16:29:32,504  __main__ main: an error occured while running receptor
Traceback (most recent call last):
  File "/home/elyezer/code/receptor/receptor/receptor/entrypoints.py", line 102, in run_as_ping
    controller = Controller(config)
  File "/home/elyezer/code/receptor/receptor/receptor/controller.py", line 33, in __init__
    self.receptor = Receptor(config)
  File "/home/elyezer/code/receptor/receptor/receptor/receptor.py", line 110, in __init__
    os.makedirs(os.path.join(self.config.default_data_dir, self.node_id))
  File "/usr/lib64/python3.7/os.py", line 211, in makedirs
    makedirs(head, exist_ok=exist_ok)
  File "/usr/lib64/python3.7/os.py", line 221, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/var/lib/receptor'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/elyezer/code/receptor/receptor/receptor/__main__.py", line 63, in main
    config.go()
  File "/home/elyezer/code/receptor/receptor/receptor/config.py", line 538, in go
    self._parsed_args.func(self)
  File "/home/elyezer/code/receptor/receptor/receptor/entrypoints.py", line 105, in run_as_ping
    controller.cleanup_tmpdir()
UnboundLocalError: local variable 'controller' referenced before assignment

It would be better to avoid showing the UnboundLocalError and state what was the issue.

With this we can bring a conversation about if ephemeral node related commands such as ping should try to create a temporary data directory. If this is a good idea we can open a separate issue and track this enhancement separately from this one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions