Skip to content

buildbot.errors.PluginDBError when importing custom www plugin #7306

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

Closed
p12tic opened this issue Dec 22, 2023 · 4 comments
Closed

buildbot.errors.PluginDBError when importing custom www plugin #7306

p12tic opened this issue Dec 22, 2023 · 4 comments
Labels

Comments

@p12tic
Copy link
Member

p12tic commented Dec 22, 2023

Got this error on buildbot.buildbot.net:

checking basedir
checking for running master
checking master.cfg
Errors loading configuration:
  error while parsing config file: 'buildbot_travis.ep' is not a package (traceback in logfile)
Unhandled error in Deferred:

Traceback (most recent call last):
  File "<string>", line 27, in <module>
    
  File "/home/bbuser/workdir/buildbot/master/buildbot/master.py", line 102, in __init__
    self._services_d = self.create_child_services()
  File "/home/bbuser/buildbot_venv/lib/python3.9/site-packages/twisted/internet/defer.py", line 2256, in unwindGenerator
    return _cancellableInlineCallbacks(gen)
  File "/home/bbuser/buildbot_venv/lib/python3.9/site-packages/twisted/internet/defer.py", line 2168, in _cancellableInlineCallbacks
    _inlineCallbacks(None, gen, status, _copy_context())
--- <exception caught here> ---
  File "/home/bbuser/buildbot_venv/lib/python3.9/site-packages/twisted/internet/defer.py", line 2000, in _inlineCallbacks
    result = context.run(gen.send, result)
  File "/home/bbuser/workdir/buildbot/master/buildbot/master.py", line 188, in create_child_services
    self.www = wwwservice.WWWService()
  File "/home/bbuser/workdir/buildbot/master/buildbot/www/service.py", line 198, in __init__
    self.apps = get_plugins('www', None, load_now=True)
  File "/home/bbuser/workdir/buildbot/master/buildbot/plugins/db.py", line 366, in get_plugins
    return _DB.add_namespace(namespace, interface, load_now)
  File "/home/bbuser/workdir/buildbot/master/buildbot/plugins/db.py", line 316, in add_namespace
    tempo.load()
  File "/home/bbuser/workdir/buildbot/master/buildbot/plugins/db.py", line 253, in load
    self._tree.load()
  File "/home/bbuser/workdir/buildbot/master/buildbot/plugins/db.py", line 130, in load
    child.load()
  File "/home/bbuser/workdir/buildbot/master/buildbot/plugins/db.py", line 59, in load
    self._value = self._loader(self._entry)
  File "/home/bbuser/workdir/buildbot/master/buildbot/plugins/db.py", line 231, in _load_entry
    raise PluginDBError(f'Unable to load {self._group}:{entry.name}: {str(e)}') from e
buildbot.errors.PluginDBError: Unable to load buildbot.www:buildbot_travis: 'buildbot_travis.ep' is not a package
@p12tic
Copy link
Member Author

p12tic commented Dec 22, 2023

Root cause is that #7270 introduced usage of importlib.resources as a replacement for importlib_resources. The new APIs are more strict with the parameters. The fix is to use __package__ as the first argument to buildbot.www.plugin.Application.

@p12tic
Copy link
Member Author

p12tic commented Dec 22, 2023

Fixed in #7305 for builtin buildbot www plugins.

@p12tic p12tic added the bug label Dec 22, 2023
@p12tic
Copy link
Member Author

p12tic commented Dec 22, 2023

Fixed in buildbot/buildbot_travis#148 for buildbot_travis.

@p12tic p12tic closed this as completed Dec 22, 2023
@yan12125
Copy link
Contributor

Root cause is that #7270 introduced usage of importlib.resources as a replacement for importlib_resources. The new APIs are more strict with the parameters. The fix is to use __package__ as the first argument to buildbot.www.plugin.Application.

Sorry for the breakage. Just to clarify: importlib_resources is generally a "newer" API than importlib.resources. In this case, the restriction for the first argument is relaxed in importlib_resources 5.10.0 [1][2], or importlib.resources as of Python 3.12 [3]. If you want to keep backward compatibility for plugins, you can use:

if sys.version_info[:2] >= (3, 12):
    # TODO: document why 3.12 is needed
    import importlib.resources as importlib_resources
else:
    import importlib_resources

Also, the breakage caused by #7270 is not always fixed only by a simple replacement. In cases where __package__ and __name__ are different, importlib_resources may look into a different path for files after the replacement, and thus plugin developers may need to reorganize the filesystem layout for static assets. This is not an issue for buildbot_travis as buildbot_travis.ep is right below buildbot_travis.

[1] python/importlib_resources#258
[2] https://importlib-resources.readthedocs.io/en/latest/history.html#v5-10-0
[3] https://github.com/python/importlib_resources#compatibility

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

No branches or pull requests

2 participants