Skip to content

ceph-volume: use importlib from stdlib on Python 3.8 and up - #57650

Merged
tchaikov merged 1 commit into
ceph:mainfrom
tchaikov:wip-use-importlib
May 31, 2024
Merged

tchaikov merged 1 commit into
ceph:mainfrom
tchaikov:wip-use-importlib

Conversation

@tchaikov

@tchaikov tchaikov commented May 23, 2024 •

Copy link
Copy Markdown
Contributor

since packaging was apparently removed from pkg_resources, let's use importlib.metadata when it is available and use importlib_metadata on older Python versions.

Refs https://tracker.ceph.com/issues/66201
Signed-off-by: Kefu Chai [email protected]

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox
  • jenkins test windows
  • jenkins test rook e2e

@tchaikov
tchaikov requested a review from a team May 23, 2024 04:50
@tchaikov

Copy link
Copy Markdown
Contributor Author

@guits hi Guillaume, could you help review this change?

@tchaikov

tchaikov commented May 23, 2024 •

Copy link
Copy Markdown
Contributor Author

i also need to update ceph.spec.in to cater the needs on different distros with rpm packaging system if some of them do not have python >= 3.8 as the default python3. but would be great if this PR can get some early feedbacks.

@phlogistonjohn phlogistonjohn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Python changes generally look OK to me. Although I had to stare hard at importlib.metadata vs importlib_metadata for a long while to see the difference.

I'll wait until you have made the spec file changes you mentioned before giving final approval, unless you would like otherwise.

@tchaikov
tchaikov force-pushed the wip-use-importlib branch 2 times, most recently from 97eec68 to 63be80a Compare May 25, 2024 05:34
@tchaikov

tchaikov commented May 25, 2024 •

Copy link
Copy Markdown
Contributor Author

v2:

  • correct the link in Refs tag in commit message.
  • use pkg_resources.iter_entry_points() as the fall back.

@phlogistonjohn thank you for your review John. per https://pkgs.org/search/?q=importlib_metadata, this package is not available on, for instance, RHEL8, where the default python3 is Python 3.6.8. so i am using instead pkg_resources.iter_entry_points as the fallback in the latest revision. the upside is that it does not require the dependency of python3-importlib_metadata, the downside is that the patch is a little bit more complicated as the function name is different in pkg_resources.

since packaging was apparently removed from pkg_resources, let's use
importlib.metadata when it is available and pkg_resources on older
Python versions.

Refs https://tracker.ceph.com/issues/66201
Signed-off-by: Kefu Chai <[email protected]>
@tchaikov
tchaikov force-pushed the wip-use-importlib branch from 63be80a to 24f8e5c Compare May 26, 2024 03:03
@tchaikov

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@phlogistonjohn phlogistonjohn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks ok to me

@tchaikov

Copy link
Copy Markdown
Contributor Author

jenkins test windows

1 similar comment
@tchaikov

Copy link
Copy Markdown
Contributor Author

jenkins test windows

@tchaikov

Copy link
Copy Markdown
Contributor Author

i will try to run at least a couple tests involving ceph-volume to sanity test this change.

@tchaikov tchaikov self-assigned this May 30, 2024
@tchaikov tchaikov removed the needs-qa label May 31, 2024
@tchaikov

tchaikov commented May 31, 2024 •

Copy link
Copy Markdown
Contributor Author

@tchaikov
tchaikov merged commit 131effd into ceph:main May 31, 2024
@tchaikov
tchaikov deleted the wip-use-importlib branch May 31, 2024 08:36
@nizamial09

Copy link
Copy Markdown
Member

We started getting the below error on our kcli based environments using cephadm probably after this change. Locally I did a normal bootstrap and saw the health warning.

[ceph: root@ceph-node-00 /]# ceph health detail
HEALTH_WARN failed to probe daemons or devices; OSD count 0 < osd_pool_default_size 3
[WRN] CEPHADM_REFRESH_FAILED: failed to probe daemons or devices
    host ceph-node-00 `cephadm ceph-volume` failed: cephadm exited with an error code: 1, stderr: Inferring config /var/lib/ceph/8df4cf64-2196-11ef-b317-5254002b3226/mon.ceph-node-00/config
Non-zero exit code 1 from /usr/bin/podman run --rm --ipc=host --stop-signal=SIGTERM --net=host --entrypoint /usr/sbin/ceph-volume --privileged --group-add=disk --init -e CONTAINER_IMAGE=quay.ceph.io/ceph-ci/ceph@sha256:1b15b7a25500815a8f1461030e3e44f7d8c33c82369e3bab6ef02b778d1bd8c9 -e NODE_NAME=ceph-node-00 -e CEPH_VOLUME_SKIP_RESTORECON=yes -e CEPH_VOLUME_DEBUG=1 -v /var/run/ceph/8df4cf64-2196-11ef-b317-5254002b3226:/var/run/ceph:z -v /var/log/ceph/8df4cf64-2196-11ef-b317-5254002b3226:/var/log/ceph:z -v /var/lib/ceph/8df4cf64-2196-11ef-b317-5254002b3226/crash:/var/lib/ceph/crash:z -v /run/systemd/journal:/run/systemd/journal -v /dev:/dev -v /run/udev:/run/udev -v /sys:/sys -v /run/lvm:/run/lvm -v /run/lock/lvm:/run/lock/lvm -v /var/lib/ceph/8df4cf64-2196-11ef-b317-5254002b3226/selinux:/sys/fs/selinux:ro -v /:/rootfs -v /etc/hosts:/etc/hosts:ro -v /tmp/ceph-tmpdsud63i6:/etc/ceph/ceph.conf:z quay.ceph.io/ceph-ci/ceph@sha256:1b15b7a25500815a8f1461030e3e44f7d8c33c82369e3bab6ef02b778d1bd8c9 inventory --format=json-pretty --filter-for-batch
/usr/bin/podman: stderr exception caught by decorator
/usr/bin/podman: stderr Traceback (most recent call last):
/usr/bin/podman: stderr   File "/usr/lib/python3.9/site-packages/ceph_volume/decorators.py", line 59, in newfunc
/usr/bin/podman: stderr     return f(*a, **kw)
/usr/bin/podman: stderr   File "/usr/lib/python3.9/site-packages/ceph_volume/main.py", line 110, in main
/usr/bin/podman: stderr     self.enable_plugins()
/usr/bin/podman: stderr   File "/usr/lib/python3.9/site-packages/ceph_volume/main.py", line 75, in enable_plugins
/usr/bin/podman: stderr     plugins = _load_library_extensions()
/usr/bin/podman: stderr   File "/usr/lib/python3.9/site-packages/ceph_volume/main.py", line 180, in _load_library_extensions
/usr/bin/podman: stderr     for ep in entry_points(group=group):
/usr/bin/podman: stderr TypeError: entry_points() got an unexpected keyword argument 'group'
/usr/bin/podman: stderr Traceback (most recent call last):
/usr/bin/podman: stderr   File "/usr/sbin/ceph-volume", line 33, in <module>
/usr/bin/podman: stderr     sys.exit(load_entry_point('ceph-volume==1.0.0', 'console_scripts', 'ceph-volume')())
/usr/bin/podman: stderr   File "/usr/lib/python3.9/site-packages/ceph_volume/main.py", line 46, in __init__
/usr/bin/podman: stderr     self.main(self.argv)
/usr/bin/podman: stderr   File "/usr/lib/python3.9/site-packages/ceph_volume/decorators.py", line 59, in newfunc
/usr/bin/podman: stderr     return f(*a, **kw)
/usr/bin/podman: stderr   File "/usr/lib/python3.9/site-packages/ceph_volume/main.py", line 110, in main
/usr/bin/podman: stderr     self.enable_plugins()
/usr/bin/podman: stderr   File "/usr/lib/python3.9/site-packages/ceph_volume/main.py", line 75, in enable_plugins
/usr/bin/podman: stderr     plugins = _load_library_extensions()
/usr/bin/podman: stderr   File "/usr/lib/python3.9/site-packages/ceph_volume/main.py", line 180, in _load_library_extensions
/usr/bin/podman: stderr     for ep in entry_points(group=group):
/usr/bin/podman: stderr TypeError: entry_points() got an unexpected keyword argument 'group'
Traceback (most recent call last):
  File "/usr/lib64/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib64/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/var/lib/ceph/8df4cf64-2196-11ef-b317-5254002b3226/cephadm.7007c93708f27a439bb9273ebfa4caf4335548ffd3ae152e4a8b908274ae7f45/__main__.py", line 5647, in <module>
  File "/var/lib/ceph/8df4cf64-2196-11ef-b317-5254002b3226/cephadm.7007c93708f27a439bb9273ebfa4caf4335548ffd3ae152e4a8b908274ae7f45/__main__.py", line 5635, in main
  File "/var/lib/ceph/8df4cf64-2196-11ef-b317-5254002b3226/cephadm.7007c93708f27a439bb9273ebfa4caf4335548ffd3ae152e4a8b908274ae7f45/__main__.py", line 408, in _infer_config
  File "/var/lib/ceph/8df4cf64-2196-11ef-b317-5254002b3226/cephadm.7007c93708f27a439bb9273ebfa4caf4335548ffd3ae152e4a8b908274ae7f45/__main__.py", line 323, in _infer_fsid
  File "/var/lib/ceph/8df4cf64-2196-11ef-b317-5254002b3226/cephadm.7007c93708f27a439bb9273ebfa4caf4335548ffd3ae152e4a8b908274ae7f45/__main__.py", line 436, in _infer_image
  File "/var/lib/ceph/8df4cf64-2196-11ef-b317-5254002b3226/cephadm.7007c93708f27a439bb9273ebfa4caf4335548ffd3ae152e4a8b908274ae7f45/__main__.py", line 310, in _validate_fsid
  File "/var/lib/ceph/8df4cf64-2196-11ef-b317-5254002b3226/cephadm.7007c93708f27a439bb9273ebfa4caf4335548ffd3ae152e4a8b908274ae7f45/__main__.py", line 3380, in command_ceph_volume
  File "/var/lib/ceph/8df4cf64-2196-11ef-b317-5254002b3226/cephadm.7007c93708f27a439bb9273ebfa4caf4335548ffd3ae152e4a8b908274ae7f45/cephadmlib/call_wrappers.py", line 310, in call_throws
RuntimeError: Failed command: /usr/bin/podman run --rm --ipc=host --stop-signal=SIGTERM --net=host --entrypoint /usr/sbin/ceph-volume --privileged --group-add=disk --init -e CONTAINER_IMAGE=quay.ceph.io/ceph-ci/ceph@sha256:1b15b7a25500815a8f1461030e3e44f7d8c33c82369e3bab6ef02b778d1bd8c9 -e NODE_NAME=ceph-node-00 -e CEPH_VOLUME_SKIP_RESTORECON=yes -e CEPH_VOLUME_DEBUG=1 -v /var/run/ceph/8df4cf64-2196-11ef-b317-5254002b3226:/var/run/ceph:z -v /var/log/ceph/8df4cf64-2196-11ef-b317-5254002b3226:/var/log/ceph:z -v /var/lib/ceph/8df4cf64-2196-11ef-b317-5254002b3226/crash:/var/lib/ceph/crash:z -v /run/systemd/journal:/run/systemd/journal -v /dev:/dev -v /run/udev:/run/udev -v /sys:/sys -v /run/lvm:/run/lvm -v /run/lock/lvm:/run/lock/lvm -v /var/lib/ceph/8df4cf64-2196-11ef-b317-5254002b3226/selinux:/sys/fs/selinux:ro -v /:/rootfs -v /etc/hosts:/etc/hosts:ro -v /tmp/ceph-tmpdsud63i6:/etc/ceph/ceph.conf:z quay.ceph.io/ceph-ci/ceph@sha256:1b15b7a25500815a8f1461030e3e44f7d8c33c82369e3bab6ef02b778d1bd8c9 inventory --format=json-pretty --filter-for-batch

@guits

guits commented Jun 3, 2024

Copy link
Copy Markdown
Contributor

/usr/bin/podman: stderr TypeError: entry_points() got an unexpected keyword argument 'group'

see #57830

@zdover23

Copy link
Copy Markdown
Contributor

#58004 - Squid backport
#58005 - Reef backport
#58006 - Quincy backport

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants