/srv/irclogs.ubuntu.com/2020/09/30/#smooth-operator.txt

Chipaca👋08:17
bthomasMorning Chipaca08:26
bthomasChipaca: If a hook changes Config will the change persist in the next hook that is called ? Of course I know one can use StoredState for persistence.08:27
Chipacabthomas: can a hook change config?08:28
bthomasChipaca: Have not tried or looked into code. I was under the impression it is an associative array. Guessing by your question, it can not.08:30
Chipacabthomas: we have a test that would fail if you could08:30
bthomasChipaca: Nice. Thanks for clarifying. Back to StoredState :)08:30
bthomasChipaca: In https://github.com/canonical/prometheus-operator/pull/3/files Justin added a function _get_image_tag which required mocking in every test. jam felt we may have a problem with "layering" here. I do not see any other alternative than the once I have suggested in the review comment. IMHO the right "layer" for such functionality is lower down the stack, in Juju or Operator Framework. Thoughts ?09:50
bthomasRefering to this comment : https://github.com/canonical/prometheus-operator/pull/3/files#r49707434009:55
facubatista¡Muy buenos días a todos!10:58
Chipacafacubatista: 👋❗10:58
Chipacabthomas: looking10:58
bthomasनमस्ते facubatista10:59
facubatistahola Chipaca, bthomas :)10:59
bthomasThanks Chipaca11:01
bthomasChipaca: you made a suggetion to avoid mentioning class name, for example `ConfigChanged` in the doc string of `ConfigChangedEvent`. I will follow through and update all such instances. However I noticed that for these event classes, the one line summary docstring is usually written as "Represents the `config-canged` hook from Juju". Would it reasonable to alter such lines as "An event triggered on configuration change" then lo11:16
bthomasin the same doc string, metion that this event "invokes the `config_changed` hook".11:16
Chipacabthomas: in meetings; i'll get back to you when i can11:59
bthomasno problem11:59
jambthomas, if we were using resources directly, juju would be providing the digest for you to be using. I'm not a huge fan of hitting the docker registry from the charm (it has all sorts of implications for offline deploys, etc)12:25
jambut I can accept it as a "way to get channel like behavior for now"12:25
bthomasjam Thanks for the insight. I appreciate our current constraints. I have responded to Justin's question regarding "layering" by suggesting doing the patching at setUp and tearDown. This should obviate the impact on all tests, if it is acceptable.12:30
jambthomas, so ideally it would be more something that we could inject into the charm via a parameter, rather than being patched (IMO). (intended to be configured, vs 'look here is a way to get what I want')12:58
jamand then we would have direct tests of the request based behavior, but split out from the other tests12:58
bthomasjam I do agree with you that using a configuration mechanism (a means of injecting) makes testing simpler. My quandary is that the present requirements do require replacing (partially) a config parameter with a dynamically (runtime) generated one.13:41
jambthomas, so I mentioned on the bug.  I think we do want StoredState to prevent unrelated changes from causing us to upgrade a patch version of the application13:41
jamwe should confirm with jldev regarding how we get "smooth transitions of application versions" when we have channels13:42
jamand try to mimic that behavior13:42
jambut my understanding is that it isn't "pods are updated automatically when things are pushed to the rocks store"13:42
bthomasgot it. Thanks.13:43
* bthomas nudges Chipaca regarding rewording the one line descriptions of event classes ^14:24
bthomas:)14:25
aluriahi o/ - I had a look to the grafana-operator and prometheus-operator code (to better understand the approach I should take to enable relations between charms) and I have a couple of questions14:30
Chipacaaluria: 👋14:31
Chipacashoot14:31
aluria1) minor doubt: I think the grafana-source interface should be set in metadata.yaml the other way around. I think it doesn't mind from the point of view of sharing data but the prometheus-operator defines grafana-source in "requires" when it should be in "provides", as it sets host/IP and port for the grafana charm to configure the datasource endpoint14:32
aluria(same, grafana-operator should have the grafana-source interface as requires, because it will use "get" methods)14:33
aluria2) the other Q is that I've seen some code using EventSource and .emit, but I don't quite understand it. I don't see a .observe counterpart and I'm not sure if the way that would work would be similar to the reactive framework use of states (set_flag and then is_flag_set or @when)14:35
aluriain the grafana and prometheus operator charms, I think they only take care of the -joined, -changed and -departed hooks being observe. EventSource is not used14:35
aluria3) [sorry, bonus Q] the prometheus-operator uses StoredState - iiuc, that should be used in a similar way as unitdata is used in charmhelpers? (make use of previously retrieved data to avoid a call to relation-get, etc.) ?14:37
aluriaChipaca: ^ :)14:37
Chipacaaluria: just in case, could you link to the code you're talking about?14:41
aluriaChipaca: https://github.com/canonical/grafana-operator and https://github.com/canonical/prometheus-operator14:46
Chipacahmm, justin isn't on irc14:47
Chipacabthomas: ^ but you're right there :)14:47
bthomasaluria With regard to Q1, it may help to think of Grafana as a "Dashboard Service Provider" and Prometheus as a data source that "requires a dashboard service".14:50
bthomasWith regard to Q2 at least as far as Prometheus was concerned there was no need to emit any event. It was suffecient to just handle events emitted by Juju.14:52
aluriabthomas: re Q2, an example of using .emit is here https://github.com/johnsca/interface-mysql/blob/master/interface_mysql.py#L68 and the "on_changed" method... it looks like when the config-changed hook runs, ".emit" will trigger a -relation-changed hook, right? Is that the use case?14:52
aluriare: Q1, ok if that works for you - I usually relate "provides" with the need of "relation-set" calls, while "requires" needs "relation-get" calls14:54
bthomasaluria: a quick looks shows that that charm is emitting an event database_lost because it had a record of a database connection which now seems to have gone.14:55
bthomasaluria: with regard to Q1 you may want to further discuss this with jam and jldev who are experts on the matter.14:56
bthomasWith regard to Q3, all I can say is that StoredState is used to persist data across hook invocations. Use it if you have a use case for it.14:56
Chipacaaluria: in general a component (not a charm) would create custom events and emit() them when whatever situation they're modeling happens14:58
Chipacaaluria: users of that component would observe those events if they needed to react to them, but it's fine if they don't14:59
Chipacasame as your charm doesn't need to write handlers for all juju events14:59
bthomasChipaca: what do you mean by "component" as opposed to charm.14:59
Chipacaaluria: a database interface for example14:59
Chipacaaluria: interfaces, in general15:00
Chipacaaluria: i have seen some charms creating custom events and emiting them instead of just calling a function, but it's a bad smell15:00
Chipacaie it wouldn't pass review15:00
aluriathat would be similar to interfaces in the reactive framework, when they use set_flag and clear_flag?15:01
aluriagood to know re: emitting vs calling a func directly15:01
justinclarkChipaca and aluria I'm here for any Grafana-specific questions now. Sorry for not being on here sooner15:14
Chipacajustinclark: 1 sec15:21
Chipaca<aluria> 1) minor doubt: I think the grafana-source interface should be set in metadata.yaml the other way around. I think it doesn't mind from the point of view of sharing data but the prometheus-operator defines grafana-source in "requires" when it should be in "provides", as it sets host/IP and port for the grafana charm to configure the datasource endpoint15:21
Chipaca<aluria> (same, grafana-operator should have the grafana-source interface as requires, because it will use "get" methods)15:21
aluriajustinclark: hey, sorry was on a call - this is the backlog https://pastebin.ubuntu.com/p/jGpsppkjHV/15:21
Chipaca<aluria> 2) the other Q is that I've seen some code using EventSource and .emit, but I don't quite understand it. I don't see a .observe counterpart and I'm not sure if the way that would work would be similar to the reactive framework use of states (set_flag and then is_flag_set or @when)15:21
Chipaca<aluria> in the grafana and prometheus operator charms, I think they only take care of the -joined, -changed and -departed hooks being observe. EventSource is not used15:21
Chipaca<aluria> 3) [sorry, bonus Q] the prometheus-operator uses StoredState - iiuc, that should be used in a similar way as unitdata is used in charmhelpers? (make use of previously retrieved data to avoid a call to relation-get, etc.) ?15:21
aluriaoh, that will also work :D15:22
Chipacajustinclark: that's all the Qs :)15:22
Chipacaheh, sorry15:22
aluriaChipaca: thx for the info re: interfaces and the use of .emit - I have to review that and find what is the suggested approach. I'll have a close look to the database interface (shared before), the prometheus interface (https://git.launchpad.net/interface-prometheus/tree/operator.py#n74) and see what it fits me in my current case15:24
Chipacajustinclark: wrt the 'v' prefix, you could use packaging instead of semver15:27
Chipacaie from packaging.version import parse15:27
Chipacaparse('1.2.3') == parse('v1.2.3')15:27
justinclarkChipaca thanks - let me take a look. I *really* don't like the current handling of the 'v' prefix15:29
* facubatista -> lunch15:51
bthomasNice. I am liking package.version. If that works for you justinclark then there may be no need to retain both original tag and parsed tag. Kudos Chipaca15:53
justinclarkbthomas it looks like Prometheus has inconsistent version strings sometimes so I think it would still be safer to retain the original tag. But this does get rid of the need to remove 'v' which is really nice.16:01
bthomasjustinclark: exactly I did notice that. As mentioned in my review comment that is why I found your solution to keep both original tags and parsed tags an acceptable solution to deal with this evil situation :). But thanks to Chipaca looks like you have a better solution now.16:04
justinclarkWell, even with packaging, it is not straightforward how we consistently reconstruct version strings like: "v2.21.0-rc.0" and "0.16.0rc1". Both of which are real examples of tags Prometheus has16:06
justinclarkI'm just thinking we should be safe and keep the original string rather than assume we can recreate the original.16:07
bthomassucks16:07
* bthomas start barking loudly 16:07
bthomasjustinclark: they seem to be more consistent on recent versions though.16:09
bthomasanyway you decide16:09
justinclarkI saw that too. I think I'll keep the current version for now just in case the format changes in the future. Hopefully it will save future developers the headache.16:10
bthomasI am tempted to ask the question on the prometheus forum if the have a well defined format for the version tags ? ;-)16:11
Chipacaa shame packaging doesn't hang on to the original string, but ¯\_(ツ)_/¯16:24
justinclarkHaha that would certainly give me confidence to reconstruct the version, bthomas.16:26
bthomasyep. Again perhaps we should highlight your use case and create an issue on their issue tracker.16:27
* justinclark lunch16:47
aluriacory_fu: hi - would you have ~10min? I'm trying to understand what this does https://github.com/johnsca/charm-gitlab-k8s/blob/c2423f4ec2718a0b5acebe0242f88aa0a1706f39/src/charm.py#L3817:47
aluriaI guess I don't understand the second arg (self), and if it calls the on_database_lost method17:47
aluriaI did see the .emit call comes from https://github.com/johnsca/interface-mysql/blob/master/interface_mysql.py#L9717:48
Chipacaaluria: that no longer works, but when it did it was equivalent to self.framework.observe(self.mysql.on.database_lost, self.on_database_lost)18:38
* facubatista eods, will be back on Friday19:59

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!