action add-disk failed with "cannot import name 'filter_missing_packages'"
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Ceph OSD Charm |
New
|
Critical
|
Unassigned |
Bug Description
when using `add-disk` action I got this error:
juju run-action ceph-osd/8 add-disk osd-devices=
...
Traceback (most recent call last):
File "/var/lib/
import ceph_hooks
File "hooks/
import charms_ceph.utils as ceph
File "lib/charms_
from charmhelpers.fetch import (
ImportError: cannot import name 'filter_
...
Error is raised in `charmhelpers` package.
The ceph-osd charm has included a local copy of it at `hooks/
However, on this host, `charmhelpers` is also installed globally at:
/usr/
In charm code, when we add local modules to python sys.path, we are using:
cat actions/
...
sys.
sys.
...
So the local modules are added at the end, which python interpreter will search last.
Thus, when a global copy of package such as `charmhelpers` exists, python will use that first, which is wrong, and caused above import error.
Suggestion:
When we add local module, we should insert it at beginning, so it's preferred over system/global ones:
sys.
This issue not only exists in action/
And other charms as well.
Changed in charm-ceph-osd: | |
status: | New → Confirmed |
assignee: | nobody → Joe Guo (guoqiao) |
Hi Joe
Your analysis is correct; the charm should not depend on the system packaged version of charm-helpers which is why it ships with a local vendored-in copy. So, this is a bug.
In terms of fixing it, if you are doing so, please could you follow the pattern established in other charms:
https:/ /github. com/openstack/ charm-nova- compute/ blob/433796779e 4f31320e6c57527 f421d4e9aaacedc /actions/ pause_resume. py#L20
I can't remember why we insert at the second position rather than the first, but it does seem to be a pattern we've established!
Many thanks
Alex.