Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cross-model dashboards #29

Merged
merged 19 commits into from
Oct 7, 2021

Conversation

rbarry82
Copy link
Contributor

No description provided.

balbirthomas
balbirthomas previously approved these changes Sep 23, 2021
Copy link
Contributor

@balbirthomas balbirthomas left a comment

Choose a reason for hiding this comment

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

The code changes look clean too me. However I am only minimally familiar with context here so can not evaluate the deeper ramifications of this change. Perhaps a commit message providing context may be useful.

mmanciop
mmanciop previously approved these changes Oct 5, 2021
@rbarry82 rbarry82 requested a review from jnsgruk October 5, 2021 23:18
@@ -1,3 +1,9 @@
/venv
*.py[cod]
*.charm
.flake8
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no .flake8 anymore

Comment on lines +7 to +9
CONTRIBUTING.md
INTEGRATING.md
RELEASE.md
Copy link
Contributor

Choose a reason for hiding this comment

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

File comment:
iiuc, .jujuignore is only needed to blacklist specific things that got glob-whitelisted by charmcraft.yaml.
In this particular case it seems that this file is not needed at all.

Comment on lines +49 to +52
rlist = [] # type: List[Any]
for i in obj:
rlist.append(type_convert_stored(i))
return rlist
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
rlist = [] # type: List[Any]
for i in obj:
rlist.append(type_convert_stored(i))
return rlist
return list(map(type_convert_stored, obj))

@@ -89,7 +118,8 @@ def __init__(
self,
charm: CharmBase,
name: str,
event_relation: str = "monitoring",
event_relation: Optional[str] = "monitoring",
Copy link
Contributor

Choose a reason for hiding this comment

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

Based on the code in this PR's diff it seems that None is not a valid value. Drop the Optional?

Suggested change
event_relation: Optional[str] = "monitoring",
event_relation = "monitoring",

Comment on lines +372 to +375
[
relation.units > 0
for relation in self.charm.model.relations[self._stored.event_relation]
]
Copy link
Contributor

Choose a reason for hiding this comment

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

Square brackets are redundant here

Suggested change
[
relation.units > 0
for relation in self.charm.model.relations[self._stored.event_relation]
]
relation.units > 0
for relation in self.charm.model.relations[self._stored.event_relation]

@@ -325,6 +399,7 @@ def __init__(self, charm: CharmBase, name: str) -> None:
super().__init__(charm, name)
self.charm = charm
self.name = name
self.source_relation = "grafana-source"
Copy link
Contributor

Choose a reason for hiding this comment

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

This is invariant - consider moving to class variable.

# Figure out our Prometheus relation and template the query

try:
prom_rel = self.charm.model.relations[self.source_relation][0]
Copy link
Contributor

Choose a reason for hiding this comment

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

Unclear why [0] is taken

@@ -398,32 +493,40 @@ def _validate_dashboard_data(self, data: Dict, rel: Relation) -> None:
if not grafana_datasource:
return

# Import at runtime so we don't get client dependencies
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand this. What do you mean by "client dependency"? Why here is "at runtime" compared to top of file?

event: a :class:`UpgradeCharmEvent` to signal the upgrade
"""
self._configure(event)
self._on_dashboards_changed(event)
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to move this into the provider lib, similar to what you have with the consumer?
Unless _configure must happen before..?

@mmanciop mmanciop merged commit 76530ed into canonical:main Oct 7, 2021
@mmanciop
Copy link
Contributor

mmanciop commented Oct 7, 2021

@sed-i I did not see your comments before merging this, I'll address them in a PR I am working on to streamline the constructors

@rbarry82 rbarry82 deleted the fix/cross-model-relations branch January 28, 2022 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants