Skip to content

Refactoring and consolidating services dependencies calculation logic#60800

Merged
adk3798 merged 1 commit intoceph:mainfrom
rkachach:fix_issue_deps_refactoring
Jan 22, 2025
Merged

Refactoring and consolidating services dependencies calculation logic#60800
adk3798 merged 1 commit intoceph:mainfrom
rkachach:fix_issue_deps_refactoring

Conversation

@rkachach
Copy link
Contributor

@rkachach rkachach commented Nov 22, 2024

currently, the dependency logic is duplicated between the different Service classes and the module.py::_calc_daemon_deps function, which can lead to issues such as BUGSs, difficulty in maintenance, and other problems associated with duplicated code. In this change, we are consolidating all the dependency logic into the Service subclasses to eliminate this duplication. This way, we also force anybody creating a new Service to think about its potential dependencies.

https://tracker.ceph.com/issues/69021

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

@rkachach rkachach force-pushed the fix_issue_deps_refactoring branch from 240d9d2 to 33db76b Compare November 22, 2024 14:50
@rkachach rkachach changed the title Fix issue deps refactoring Refactoring and consolidating deps calculation logic Nov 22, 2024
@rkachach rkachach changed the title Refactoring and consolidating deps calculation logic Refactoring and consolidating services dependencies calculation logic Nov 22, 2024
@rkachach rkachach force-pushed the fix_issue_deps_refactoring branch 10 times, most recently from 4b8badc to 10ef0a4 Compare November 28, 2024 16:43
@rkachach rkachach marked this pull request as ready for review November 28, 2024 16:47
@rkachach rkachach requested a review from a team as a code owner November 28, 2024 16:47
@rkachach
Copy link
Contributor Author

jenkins test dashboard cephadm

1 similar comment
@rkachach
Copy link
Contributor Author

jenkins test dashboard cephadm

Copy link
Contributor

@adk3798 adk3798 left a comment

Choose a reason for hiding this comment

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

This seems good looking it over, although this is one of those PRs that's particularly difficult to review since it's a lot of moving code around

self.log.info(f'Reconfiguring {dd.name()} (dependencies changed)...')
sym_diff = set(deps).symmetric_difference(last_deps)
self.log.debug(f'Reconfiguring {dd.name()} deps changed {last_deps} -> {deps} diff is {sym_diff}')
self.log.info(f'Reconfiguring {dd.name()} because dependencies have changed: diff {sym_diff}')
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to be logging the diffs at info level? I think the reason there is a separate log line to begin with is so we don't flood the logs with some large blob of deps at info level.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@adk3798 yeah, probably it's too much info for info level. I'll only keep that for debug.

Comment on lines +16 to +27
ServiceMap = {
CephadmAgent.TYPE: CephadmAgent,
NodeProxy.TYPE: NodeProxy,
IscsiService.TYPE: IscsiService,
PrometheusService.TYPE: PrometheusService,
GrafanaService.TYPE: GrafanaService,
AlertmanagerService.TYPE: AlertmanagerService,
PromtailService.TYPE: PromtailService,
CephExporterService.TYPE: CephExporterService,
NodeExporterService.TYPE: NodeExporterService,
JaegerAgentService.TYPE: JaegerAgentService,
MgmtGatewayService.TYPE: MgmtGatewayService
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like there ought to be some way to automate the creation of this mapping. Maybe you could take a look at the self.cephdam_services attribute in cephadm/module.py, since it's a similar thing but instead of mapping types to services it's just the list of services. I don't see any reason this list couldn't include all the services without deps either. They'll just route back to the parent function class and get an empty list.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing that out, I wasn't aware of the self.cephdam_services. Since it serves exactly the same purpose I'll just go and us it directly. As you said services with no dependencies will return an empty list (from the base class).

Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW there's a "registration via decorator" pattern I have used many times in the past. It looks vageuly like:

MY_REG = {}

def reg_decorator(cls):
   MY_REG[cls.KEY] = cls
   return cls

@reg_decorator
class MyCoolClass:
   pass

I do believe we used it in cephadm for the daemon classes, IIRC.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@phlogistonjohn @adk3798 I like the idea of automatically register/generates the services map (cephadm_services) instead of having to specify the whole list. However, in order to avoid putting more changes on this PR (which already has a lot), and to avoid mix this change with the dependencies movement I think it's better to have a dedicated PR, so I went and created the PR #61114 on top of this one with a new commit. I'll be rebasin it later once this one is merged.

Comment on lines +23 to +28
def get_daemon_names(mgr: "CephadmOrchestrator", daemons: List[str]) -> List[str]:
daemon_names = []
for daemon_type in daemons:
for dd in mgr.cache.get_daemons_by_type(daemon_type):
daemon_names.append(dd.name())
return daemon_names
Copy link
Contributor

Choose a reason for hiding this comment

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

now that this isn't some inline function in the calc_daemon_deps function, we might want to clean it up. Specifically I think it's a bit unintuitive that the parameter is daemons when it's expected to be a list of daemon types. We could also consider just having a new function in HostCache get_daemons_by_types that handles getting daemons of multiple types at once, since all it's doing is repeatedly calling to the HostCache with a different type.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@adk3798 I think it's a good idea. I created the new method and updated the code to use it. All the changes related to the review are packed in the last commit. I'll be squashing the changes later once all the comments are solved.

@rkachach rkachach force-pushed the fix_issue_deps_refactoring branch from 3c375de to 4db99d2 Compare December 10, 2024 12:08
@rkachach rkachach requested a review from adk3798 December 10, 2024 14:59
@adk3798
Copy link
Contributor

adk3798 commented Dec 11, 2024

@rkachach from my last teuthology run, I think it's possible there are some issues with this for alertmanager and ingress. From the logs of a failed test (I shortened the lines and removed a lot of the ones that weren't helpful

Dec 10 07:11:17 smithi067 ceph-mon[28526]: Reconfiguring keepalived.nfs.foo.smithi067.xfnzie because dependencies have changed: diff {'haproxy.nfs.foo.smithi086.mueemc', 'haproxy.nfs.foo.smithi067.arrqee'}
Dec 10 07:11:17 smithi067 ceph-mon[28526]: Reconfiguring daemon keepalived.nfs.foo.smithi067.xfnzie on smithi067
Dec 10 07:11:17 smithi086 ceph-mon[37685]: Reconfiguring keepalived.nfs.foo.smithi067.xfnzie because dependencies have changed: diff {'haproxy.nfs.foo.smithi086.mueemc', 'haproxy.nfs.foo.smithi067.arrqee'}
Dec 10 07:11:17 smithi086 ceph-mon[37685]: Reconfiguring daemon keepalived.nfs.foo.smithi067.xfnzie on smithi067
2024-12-10T07:11:21.049 DEBUG:teuthology.orchestra.run.smithi067:> sudo TESTDIR=/home/ubuntu/cephtest bash -ex -c 'mount -t nfs 10.0.31.67:/fake /mnt/foo'
2024-12-10T07:11:21.116 INFO:teuthology.orchestra.run.smithi067.stderr:+ mount -t nfs 10.0.31.67:/fake /mnt/foo
Dec 10 07:11:21 smithi086 ceph-mon[37685]: Reconfiguring keepalived.nfs.foo.smithi086.tbzyuk because dependencies have changed: diff {'haproxy.nfs.foo.smithi086.mueemc', 'haproxy.nfs.foo.smithi067.arrqee'}
Dec 10 07:11:21 smithi086 ceph-mon[37685]: 10.0.31.67 is in 10.0.0.0/16 on smithi086 interface enp3s0f1
Dec 10 07:11:21 smithi086 ceph-mon[37685]: 10.0.31.67 is in 10.0.0.0/16 on smithi067 interface enp3s0f1
Dec 10 07:11:21 smithi086 ceph-mon[37685]: Reconfiguring daemon keepalived.nfs.foo.smithi086.tbzyuk on smithi086
Dec 10 07:11:21 smithi067 ceph-mon[28526]: Reconfiguring keepalived.nfs.foo.smithi086.tbzyuk because dependencies have changed: diff {'haproxy.nfs.foo.smithi086.mueemc', 'haproxy.nfs.foo.smithi067.arrqee'}
Dec 10 07:11:21 smithi067 ceph-mon[28526]: 10.0.31.67 is in 10.0.0.0/16 on smithi086 interface enp3s0f1
Dec 10 07:11:21 smithi067 ceph-mon[28526]: 10.0.31.67 is in 10.0.0.0/16 on smithi067 interface enp3s0f1
Dec 10 07:11:21 smithi067 ceph-mon[28526]: Reconfiguring daemon keepalived.nfs.foo.smithi086.tbzyuk on smithi086
Dec 10 07:11:25 smithi086 ceph-mon[37685]: from='mgr.14243 172.21.15.67:0/3588716280' entity='mgr.smithi067.vvoxtb' cmd={"prefix": "dashboard get-alertmanager-api-host"} : dispatch
Dec 10 07:11:25 smithi086 ceph-mon[37685]: from='mon.0 -' entity='mon.' cmd=[{"prefix": "dashboard get-alertmanager-api-host"}]: dispatch
Dec 10 07:11:25 smithi086 ceph-mon[37685]: from='mgr.14243 172.21.15.67:0/3588716280' entity='mgr.smithi067.vvoxtb' cmd={"prefix": "dashboard get-prometheus-api-host"} : dispatch
Dec 10 07:11:25 smithi086 ceph-mon[37685]: from='mon.0 -' entity='mon.' cmd=[{"prefix": "dashboard get-prometheus-api-host"}]: dispatch
Dec 10 07:11:25 smithi086 ceph-mon[37685]: from='mgr.14243 172.21.15.67:0/3588716280' entity='mgr.smithi067.vvoxtb' cmd={"prefix": "config dump", "format": "json"} : dispatch
Dec 10 07:11:25 smithi067 ceph-mon[28526]: from='mgr.14243 172.21.15.67:0/3588716280' entity='mgr.smithi067.vvoxtb' cmd={"prefix": "dashboard get-alertmanager-api-host"} : dispatch
Dec 10 07:11:25 smithi067 ceph-mon[28526]: from='mon.0 -' entity='mon.' cmd=[{"prefix": "dashboard get-alertmanager-api-host"}]: dispatch
Dec 10 07:11:25 smithi067 ceph-mon[28526]: from='mgr.14243 172.21.15.67:0/3588716280' entity='mgr.smithi067.vvoxtb' cmd={"prefix": "dashboard get-prometheus-api-host"} : dispatch
Dec 10 07:11:25 smithi067 ceph-mon[28526]: from='mon.0 -' entity='mon.' cmd=[{"prefix": "dashboard get-prometheus-api-host"}]: dispatch
Dec 10 07:11:32 smithi067 ceph-mon[28526]: Reconfiguring alertmanager.smithi067 because dependencies have changed: diff set()
Dec 10 07:11:32 smithi067 ceph-mon[28526]: Reconfiguring daemon alertmanager.smithi067 on smithi067
Dec 10 07:11:32 smithi086 ceph-mon[37685]: Reconfiguring alertmanager.smithi067 because dependencies have changed: diff set()
Dec 10 07:11:32 smithi086 ceph-mon[37685]: Reconfiguring daemon alertmanager.smithi067 on smithi067
Dec 10 07:11:37 smithi086 ceph-mon[37685]: Reconfiguring keepalived.nfs.foo.smithi067.xfnzie because dependencies have changed: diff {'haproxy.nfs.foo.smithi086.mueemc', 'haproxy.nfs.foo.smithi067.arrqee'}
Dec 10 07:11:37 smithi086 ceph-mon[37685]: 10.0.31.67 is in 10.0.0.0/16 on smithi067 interface enp3s0f1
Dec 10 07:11:37 smithi086 ceph-mon[37685]: 10.0.31.67 is in 10.0.0.0/16 on smithi086 interface enp3s0f1
Dec 10 07:11:37 smithi086 ceph-mon[37685]: Reconfiguring daemon keepalived.nfs.foo.smithi067.xfnzie on smithi067
Dec 10 07:11:37 smithi067 ceph-mon[28526]: from='mgr.14243 172.21.15.67:0/3588716280' entity='mgr.smithi067.vvoxtb'
Dec 10 07:11:37 smithi067 ceph-mon[28526]: from='mgr.14243 172.21.15.67:0/3588716280' entity='mgr.smithi067.vvoxtb'
Dec 10 07:11:37 smithi067 ceph-mon[28526]: Reconfiguring keepalived.nfs.foo.smithi067.xfnzie because dependencies have changed: diff {'haproxy.nfs.foo.smithi086.mueemc', 'haproxy.nfs.foo.smithi067.arrqee'}
Dec 10 07:11:37 smithi067 ceph-mon[28526]: 10.0.31.67 is in 10.0.0.0/16 on smithi067 interface enp3s0f1
Dec 10 07:11:37 smithi067 ceph-mon[28526]: 10.0.31.67 is in 10.0.0.0/16 on smithi086 interface enp3s0f1
Dec 10 07:11:37 smithi067 ceph-mon[28526]: Reconfiguring daemon keepalived.nfs.foo.smithi067.xfnzie on smithi067
Dec 10 07:11:41 smithi086 ceph-mon[37685]: Reconfiguring keepalived.nfs.foo.smithi086.tbzyuk because dependencies have changed: diff {'haproxy.nfs.foo.smithi086.mueemc', 'haproxy.nfs.foo.smithi067.arrqee'}
Dec 10 07:11:41 smithi086 ceph-mon[37685]: 10.0.31.67 is in 10.0.0.0/16 on smithi086 interface enp3s0f1
Dec 10 07:11:41 smithi086 ceph-mon[37685]: 10.0.31.67 is in 10.0.0.0/16 on smithi067 interface enp3s0f1
Dec 10 07:11:41 smithi086 ceph-mon[37685]: Reconfiguring daemon keepalived.nfs.foo.smithi086.tbzyuk on smithi086
Dec 10 07:11:41 smithi067 ceph-mon[28526]: Reconfiguring keepalived.nfs.foo.smithi086.tbzyuk because dependencies have changed: diff {'haproxy.nfs.foo.smithi086.mueemc', 'haproxy.nfs.foo.smithi067.arrqee'}
Dec 10 07:11:41 smithi067 ceph-mon[28526]: 10.0.31.67 is in 10.0.0.0/16 on smithi086 interface enp3s0f1
Dec 10 07:11:41 smithi067 ceph-mon[28526]: 10.0.31.67 is in 10.0.0.0/16 on smithi067 interface enp3s0f1
Dec 10 07:11:41 smithi067 ceph-mon[28526]: Reconfiguring daemon keepalived.nfs.foo.smithi086.tbzyuk on smithi086
Dec 10 07:11:44 smithi086 ceph-mon[37685]: from='mgr.14243 172.21.15.67:0/3588716280' entity='mgr.smithi067.vvoxtb' cmd={"prefix": "dashboard get-alertmanager-api-host"} : dispatch
Dec 10 07:11:44 smithi067 ceph-mon[28526]: from='mgr.14243 172.21.15.67:0/3588716280' entity='mgr.smithi067.vvoxtb' cmd={"prefix": "dashboard get-alertmanager-api-host"} : dispatch
Dec 10 07:11:51 smithi086 ceph-mon[37685]: Reconfiguring alertmanager.smithi067 because dependencies have changed: diff set()
Dec 10 07:11:51 smithi086 ceph-mon[37685]: Reconfiguring daemon alertmanager.smithi067 on smithi067
Dec 10 07:11:51 smithi067 ceph-mon[28526]: pgmap v209: 97 pgs: 97 active+clean; 583 KiB data, 217 MiB used, 715 GiB / 715 GiB avail; 170 B/s rd, 0 op/s
Dec 10 07:11:51 smithi067 ceph-mon[28526]: from='mgr.14243 172.21.15.67:0/3588716280' entity='mgr.smithi067.vvoxtb' cmd={"prefix": "config generate-minimal-conf"} : dispatch
Dec 10 07:11:51 smithi067 ceph-mon[28526]: from='mgr.14243 172.21.15.67:0/3588716280' entity='mgr.smithi067.vvoxtb' cmd={"prefix": "auth get", "entity": "client.admin"} : dispatch
Dec 10 07:11:51 smithi067 ceph-mon[28526]: from='mgr.14243 172.21.15.67:0/3588716280' entity='mgr.smithi067.vvoxtb' cmd={"prefix": "osd tree", "states": ["destroyed"], "format": "json"} : dispatch
Dec 10 07:11:51 smithi067 ceph-mon[28526]: Reconfiguring alertmanager.smithi067 because dependencies have changed: diff set()
Dec 10 07:11:51 smithi067 ceph-mon[28526]: Reconfiguring daemon alertmanager.smithi067 on smithi067
Dec 10 07:11:56 smithi086 ceph-mon[37685]: Reconfiguring keepalived.nfs.foo.smithi067.xfnzie because dependencies have changed: diff {'haproxy.nfs.foo.smithi086.mueemc', 'haproxy.nfs.foo.smithi067.arrqee'}
Dec 10 07:11:56 smithi086 ceph-mon[37685]: 10.0.31.67 is in 10.0.0.0/16 on smithi067 interface enp3s0f1
Dec 10 07:11:56 smithi086 ceph-mon[37685]: 10.0.31.67 is in 10.0.0.0/16 on smithi086 interface enp3s0f1
Dec 10 07:11:56 smithi086 ceph-mon[37685]: Reconfiguring daemon keepalived.nfs.foo.smithi067.xfnzie on smithi067
Dec 10 07:11:56 smithi067 ceph-mon[28526]: Reconfiguring keepalived.nfs.foo.smithi067.xfnzie because dependencies have changed: diff {'haproxy.nfs.foo.smithi086.mueemc', 'haproxy.nfs.foo.smithi067.arrqee'}
Dec 10 07:11:56 smithi067 ceph-mon[28526]: 10.0.31.67 is in 10.0.0.0/16 on smithi067 interface enp3s0f1
Dec 10 07:11:56 smithi067 ceph-mon[28526]: 10.0.31.67 is in 10.0.0.0/16 on smithi086 interface enp3s0f1
Dec 10 07:11:56 smithi067 ceph-mon[28526]: Reconfiguring daemon keepalived.nfs.foo.smithi067.xfnzie on smithi067
Dec 10 07:11:59 smithi067 ceph-mon[28526]: from='mgr.14243 172.21.15.67:0/3588716280' entity='mgr.smithi067.vvoxtb' cmd={"prefix": "osd blocklist ls", "format": "json"} : dispatch
Dec 10 07:11:59 smithi086 ceph-mon[37685]: pgmap v213: 97 pgs: 97 active+clean; 583 KiB data, 217 MiB used, 715 GiB / 715 GiB avail; 341 B/s rd, 0 op/s
Dec 10 07:11:59 smithi086 ceph-mon[37685]: from='mgr.14243 172.21.15.67:0/3588716280' entity='mgr.smithi067.vvoxtb' cmd={"prefix": "osd blocklist ls", "format": "json"} : dispatch
Dec 10 07:12:00 smithi067 ceph-mon[28526]: Reconfiguring keepalived.nfs.foo.smithi086.tbzyuk because dependencies have changed: diff {'haproxy.nfs.foo.smithi086.mueemc', 'haproxy.nfs.foo.smithi067.arrqee'}
Dec 10 07:12:00 smithi067 ceph-mon[28526]: 10.0.31.67 is in 10.0.0.0/16 on smithi086 interface enp3s0f1
Dec 10 07:12:00 smithi067 ceph-mon[28526]: 10.0.31.67 is in 10.0.0.0/16 on smithi067 interface enp3s0f1
Dec 10 07:12:00 smithi067 ceph-mon[28526]: Reconfiguring daemon keepalived.nfs.foo.smithi086.tbzyuk on smithi086
Dec 10 07:12:00 smithi086 ceph-mon[37685]: from='mgr.14243 172.21.15.67:0/3588716280' entity='mgr.smithi067.vvoxtb'
Dec 10 07:12:00 smithi086 ceph-mon[37685]: from='mgr.14243 172.21.15.67:0/3588716280' entity='mgr.smithi067.vvoxtb'
Dec 10 07:12:00 smithi086 ceph-mon[37685]: Reconfiguring keepalived.nfs.foo.smithi086.tbzyuk because dependencies have changed: diff {'haproxy.nfs.foo.smithi086.mueemc', 'haproxy.nfs.foo.smithi067.arrqee'}
Dec 10 07:12:00 smithi086 ceph-mon[37685]: 10.0.31.67 is in 10.0.0.0/16 on smithi086 interface enp3s0f1
Dec 10 07:12:00 smithi086 ceph-mon[37685]: 10.0.31.67 is in 10.0.0.0/16 on smithi067 interface enp3s0f1
Dec 10 07:12:00 smithi086 ceph-mon[37685]: Reconfiguring daemon keepalived.nfs.foo.smithi086.tbzyuk on smithi086
Dec 10 07:12:03 smithi067 ceph-mon[28526]: from='mgr.14243 172.21.15.67:0/3588716280' entity='mgr.smithi067.vvoxtb' cmd={"prefix": "dashboard get-alertmanager-api-host"} : dispatch
Dec 10 07:12:03 smithi086 ceph-mon[37685]: from='mgr.14243 172.21.15.67:0/3588716280' entity='mgr.smithi067.vvoxtb' cmd={"prefix": "dashboard get-alertmanager-api-host"} : dispatch
Dec 10 07:12:04 smithi086 ceph-mon[37685]: from='mon.0 -' entity='mon.' cmd=[{"prefix": "dashboard get-alertmanager-api-host"}]: dispatch
Dec 10 07:12:04 smithi086 ceph-mon[37685]: from='mgr.14243 172.21.15.67:0/3588716280' entity='mgr.smithi067.vvoxtb' cmd={"prefix": "config dump", "format": "json"} : dispatch
Dec 10 07:12:04 smithi067 ceph-mon[28526]: from='mon.0 -' entity='mon.' cmd=[{"prefix": "dashboard get-alertmanager-api-host"}]: dispatch
Dec 10 07:12:11 smithi067 ceph-mon[28526]: Reconfiguring daemon alertmanager.smithi067 on smithi067
Dec 10 07:12:11 smithi086 ceph-mon[37685]: from='mgr.14243 172.21.15.67:0/3588716280' entity='mgr.smithi067.vvoxtb' cmd={"prefix": "config generate-minimal-conf"} : dispatch
Dec 10 07:12:11 smithi086 ceph-mon[37685]: from='mgr.14243 172.21.15.67:0/3588716280' entity='mgr.smithi067.vvoxtb' cmd={"prefix": "auth get", "entity": "client.admin"} : dispatch
Dec 10 07:12:11 smithi086 ceph-mon[37685]: from='mgr.14243 172.21.15.67:0/3588716280' entity='mgr.smithi067.vvoxtb' cmd={"prefix": "osd tree", "states": ["destroyed"], "format": "json"} : dispatch
Dec 10 07:12:11 smithi086 ceph-mon[37685]: Reconfiguring alertmanager.smithi067 because dependencies have changed: diff set()
Dec 10 07:12:11 smithi086 ceph-mon[37685]: Reconfiguring daemon alertmanager.smithi067 on smithi067
Dec 10 07:12:14 smithi086 ceph-mon[37685]: from='mgr.14243 172.21.15.67:0/3588716280' entity='mgr.smithi067.vvoxtb' cmd={"prefix": "osd blocklist ls", "format": "json"} : dispatch
Dec 10 07:12:14 smithi067 ceph-mon[28526]: from='mgr.14243 172.21.15.67:0/3588716280' entity='mgr.smithi067.vvoxtb' cmd={"prefix": "osd blocklist ls", "format": "json"} : dispatch
Dec 10 07:12:16 smithi067 ceph-mon[28526]: Reconfiguring keepalived.nfs.foo.smithi067.xfnzie because dependencies have changed: diff {'haproxy.nfs.foo.smithi086.mueemc', 'haproxy.nfs.foo.smithi067.arrqee'}
Dec 10 07:12:16 smithi067 ceph-mon[28526]: 10.0.31.67 is in 10.0.0.0/16 on smithi067 interface enp3s0f1
Dec 10 07:12:16 smithi067 ceph-mon[28526]: 10.0.31.67 is in 10.0.0.0/16 on smithi086 interface enp3s0f1
Dec 10 07:12:16 smithi067 ceph-mon[28526]: Reconfiguring daemon keepalived.nfs.foo.smithi067.xfnzie on smithi067
Dec 10 07:12:16 smithi086 ceph-mon[37685]: Reconfiguring keepalived.nfs.foo.smithi067.xfnzie because dependencies have changed: diff {'haproxy.nfs.foo.smithi086.mueemc', 'haproxy.nfs.foo.smithi067.arrqee'}
Dec 10 07:12:16 smithi086 ceph-mon[37685]: 10.0.31.67 is in 10.0.0.0/16 on smithi067 interface enp3s0f1
Dec 10 07:12:16 smithi086 ceph-mon[37685]: 10.0.31.67 is in 10.0.0.0/16 on smithi086 interface enp3s0f1
Dec 10 07:12:16 smithi086 ceph-mon[37685]: Reconfiguring daemon keepalived.nfs.foo.smithi067.xfnzie on smithi067
Dec 10 07:12:20 smithi086 ceph-mon[37685]: Reconfiguring keepalived.nfs.foo.smithi086.tbzyuk because dependencies have changed: diff {'haproxy.nfs.foo.smithi086.mueemc', 'haproxy.nfs.foo.smithi067.arrqee'}
Dec 10 07:12:20 smithi086 ceph-mon[37685]: 10.0.31.67 is in 10.0.0.0/16 on smithi086 interface enp3s0f1
Dec 10 07:12:20 smithi086 ceph-mon[37685]: 10.0.31.67 is in 10.0.0.0/16 on smithi067 interface enp3s0f1
Dec 10 07:12:20 smithi086 ceph-mon[37685]: Reconfiguring daemon keepalived.nfs.foo.smithi086.tbzyuk on smithi086
Dec 10 07:12:20 smithi067 ceph-mon[28526]: Reconfiguring keepalived.nfs.foo.smithi086.tbzyuk because dependencies have changed: diff {'haproxy.nfs.foo.smithi086.mueemc', 'haproxy.nfs.foo.smithi067.arrqee'}
Dec 10 07:12:20 smithi067 ceph-mon[28526]: 10.0.31.67 is in 10.0.0.0/16 on smithi086 interface enp3s0f1
Dec 10 07:12:20 smithi067 ceph-mon[28526]: 10.0.31.67 is in 10.0.0.0/16 on smithi067 interface enp3s0f1
Dec 10 07:12:20 smithi067 ceph-mon[28526]: Reconfiguring daemon keepalived.nfs.foo.smithi086.tbzyuk on smithi086
Dec 10 07:12:23 smithi067 ceph-mon[28526]: from='mgr.14243 172.21.15.67:0/3588716280' entity='mgr.smithi067.vvoxtb' cmd={"prefix": "dashboard get-alertmanager-api-host"} : dispatch
Dec 10 07:12:23 smithi086 ceph-mon[37685]: from='mgr.14243 172.21.15.67:0/3588716280' entity='mgr.smithi067.vvoxtb' cmd={"prefix": "dashboard get-alertmanager-api-host"} : dispatch
Dec 10 07:12:24 smithi067 ceph-mon[28526]: from='mon.0 -' entity='mon.' cmd=[{"prefix": "dashboard get-alertmanager-api-host"}]: dispatch
Dec 10 07:12:24 smithi067 ceph-mon[28526]: from='mgr.14243 172.21.15.67:0/3588716280' entity='mgr.smithi067.vvoxtb' cmd={"prefix": "config dump", "format": "json"} : dispatch
Dec 10 07:12:24 smithi086 ceph-mon[37685]: from='mon.0 -' entity='mon.' cmd=[{"prefix": "dashboard get-alertmanager-api-host"}]: dispatch
Dec 10 07:12:31 smithi086 ceph-mon[37685]: Reconfiguring alertmanager.smithi067 because dependencies have changed: diff set()
Dec 10 07:12:31 smithi086 ceph-mon[37685]: Reconfiguring daemon alertmanager.smithi067 on smithi067
Dec 10 07:12:31 smithi067 ceph-mon[28526]: from='mgr.14243 172.21.15.67:0/3588716280' entity='mgr.smithi067.vvoxtb' cmd={"prefix": "config generate-minimal-conf"} : dispatch
Dec 10 07:12:31 smithi067 ceph-mon[28526]: from='mgr.14243 172.21.15.67:0/3588716280' entity='mgr.smithi067.vvoxtb' cmd={"prefix": "auth get", "entity": "client.admin"} : dispatch
Dec 10 07:12:31 smithi067 ceph-mon[28526]: from='mgr.14243 172.21.15.67:0/3588716280' entity='mgr.smithi067.vvoxtb' cmd={"prefix": "osd tree", "states": ["destroyed"], "format": "json"} : dispatch
Dec 10 07:12:31 smithi067 ceph-mon[28526]: Reconfiguring alertmanager.smithi067 because dependencies have changed: diff set()
Dec 10 07:12:31 smithi067 ceph-mon[28526]: Reconfiguring daemon alertmanager.smithi067 on smithi067
Dec 10 07:12:36 smithi086 ceph-mon[37685]: Reconfiguring keepalived.nfs.foo.smithi067.xfnzie because dependencies have changed: diff {'haproxy.nfs.foo.smithi086.mueemc', 'haproxy.nfs.foo.smithi067.arrqee'}
Dec 10 07:12:36 smithi086 ceph-mon[37685]: 10.0.31.67 is in 10.0.0.0/16 on smithi067 interface enp3s0f1
Dec 10 07:12:36 smithi086 ceph-mon[37685]: 10.0.31.67 is in 10.0.0.0/16 on smithi086 interface enp3s0f1
Dec 10 07:12:36 smithi086 ceph-mon[37685]: Reconfiguring daemon keepalived.nfs.foo.smithi067.xfnzie on smithi067
Dec 10 07:12:36 smithi067 ceph-mon[28526]: Reconfiguring keepalived.nfs.foo.smithi067.xfnzie because dependencies have changed: diff {'haproxy.nfs.foo.smithi086.mueemc', 'haproxy.nfs.foo.smithi067.arrqee'}
Dec 10 07:12:36 smithi067 ceph-mon[28526]: 10.0.31.67 is in 10.0.0.0/16 on smithi067 interface enp3s0f1
Dec 10 07:12:36 smithi067 ceph-mon[28526]: 10.0.31.67 is in 10.0.0.0/16 on smithi086 interface enp3s0f1
Dec 10 07:12:36 smithi067 ceph-mon[28526]: Reconfiguring daemon keepalived.nfs.foo.smithi067.xfnzie on smithi067
Dec 10 07:12:41 smithi067 ceph-mon[28526]: Reconfiguring keepalived.nfs.foo.smithi086.tbzyuk because dependencies have changed: diff {'haproxy.nfs.foo.smithi086.mueemc', 'haproxy.nfs.foo.smithi067.arrqee'}
Dec 10 07:12:41 smithi067 ceph-mon[28526]: 10.0.31.67 is in 10.0.0.0/16 on smithi086 interface enp3s0f1
Dec 10 07:12:41 smithi067 ceph-mon[28526]: 10.0.31.67 is in 10.0.0.0/16 on smithi067 interface enp3s0f1
Dec 10 07:12:41 smithi067 ceph-mon[28526]: Reconfiguring daemon keepalived.nfs.foo.smithi086.tbzyuk on smithi086
Dec 10 07:12:41 smithi067 ceph-mon[28526]: pgmap v234: 97 pgs: 97 active+clean; 583 KiB data, 217 MiB used, 715 GiB / 715 GiB avail; 170 B/s rd, 0 op/s
Dec 10 07:12:41 smithi086 ceph-mon[37685]: Reconfiguring keepalived.nfs.foo.smithi086.tbzyuk because dependencies have changed: diff {'haproxy.nfs.foo.smithi086.mueemc', 'haproxy.nfs.foo.smithi067.arrqee'}
Dec 10 07:12:41 smithi086 ceph-mon[37685]: 10.0.31.67 is in 10.0.0.0/16 on smithi086 interface enp3s0f1
Dec 10 07:12:41 smithi086 ceph-mon[37685]: 10.0.31.67 is in 10.0.0.0/16 on smithi067 interface enp3s0f1
Dec 10 07:12:41 smithi086 ceph-mon[37685]: Reconfiguring daemon keepalived.nfs.foo.smithi086.tbzyuk on smithi086
Dec 10 07:12:43 smithi067 ceph-mon[28526]: from='mgr.14243 172.21.15.67:0/3588716280' entity='mgr.smithi067.vvoxtb' cmd={"prefix": "dashboard get-alertmanager-api-host"} : dispatch
Dec 10 07:12:43 smithi086 ceph-mon[37685]: from='mgr.14243 172.21.15.67:0/3588716280' entity='mgr.smithi067.vvoxtb' cmd={"prefix": "dashboard get-alertmanager-api-host"} : dispatch
Dec 10 07:12:44 smithi086 ceph-mon[37685]: from='mon.0 -' entity='mon.' cmd=[{"prefix": "dashboard get-alertmanager-api-host"}]: dispatch
Dec 10 07:12:44 smithi067 ceph-mon[28526]: from='mon.0 -' entity='mon.' cmd=[{"prefix": "dashboard get-alertmanager-api-host"}]: dispatch
Dec 10 07:12:50 smithi086 ceph-mon[37685]: Reconfiguring daemon alertmanager.smithi067 on smithi067
Dec 10 07:12:50 smithi067 ceph-mon[28526]: Reconfiguring alertmanager.smithi067 because dependencies have changed: diff set()
Dec 10 07:12:50 smithi067 ceph-mon[28526]: Reconfiguring daemon alertmanager.smithi067 on smithi067

from https://pulpito.ceph.com/adking-2024-12-10_06:38:28-orch:cephadm-wip-adk-testing-2024-12-09-2041-distro-default-smithi/8028102/, I see some daemons getting reconfigured quite a bit. Do you think this is a result of some bug in this PR?

Comment on lines +632 to +633
@staticmethod
def get_dependencies(mgr: "CephadmOrchestrator") -> List[str]:
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be a classmethod since it uses class level parameters

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@phlogistonjohn TBH I'm not sure it's the case as we don't use any class argument (such as cls). This method only relies on the mgr argument in general so I think in this case is in fact a staticmethod.

Copy link
Contributor

@phlogistonjohn phlogistonjohn Dec 17, 2024

Choose a reason for hiding this comment

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

I generally (almost always) review code patch-by-patch. In my view, every patch should tell it's own "story". So when I first looked at the patch I immediately saw code in this function like:
port = cast(int, mgr.get_module_option_ex('prometheus', 'server_port', PrometheusService.DEFAULT_MGR_PROMETHEUS_PORT))

Where PrometheusService is the class that this method is attached to. When I see a staticmethod that refers to it's own class by name I always recommend using a classmethod. The main reason is that a classmethod works better with inheritance. For example:

class Foo:
    SECRET = 'abracadabra'
    @staticmethod
    def whats_my_line():
        return Foo.SECRET

class Bar:
    SECRET = 'open sesame'

In this example, the behavior of Bar.whats_my_line is a bit surprising to the unaware: it'll return 'abracadabra' not 'open sesame' because the function call always returns Foo's SECRET attribute. If the funciton was instead written as:

@classmethod
def whats_my_line(cls):
    return cls.SECRET

then things generally work as many people would expect.

Note I do not object to staticmethod when there are zero references to the class at all, like in many other examples in this patch.

That all said, I do now see that the final version of this function in the PR removes these class references. But I was looking at it patch-by-patch. I prefer each patch to be "complete" - but I won't insist on it in a case like this.

Does all this make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@phlogistonjohn

Yes it does! thank your for your patience and for the detailed explanation :)

In fact, I didn’t look/notice the specific example you pointed out regarding the reference to the class itself for Prometheus in the code.:

port = cast(int, mgr.get_module_option_ex('prometheus', 'server_port', PrometheusService.DEFAULT_MGR_PROMETHEUS_PORT))

I think this usage alone is strong enough to justify using a classmethod instead of a staticmethod in this case. I’ve updated the code to use a classmethod in all the methods.

Comment on lines +16 to +27
ServiceMap = {
CephadmAgent.TYPE: CephadmAgent,
NodeProxy.TYPE: NodeProxy,
IscsiService.TYPE: IscsiService,
PrometheusService.TYPE: PrometheusService,
GrafanaService.TYPE: GrafanaService,
AlertmanagerService.TYPE: AlertmanagerService,
PromtailService.TYPE: PromtailService,
CephExporterService.TYPE: CephExporterService,
NodeExporterService.TYPE: NodeExporterService,
JaegerAgentService.TYPE: JaegerAgentService,
MgmtGatewayService.TYPE: MgmtGatewayService
Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW there's a "registration via decorator" pattern I have used many times in the past. It looks vageuly like:

MY_REG = {}

def reg_decorator(cls):
   MY_REG[cls.KEY] = cls
   return cls

@reg_decorator
class MyCoolClass:
   pass

I do believe we used it in cephadm for the daemon classes, IIRC.

Comment on lines +2935 to +2936
svc_cls = ServiceMap.get(daemon_type, None)
deps = svc_cls.get_dependencies(self, spec, daemon_type) if svc_cls else []
Copy link
Contributor

Choose a reason for hiding this comment

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

🎉

Comment on lines +23 to +24
@staticmethod
def get_dependencies(mgr: "CephadmOrchestrator",
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be a classmethod and it would behave "correctly" wrt inheritance.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same comment as above :)

@rkachach
Copy link
Contributor Author

jenkins retest this please

@github-actions
Copy link

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

currently, the dependency logic is duplicated between the different Service
classes and the module.py::_calc_daemon_deps function, which can lead
to issues such as BUGSs, difficulty in maintenance, and other problems
associated with duplicated code. In this change, we are consolidating
all the dependency logic into the Service subclasses to eliminate this
duplication. This way, we also force anybody creating a new Service to
think about its potential dependencies.

Fixes: https://tracker.ceph.com/issues/69021
Signed-off-by: Redouane Kachach <[email protected]>
@rkachach rkachach force-pushed the fix_issue_deps_refactoring branch from 52a7f75 to 1280f01 Compare January 14, 2025 09:34
@adk3798
Copy link
Contributor

adk3798 commented Jan 21, 2025

jenkins test api

@adk3798
Copy link
Contributor

adk3798 commented Jan 21, 2025

@adk3798
Copy link
Contributor

adk3798 commented Jan 21, 2025

jenkins test api

@adk3798 adk3798 merged commit b40036b into ceph:main Jan 22, 2025
4 checks passed
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.

3 participants