Skip to content

cephadm: add a more generic daemon_to_container function - #54424

Merged
adk3798 merged 17 commits into
ceph:mainfrom
phlogistonjohn:jjm-cephadm-daemon-to-container
Nov 29, 2023
Merged

adk3798 merged 17 commits into
ceph:mainfrom
phlogistonjohn:jjm-cephadm-daemon-to-container

Conversation

@phlogistonjohn

@phlogistonjohn phlogistonjohn commented Nov 8, 2023 •

Copy link
Copy Markdown
Contributor

Depends on #54403

Complete the conversion effort started in #54403 by adding a new daemon_to_container function that works similarly to how get_container worked but in a class based and much more uniform way.

By using daemon_to_container instead of get_container within the daemon type classes we break the last major (there could be some minor ones lingering) circular dependency that prevents us from moving the deamon type classes to files in cephadmlib.

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

@github-actions

github-actions Bot commented Nov 9, 2023

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@phlogistonjohn
phlogistonjohn force-pushed the jjm-cephadm-daemon-to-container branch from fb48843 to 5de518a Compare November 9, 2023 20:48
@phlogistonjohn
phlogistonjohn force-pushed the jjm-cephadm-daemon-to-container branch 2 times, most recently from 699d2dc to f2ef63f Compare November 14, 2023 21:27
Use the CustomContainer.create classmethod like most other blocks of
code in the get_container function.

Signed-off-by: John Mulligan <[email protected]>
This prevents a test failure in future refactoring changes.

Signed-off-by: John Mulligan <[email protected]>
In get_container, convert calls to get_container_binds and
get_container_mounts to direct uses of the ContainerDaemonForm customize
methods, avoiding constructing said ContainerDaemonForm subclasses
redundantly.
This is all done in one pass because the _update_podman_mounts function
is called by get_container_mounts and trying to convert each type at a
time would result in extra calls to that function.

Signed-off-by: John Mulligan <[email protected]>
Add the function daemon_to_container in the container_daemon_form.py
function. This function is roughly equivalent to `get_container` in
cephadm.py but entirely relies on subclasses implementing
ContainerDaemonForm methods and avoids special casing of daemon
types.

It duplicates the functionality provided by functions in cephadm.py with
regards to special podman specific behaviors. I feel that this is a
minor issue because due to recent refactoring those functions are now
the one- or two-liners that are copied here. I gated them behind
arguments `auto_podman_mounts` and `auto_podman_args` that default to
true in order to make the function more reusable - however I don't need
them that way and if it seems like extra complexity for no win, we can
remove them later.

Signed-off-by: John Mulligan <[email protected]>
Switch the ceph daemon type class to call daemon_to_container instead of
get_container in the class's container method. This breaks a dependency loop
between the class and the get_container function hopefully enabling future
clean ups and code moves.

Signed-off-by: John Mulligan <[email protected]>
Switch the snmp daemon type class to call daemon_to_container instead of
get_container in the class's container method. This breaks a dependency loop
between the class and the get_container function hopefully enabling future
clean ups and code moves.

Signed-off-by: John Mulligan <[email protected]>
Switch the monitoring daemon type class to call daemon_to_container instead of
get_container in the class's container method. This breaks a dependency loop
between the class and the get_container function hopefully enabling future
clean ups and code moves.

Signed-off-by: John Mulligan <[email protected]>
Switch the nfs daemon type class to call daemon_to_container instead of
get_container in the class's container method. This breaks a dependency loop
between the class and the get_container function hopefully enabling future
clean ups and code moves.

Signed-off-by: John Mulligan <[email protected]>
Switch the iscsi daemon type class to call daemon_to_container instead of
get_container in the class's container method. This breaks a dependency loop
between the class and the get_container function hopefully enabling future
clean ups and code moves.

Signed-off-by: John Mulligan <[email protected]>
Switch the nvmeof daemon type class to call daemon_to_container instead of
get_container in the class's container method. This breaks a dependency loop
between the class and the get_container function hopefully enabling future
clean ups and code moves.

Signed-off-by: John Mulligan <[email protected]>
Switch the ceph exporter daemon type class to call daemon_to_container
instead of get_container in the class's container method. This breaks a
dependency loop between the class and the get_container function
hopefully enabling future clean ups and code moves.

Signed-off-by: John Mulligan <[email protected]>
Switch the haproxy daemon type class to call daemon_to_container instead of
get_container in the class's container method. This breaks a dependency loop
between the class and the get_container function hopefully enabling future
clean ups and code moves.

Signed-off-by: John Mulligan <[email protected]>
Switch the keepalived daemon type class to call daemon_to_container instead of
get_container in the class's container method. This breaks a dependency loop
between the class and the get_container function hopefully enabling future
clean ups and code moves.

Signed-off-by: John Mulligan <[email protected]>
Switch the tracing daemon type class to call daemon_to_container instead of
get_container in the class's container method. This breaks a dependency loop
between the class and the get_container function hopefully enabling future
clean ups and code moves.

Signed-off-by: John Mulligan <[email protected]>
…ction

Switch the custom container daemon type class to call
daemon_to_container instead of get_container in the class's container
method. This breaks a dependency loop between the class and the
get_container function hopefully enabling future clean ups and code
moves.

Signed-off-by: John Mulligan <[email protected]>
With get_container basically equivalent to daemon_to_container except
one creates a ContainerDaemonForm and the other requires one, we
can rework get_container to act as a thin wrapper around
daemon_to_container.

Signed-off-by: John Mulligan <[email protected]>
@phlogistonjohn
phlogistonjohn force-pushed the jjm-cephadm-daemon-to-container branch from f2ef63f to 8e08d3c Compare November 17, 2023 13:13
Remove the call to get_container from the iscsi class's
get_tcmu_runner_container method, replacing it with a call to the
daemon_to_container function. While they're roughly equivalent -
we can consider get_container legacy and only for use in cephadm.py
where daemon_to_container is more general.

Signed-off-by: John Mulligan <[email protected]>
@phlogistonjohn
phlogistonjohn force-pushed the jjm-cephadm-daemon-to-container branch from 8e08d3c to a4e7f35 Compare November 17, 2023 13:17
@phlogistonjohn
phlogistonjohn marked this pull request as ready for review November 17, 2023 13:19
@phlogistonjohn
phlogistonjohn requested a review from a team as a code owner November 17, 2023 13:19
@adk3798

adk3798 commented Nov 28, 2023

Copy link
Copy Markdown
Contributor

https://pulpito.ceph.com/adking-2023-11-27_13:04:25-orch:cephadm-wip-adk-testing-2023-11-26-1627-distro-default-smithi/

Lots of failures, but 14/18 are just infra/teuthology issues caused by

2023-11-27T13:26:02.342 DEBUG:teuthology.orchestra.run.smithi137:> sudo yum -y install ceph
2023-11-27T13:26:02.676 INFO:teuthology.orchestra.run.smithi137.stdout:Updating Subscription Management repositories.
2023-11-27T13:26:03.273 INFO:teuthology.orchestra.run.smithi172.stdout:Installed products updated.
2023-11-27T13:26:03.453 INFO:teuthology.orchestra.run.smithi172.stdout:
2023-11-27T13:26:03.454 INFO:teuthology.orchestra.run.smithi172.stdout:Installed:
2023-11-27T13:26:03.454 INFO:teuthology.orchestra.run.smithi172.stdout:  ceph-test-2:18.0.0-7549.gc8a64eba.el8.x86_64
2023-11-27T13:26:03.454 INFO:teuthology.orchestra.run.smithi172.stdout:  jq-1.6-3.el8.x86_64
2023-11-27T13:26:03.454 INFO:teuthology.orchestra.run.smithi172.stdout:  libcephsqlite-2:18.0.0-7549.gc8a64eba.el8.x86_64
2023-11-27T13:26:03.454 INFO:teuthology.orchestra.run.smithi172.stdout:  oniguruma-6.8.2-2.el8.x86_64
2023-11-27T13:26:03.454 INFO:teuthology.orchestra.run.smithi172.stdout:  socat-1.7.4.1-1.el8.x86_64
2023-11-27T13:26:03.454 INFO:teuthology.orchestra.run.smithi172.stdout:  xmlstarlet-1.6.1-20.el8.x86_64
2023-11-27T13:26:03.454 INFO:teuthology.orchestra.run.smithi172.stdout:
2023-11-27T13:26:03.454 INFO:teuthology.orchestra.run.smithi172.stdout:Complete!
2023-11-27T13:26:03.590 DEBUG:teuthology.orchestra.run.smithi172:> sudo yum -y install ceph
2023-11-27T13:26:03.925 INFO:teuthology.orchestra.run.smithi172.stdout:Updating Subscription Management repositories.
2023-11-27T13:26:04.232 INFO:teuthology.orchestra.run.smithi137.stdout:Last metadata expiration check: 0:01:24 ago on Mon 27 Nov 2023 01:24:40 PM UTC.
2023-11-27T13:26:05.338 INFO:teuthology.orchestra.run.smithi172.stdout:Last metadata expiration check: 0:01:26 ago on Mon 27 Nov 2023 01:24:39 PM UTC.
2023-11-27T13:26:05.751 INFO:teuthology.orchestra.run.smithi137.stderr:Error:
2023-11-27T13:26:05.751 INFO:teuthology.orchestra.run.smithi137.stderr: Problem: conflicting requests
2023-11-27T13:26:05.751 INFO:teuthology.orchestra.run.smithi137.stderr:  - nothing provides lua-devel needed by ceph-2:18.0.0-7549.gc8a64eba.el8.x86_64
2023-11-27T13:26:05.752 INFO:teuthology.orchestra.run.smithi137.stdout:(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)
2023-11-27T13:26:05.829 DEBUG:teuthology.orchestra.run:got remote process result: 1

Other than that, 5 failures

Overall, should only block merging for two PRs causing new failures.

@adk3798 adk3798 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.

LGTM, one comment but I wouldn't block merging over it. I'm okay with the auto_podman... stuff as well. I think it's nice to have the option there even if there isn't a use case for it yet.

Comment thread src/cephadm/cephadm.py
host_network=host_network,
daemon = daemon_form_create(ctx, ident)
assert isinstance(daemon, ContainerDaemonForm)
privileged = ident.daemon_type in {'mon', 'osd', CephIscsi.daemon_type}

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.

NIT, but I think it would be nice to standardize the list of daemon types that need to run with --privileged. There's another spot in this PR that says

privileged = self.identity.daemon_type in ['mon', 'osd']

which already doesn't include the ISCSI daemon type as this set does here. If we had one constant somewhere that listed all the types that need it, we could just reference it whenever needed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point. I generally feel that this knowledge should be kept within each ContainerDaemonForm class but I was already running out of energy to "refactor all the things".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That said, I think this PR is OK as is as these kinds of improvements can be done later.

@adk3798
adk3798 merged commit f82d879 into ceph:main Nov 29, 2023
@phlogistonjohn
phlogistonjohn deleted the jjm-cephadm-daemon-to-container branch November 29, 2023 20:10
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.

2 participants