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

Pcs (and consequently and painfully, respective interactive execution to figure out the respective bash completion atoms) is not robust when it comes to keyboard interrupts #152

Open
jnpkrn opened this issue Nov 15, 2017 · 3 comments

Comments

@jnpkrn
Copy link
Contributor

jnpkrn commented Nov 15, 2017

What I did:

$  pcs --<tab><tab><Ctrl+C>

What I got (for instance):

  File "/usr/sbin/pcs", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3038, in <module>
    @_call_aside
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3022, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3051, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 648, in _build_master
    ws = cls()
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 641, in __init__
    self.add_entry(entry)
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 697, in add_entry
    for dist in find_distributions(entry, True):
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2033, in find_on_path
    path_item, entry, metadata, precedence=DEVELOP_DIST
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2452, in from_location
    py_version=py_version, platform=platform, **kw
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2792, in _reload_version
    md_version = _version_from_file(self._get_metadata(self.PKG_INFO))
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2417, in _version_from_file
    line = next(iter(version_lines), '')
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2584, in _get_metadata
    if self.has_metadata(name):
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2624, in __getattr__
    def __getattr__(self, attr):
KeyboardInterrupt

I.e. /usr/sbin/pcs needs to catch that exception from the very beginning
(ultimate solution for https://bugzilla.redhat.com/show_bug.cgi?id=1354498,
indeed, it should respond to it per the current context of use, but exit right
away when being run to complete something).

@jnpkrn jnpkrn changed the title Bash completion not robust enough Pcs (and consequently and painfully, respective interactive execution to figure out the respective bash completion atoms) is not robust when it comes to keyboard interrupts Mar 21, 2019
@jnpkrn
Copy link
Contributor Author

jnpkrn commented Mar 21, 2019

Have just observed that again:

$ pcs resource list
^CTraceback (most recent call last):
  File "/usr/sbin/pcs", line 11, in <module>
    load_entry_point('pcs==0.10.1', 'console_scripts', 'pcs')()
  File "/usr/lib/python3.7/site-packages/pcs/app.py", line 178, in main
    utils.get_input_modifiers(),
  File "/usr/lib/python3.7/site-packages/pcs/resource.py", line 91, in resource_cmd
    resource_list_available(lib, argv_next, modifiers)
  File "/usr/lib/python3.7/site-packages/pcs/resource.py", line 298, in resource_list_available
    not modifiers.get("--nodesc"), search
  File "/usr/lib/python3.7/site-packages/pcs/cli/common/lib_wrapper.py", line 86, in decorated_run
    return run_with_middleware(run, cli_env, *args, **kwargs)
  File "/usr/lib/python3.7/site-packages/pcs/cli/common/middleware.py", line 13, in run
    return next_in_line(env, *args, **kwargs)
  File "/usr/lib/python3.7/site-packages/pcs/cli/common/lib_wrapper.py", line 76, in run
    lib_call_result = run_library_command(lib_env, *args, **kwargs)
  File "/usr/lib/python3.7/site-packages/pcs/lib/commands/resource_agent.py", line 57, in list_agents
    for agent in resource_agent.list_resource_agents(runner, std)
  File "/usr/lib/python3.7/site-packages/pcs/lib/resource_agent.py", line 187, in list_resource_agents
    settings.crm_resource_binary, "--list-agents", standard_provider
  File "/usr/lib/python3.7/site-packages/pcs/lib/external.py", line 349, in run
    out_std, out_err = process.communicate(stdin_string)
  File "/usr/lib64/python3.7/subprocess.py", line 939, in communicate
    stdout, stderr = self._communicate(input, endtime, timeout)
  File "/usr/lib64/python3.7/subprocess.py", line 1681, in _communicate
    ready = selector.select(timeout)
  File "/usr/lib64/python3.7/selectors.py", line 415, in select
    fd_event_list = self._selector.poll(timeout)
KeyboardInterrupt

Apparently, this is a long running command now and hence shall be
protected (preferably just as the whole pcs Python-based CLI at once).
With protected, I mean made civilized, without scary tracebacks.

@tomjelinek
Copy link
Member

The traceback is invaluable when figuring out where pcs got stuck or what it was waiting for.

@jnpkrn
Copy link
Contributor Author

jnpkrn commented Apr 9, 2019

Perhaps, but still the right balance needs to be found so as not
alienate the primary audience (which maintainers of pcs are not).

Use SIGQUIT for the latter so you can still advice people to
hit the respective combo (^\ by default) to see those pesky
tracebacks if need be.

Hardly anybody using pcs as a whitebox is interested in the
unsolicited, overwhelming console spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants