Bug 33627 - AppCenter: init() seems to fail or not yet called
AppCenter: init() seems to fail or not yet called
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: UMC - App-Center
UCS 3.2
Other Linux
: P5 normal (vote)
: UCS 4.0-2-errata
Assigned To: Florian Best
Dirk Wiesenthal
:
Depends on:
Blocks: 34235
  Show dependency treegraph
 
Reported: 2013-12-02 11:41 CET by Dirk Wiesenthal
Modified: 2015-05-28 16:49 CEST (History)
4 users (show)

See Also:
What kind of report is it?: ---
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional): Error handling, External feedback
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Wiesenthal univentionstaff 2013-12-02 11:41:33 CET
We received two tracebacks:

Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.6/univention/management/console/modules/__init__.py",
line 204, in execute
    func( request )
  File "/usr/lib/pymodules/python2.6/univention/management/console/modules/decorators.py",
line 305, in _response
    result = _multi_response(self, request)
  File "/usr/lib/pymodules/python2.6/univention/management/console/modules/decorators.py",
line 432, in _response
    for res in function(self, iterator, *nones):
  File "/usr/lib/pymodules/python2.6/univention/management/console/modules/decorators.py",
line 271, in _fake_func
    yield function(self, *args)
  File
"/usr/lib/pymodules/python2.6/univention/management/console/modules/appcenter/__init__.py",
line 469, in components_query
    self.uu.ucr_reinit()
AttributeError: 'Instance' object has no attribute 'uu'


and


 Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.6/univention/management/console/modules/__init__.py",
line 204, in execute
    func( request )
  File "/usr/lib/pymodules/python2.6/univention/management/console/modules/decorators.py",
line 305, in _response
    result = _multi_response(self, request)
  File "/usr/lib/pymodules/python2.6/univention/management/console/modules/decorators.py",
line 432, in _response
    for res in function(self, iterator, *nones):
  File "/usr/lib/pymodules/python2.6/univention/management/console/modules/decorators.py",
line 271, in _fake_func
    yield function(self, *args)
  File
"/usr/lib/pymodules/python2.6/univention/management/console/modules/appcenter/__init__.py",
line 105, in query
    self.package_manager.reopen_cache()
AttributeError: 'Instance' object has no attribute 'package_manager'


I would have thought this is impossible.

self.uu and self.package_manager are both initialized in init(). Seems that this command either fails silently with a traceback or that it is not yet finished.

If I time.sleep() in init() all other commands wait as well so this cannot be the reason.

I checked the code before self.package_manager = [...] and could not identify any line that could cause a traceback. But: If it fails for whatever reason this goes unnoticed. I did not find any log information anywhere about a traceback in init().

However, it would be helpful if we:
 * put all the init() stuff in __init__() -> guaranteed to be executed
 * put all the __init__() stuff in try/except and log it somewhere

Maybe log tracebacks in init() (would require a patch against umc-server)?
Comment 1 Alexander Kläser univentionstaff 2013-12-05 22:47:11 CET
(In reply to Dirk Wiesenthal from comment #0) 
> ...
> I would have thought this is impossible.

In fact, quite some errors reported via Piwik happen when opening the app center UMC module. These seem probably related to the tracebacks you mentioned.

> self.uu and self.package_manager are both initialized in init(). Seems that
> this command either fails silently with a traceback or that it is not yet
> finished.

I also observed that tracebacks within theses methods are not written to the log files.

> If I time.sleep() in init() all other commands wait as well so this cannot
> be the reason.
> 
> I checked the code before self.package_manager = [...] and could not
> identify any line that could cause a traceback. But: If it fails for
> whatever reason this goes unnoticed. I did not find any log information
> anywhere about a traceback in init().

What about the following line, could it provoke an error?

> util.install_opener(self.ucr)

> However, it would be helpful if we:
>  * put all the init() stuff in __init__() -> guaranteed to be executed
>  * put all the __init__() stuff in try/except and log it somewhere

Not sure whether this is a good idea. From the code documentation:
> *init*: Is invoked after the module process has been initialised. At that 
> moment, the settings, like locale and username and password are available.
 
> Maybe log tracebacks in init() (would require a patch against umc-server)?

Hm… in modserver.py, the stacktrace is recorded, yet it is not printed out. I nvestigated the problem a bit and opened Bug 33673.
Comment 2 Dirk Wiesenthal univentionstaff 2014-01-17 12:21:35 CET
Maybe self.package_manager = PackageManager() failed. See Bug #33944 (Syntax error in /etc/apt/sources.list*)
Comment 3 Dirk Wiesenthal univentionstaff 2014-01-22 15:00:23 CET
Bug #33673 will improve tracebacks. Currently, I do not know what to fix.

If Comment 2 is correct, then a fix is really hard. Actually I would leave it this way. What is the App Center supposed to do when apt.Cache() is unavailable? It cannot workaround this issue! (Even apt-get is unavailable in this case!)
I would say always show an error. Just like it does now when init() fails...
At best one could
  except SystemError as e: re.match(SOME_APT_ERROR_REGEX, str(e)) and raise UMC_Error('check your apt/sources.list!')

Remove errata tag for now. Wait for more feedback, prepare to resolve as WONTFIX.
Comment 4 Florian Best univentionstaff 2014-03-04 09:05:27 CET
The very same both tracebacks have been reported again:
3.2-0 errata17 (Borgfeld) → Ticket #2014030321012411
3.2-0 errata0 (Borgfeld) → Ticket #2014021021003445
Comment 5 Florian Best univentionstaff 2014-03-04 10:17:34 CET
If this has nothing to do with the appcenter this bug can be marked as duplicate of Bug #34235.
Comment 6 Florian Best univentionstaff 2015-02-19 14:47:55 CET
Maybe related to Bug #34235 Bug #33848 Bug #37400
Comment 7 Florian Best univentionstaff 2015-03-10 11:44:17 CET
Fixed by Bug #33673?
Comment 8 Dirk Wiesenthal univentionstaff 2015-04-08 11:35:48 CEST
The error message should be something else now, but the underlying problem still exists.

We need an unobtrusive message that something went wrong during initializing. It is most probably a problem with the package manager and this is probably due to a broken sources.list. We have also seen "Not enough disk space"...

I think you can except apt.SystemError when initializing the PackageManager
Comment 9 Florian Best univentionstaff 2015-05-13 11:49:17 CEST
(In reply to Dirk Wiesenthal from comment #8)
> The error message should be something else now, but the underlying problem
> still exists.
> 
> We need an unobtrusive message that something went wrong during
> initializing. It is most probably a problem with the package manager and
> this is probably due to a broken sources.list. We have also seen "Not enough
> disk space"...
> 
> I think you can except apt.SystemError when initializing the PackageManager
Yes, you are right. I implemented the catch which shows a user friendly message now. Btw: apt.SystemError does not exists, it is the python SystemError!

YAML: 2015-05-12-univention-management-console-module-appcenter.yaml
Package: univention-management-console-module-appcenter
Version: 4.1.20-26.353.201505131140

YAML: 2015-05-12-univention-lib.yaml
Package: univention-lib
Version: 4.0.5-16.300.201505131140
Comment 10 Dirk Wiesenthal univentionstaff 2015-05-21 16:27:32 CEST
I think there might be a problem with the finished status:

When the package manager can not be initialized while trying to uninstall an app, it is still in "working mode". Fixing the problem (which may be just waiting while the files are re-generated) does not really help, because from now on the package manager refuses to uninstall because it thinks it is still busy.
Comment 11 Florian Best univentionstaff 2015-05-22 16:13:05 CEST
(In reply to Dirk Wiesenthal from comment #10)
> I think there might be a problem with the finished status:
> 
> When the package manager can not be initialized while trying to uninstall an
> app, it is still in "working mode". Fixing the problem (which may be just
> waiting while the files are re-generated) does not really help, because from
> now on the package manager refuses to uninstall because it thinks it is
> still busy.
You are right. Fixed directly in package manger lib in svn r60852.
The error should have been the same, before.
Comment 12 Dirk Wiesenthal univentionstaff 2015-05-27 10:14:20 CEST
OK, works fine
Comment 13 Janek Walkenhorst univentionstaff 2015-05-28 16:46:28 CEST
<http://errata.univention.de/ucs/4.0/196.html>
Comment 14 Janek Walkenhorst univentionstaff 2015-05-28 16:49:42 CEST
<http://errata.univention.de/ucs/4.0/203.html>