oamg / leapp

Leapp - Application & OS Modernization Framework (For in-place upgrades, follow leapp-repository)
https://oamg.github.io/leapp/
Apache License 2.0
87 stars 70 forks source link

Better output of `snactor discover` when inspection fails #338

Open vojtechsokol opened 6 years ago

vojtechsokol commented 6 years ago

When an actor or a model contains a bug, snactor discover fails and no output is shown.

Reproducer: Install leapp framework, create new repo and actor:

pip install git+https://github.com/leapp-to/leapp
snactor repo new discover-bug
cd discover-bug
snactor new-actor discover-bug

The actor is buggy, as it is missing a tag attribute.

Running snactor discover fails because of this:

$ snactor discover

Process Process-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
    self.run()
  File "/usr/lib/python2.7/multiprocessing/process.py", line 114, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python2.7/dist-packages/leapp/repository/actor_definition.py", line 26, in inspect_actor
    result = [get_actor_metadata(actor) for actor in get_actors()]
  File "/usr/local/lib/python2.7/dist-packages/leapp/actors/__init__.py", line 276, in get_actors
    get_actor_metadata(actor)
  File "/usr/local/lib/python2.7/dist-packages/leapp/actors/__init__.py", line 261, in get_actor_metadata
    _get_attribute(actor, 'tags', _is_tag_tuple, required=True),
  File "/usr/local/lib/python2.7/dist-packages/leapp/actors/__init__.py", line 242, in _get_attribute
    raise MissingActorAttributeError('Actor {} is missing attribute {}'.format(actor, name))
MissingActorAttributeError: Actor <class 'actor.DiscoverBug'> is missing attribute tags
No handlers could be found for logger "leapp.repository.discover-bug"
Inspection of actor in actors/bug failed

Similar thing happens when there is a bug in a model - create new model and don't fill in the topic:

snactor new-model buggy-model

The discover subcommand now does not output the traceback but still doesn't show the discovered objects.

$ snactor discover

Missing topic in Model BuggyModel

I expect the discover subcommand to deal with the buggy objects and show object where inspection was ok and possibly also the buggy ones, e.g.:

$ snactor discover
Repository:
  Name: common
  Path: /home/vsokol/leapp-actors/repos/common

Actors(2):
   - ActorExample1                 actors/actorexample1
   - ActorExample2                 actors/actorexample2

Models(0):

Tags(0):

Topics(0):

Workflows(0):

Inspection failures(1):
   - Actor: DiscoverBug            actors/discover-bug      Missing attribute 'tags'
   - Model: BuggyModel             models/buggy-model.py    Missing topic
shaded-enmity commented 6 years ago

@vinzenz @vojtechsokol This is something that bites me almost every time, I think we should switch to using ast module for discover so that we can handle this use case in a more robust way.

shaded-enmity commented 5 years ago

I whip up something quick, @vojtechsokol can you please try #375 ?

vojtechsokol commented 5 years ago

I think this issue shouldn't be closed as the problem still persists. If I use the solution from #375, the traceback is gone which is nice, however I don't get any information if there is some failure.

bocekm commented 4 years ago

Related: RHELLEAPP-980