mgr/cephadm: config service_url in Dashboard for Prometheus and Alert…#35194
mgr/cephadm: config service_url in Dashboard for Prometheus and Alert…#35194tchaikov merged 2 commits intoceph:masterfrom
Conversation
src/pybind/mgr/cephadm/module.py
Outdated
| elif dd.daemon_type == 'iscsi': | ||
| iscsi_daemons.append(dd) | ||
| if dd.daemon_type in ['grafana', 'iscsi', 'prometheus', 'alertmanager']: | ||
| cephadm_service = self.cephadm_services.get(dd.daemon_type) |
There was a problem hiding this comment.
Why using the get() when Python has the simpler []?
| cephadm_service = self.cephadm_services.get(dd.daemon_type) | |
| cephadm_service = self.cephadm_services[dd.daemon_type] |
There was a problem hiding this comment.
what about making self.cephadm_services a method? That would prevent others from running into the same issue?
Maybe this also solves your
post_actions = {} # type: Dict[str, Any]
problem.
CephadmServices = TypeVar('CephadmService', bound=CephadmService)
def get_service(self, what: str) -> CephadmServices: ...There was a problem hiding this comment.
Yeah, thanks! I definitely prefer that approach: encapsulating service functionality within the service class scope, rather than having the consumers of the dummy classes implementing the functionality.
Regarding the use of combinations of nested dicts + lists for storing structured data, it feels to me like bringing JSON back to Python, when even Javascript is moving towards Types & Classes (ES6, Typescript, ...). It's great to use mypy, but classes provide the only runtime type checking.
There was a problem hiding this comment.
A method is created to get services. But I think all service usage in module.py should also be refactored. It will become a bit lengthy.
e.g.
return self._add_daemon('mon', spec, self.mon_service.create)
to
# maybe change 'mon' to a constant.
return self._add_daemon('mon', spec, self._get_cephadm_service('mon').create)
| grafanas.insert(0, dd) | ||
| elif dd.daemon_type == 'iscsi': | ||
| iscsi_daemons.append(dd) | ||
| if dd.daemon_type in ['grafana', 'iscsi', 'prometheus', 'alertmanager']: |
There was a problem hiding this comment.
dd, v['daemons'].insert(0, dd)... That's closer to assembler than to Python.
What about daemon or daemon_desc and post_action['daemons'].insert(0, daemon_desc)?
Type hints are great but they cannot replace human-friendly naming. We are following that (good) practice in the dashboard front-end, so why not keeping that when coding elsewhere?
There was a problem hiding this comment.
I think that code readability is not about core developers understanding the code they have written and read dozens of times, but everyone else doing so. And yeah, we all love (and use) fully-featured Graphical IDEs with ML-based auto-completion and cloud-based indexing, but there are plenty situations out there where that doesn't work. For example:
- Github code reviews like this one,
- Tracebacks or errors: (a user facing
AttributeError: 'dd' object has no attribute 'dt'vs.AttributeError: 'daemon_desc' object has no attribute 'daemon_type'can at least open a meaningful issue:"mgr/cephadm: missing attribute 'daemon_type' in daemon_desc"vs."mgr/cephadm: missing attribute 'dt' in dd"). - Debugging a field issue on a remote system where you can barely have
vi(not even the fancy vim with your super-crafted vimrc).
There was a problem hiding this comment.
(I'm just not sure, if
vis a good name)
It's removed.
|
|
||
| def get_active_daemon(self, daemon_descrs: List[DaemonDescription]) -> DaemonDescription: |
There was a problem hiding this comment.
?
| def get_active_daemon(self, daemon_descrs: List[DaemonDescription]) -> DaemonDescription: | |
| @staticmethod | |
| def get_active_daemon(daemon_descrs: List[DaemonDescription]) -> DaemonDescription: |
There was a problem hiding this comment.
-1 for @staticmethod. I need to get the active daemon for MDS and MGR to properly schedule daemon removals. And I need self to access the mgr. Adding @staticmethod force me to remove @staticmethod again later on.
|
|
||
| def get_active_daemon(self, daemon_descrs: List[DaemonDescription]) -> DaemonDescription: |
There was a problem hiding this comment.
| def get_active_daemon(self, daemon_descrs: List[DaemonDescription]) -> DaemonDescription: | |
| @staticmethod | |
| def get_active_daemon(daemon_descrs: List[DaemonDescription]) -> DaemonDescription: |
…Manager Calling Dashboard's CLI to set service URLs after deploying Prometheus and AlertManager Daemons. Fixes: https://tracker.ceph.com/issues/45625 Signed-off-by: Kiefer Chang <kiefer.chang@suse.com>
Signed-off-by: Kiefer Chang <kiefer.chang@suse.com>
|
Rebased. |

Calling Dashboard's CLI to set service URLs after deploying Prometheus
and AlertManager Daemons.
Fixes: https://tracker.ceph.com/issues/45625
Signed-off-by: Kiefer Chang kiefer.chang@suse.com
Dashboard page
Cluster -> Monitoringis visible after setting service URLs.`
Checklist
Show available Jenkins commands
jenkins retest this pleasejenkins test classic perfjenkins test crimson perfjenkins test signedjenkins test make checkjenkins test make check arm64jenkins test submodulesjenkins test dashboardjenkins test dashboard backendjenkins test docsjenkins render docsjenkins test ceph-volume alljenkins test ceph-volume tox