Skip to content

mgr/cephadm: config service_url in Dashboard for Prometheus and Alert…#35194

Merged
tchaikov merged 2 commits intoceph:masterfrom
bk201:wip-45625
May 28, 2020
Merged

mgr/cephadm: config service_url in Dashboard for Prometheus and Alert…#35194
tchaikov merged 2 commits intoceph:masterfrom
bk201:wip-45625

Conversation

@bk201
Copy link
Contributor

@bk201 bk201 commented May 22, 2020

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 -> Monitoring is visible after setting service URLs.
`

Checklist

  • References tracker ticket
  • Updates documentation if necessary
  • Includes tests for new functionality or reproducer for bug

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 backend
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox

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)
Copy link
Member

Choose a reason for hiding this comment

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

Why using the get() when Python has the simpler []?

Suggested change
cephadm_service = self.cephadm_services.get(dd.daemon_type)
cephadm_service = self.cephadm_services[dd.daemon_type]

Copy link
Contributor

@sebastian-philipp sebastian-philipp May 25, 2020

Choose a reason for hiding this comment

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

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: ...

Copy link
Member

Choose a reason for hiding this comment

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

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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']:
Copy link
Member

Choose a reason for hiding this comment

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

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?

Copy link
Contributor

Choose a reason for hiding this comment

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

  1. DaemonDescription is one of the fundamental data types here in mgr/cephadm. Having short names for them is imo a good thing.

  2. At least, I'm getting a nice mouse-over:

image

(I'm just not sure, if v is a good name)

Copy link
Member

Choose a reason for hiding this comment

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

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).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(I'm just not sure, if v is a good name)

It's removed.

Copy link
Member

@epuertat epuertat left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for addressing my comments @bk201 !

Comment on lines 193 to +194

def get_active_daemon(self, daemon_descrs: List[DaemonDescription]) -> DaemonDescription:
Copy link
Member

Choose a reason for hiding this comment

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

?

Suggested change
def get_active_daemon(self, daemon_descrs: List[DaemonDescription]) -> DaemonDescription:
@staticmethod
def get_active_daemon(daemon_descrs: List[DaemonDescription]) -> DaemonDescription:

Copy link
Contributor

Choose a reason for hiding this comment

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

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

Comment on lines 307 to +308

def get_active_daemon(self, daemon_descrs: List[DaemonDescription]) -> DaemonDescription:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
def get_active_daemon(self, daemon_descrs: List[DaemonDescription]) -> DaemonDescription:
@staticmethod
def get_active_daemon(daemon_descrs: List[DaemonDescription]) -> DaemonDescription:

bk201 added 2 commits May 28, 2020 09:27
…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>
@bk201
Copy link
Contributor Author

bk201 commented May 28, 2020

Rebased.

@tchaikov tchaikov merged commit 698fe28 into ceph:master May 28, 2020
@bk201 bk201 deleted the wip-45625 branch July 10, 2020 04:07
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.

4 participants