[08:17] 👋 [08:26] Morning Chipaca [08:27] Chipaca: 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:28] bthomas: can a hook change config? [08:30] Chipaca: 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] bthomas: we have a test that would fail if you could [08:30] Chipaca: Nice. Thanks for clarifying. Back to StoredState :) [09:50] Chipaca: 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:55] Refering to this comment : https://github.com/canonical/prometheus-operator/pull/3/files#r497074340 [10:58] ¡Muy buenos días a todos! [10:58] facubatista: 👋❗ [10:58] bthomas: looking [10:59] नमस्ते facubatista [10:59] hola Chipaca, bthomas :) [11:01] Thanks Chipaca [11:16] Chipaca: 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 lo [11:16] in the same doc string, metion that this event "invokes the `config_changed` hook". [11:59] bthomas: in meetings; i'll get back to you when i can [11:59] no problem [12:25] bthomas, 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] but I can accept it as a "way to get channel like behavior for now" [12:30] jam 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:58] bthomas, 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] and then we would have direct tests of the request based behavior, but split out from the other tests [13:41] jam 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] bthomas, 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 application [13:42] we should confirm with jldev regarding how we get "smooth transitions of application versions" when we have channels [13:42] and try to mimic that behavior [13:42] but my understanding is that it isn't "pods are updated automatically when things are pushed to the rocks store" [13:43] got it. Thanks. [14:24] * bthomas nudges Chipaca regarding rewording the one line descriptions of event classes ^ [14:25] :) [14:30] hi 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 questions [14:31] aluria: 👋 [14:31] shoot [14:32] 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 endpoint [14:33] (same, grafana-operator should have the grafana-source interface as requires, because it will use "get" methods) [14:35] 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) [14:35] 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 used [14:37] 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.) ? [14:37] Chipaca: ^ :) [14:41] aluria: just in case, could you link to the code you're talking about? [14:46] Chipaca: https://github.com/canonical/grafana-operator and https://github.com/canonical/prometheus-operator [14:47] hmm, justin isn't on irc [14:47] bthomas: ^ but you're right there :) [14:50] aluria 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:52] With 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] bthomas: 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:54] re: Q1, ok if that works for you - I usually relate "provides" with the need of "relation-set" calls, while "requires" needs "relation-get" calls [14:55] aluria: 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:56] aluria: with regard to Q1 you may want to further discuss this with jam and jldev who are experts on the matter. [14:56] With 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:58] aluria: in general a component (not a charm) would create custom events and emit() them when whatever situation they're modeling happens [14:59] aluria: users of that component would observe those events if they needed to react to them, but it's fine if they don't [14:59] same as your charm doesn't need to write handlers for all juju events [14:59] Chipaca: what do you mean by "component" as opposed to charm. [14:59] aluria: a database interface for example [15:00] aluria: interfaces, in general [15:00] aluria: i have seen some charms creating custom events and emiting them instead of just calling a function, but it's a bad smell [15:00] ie it wouldn't pass review [15:01] that would be similar to interfaces in the reactive framework, when they use set_flag and clear_flag? [15:01] good to know re: emitting vs calling a func directly [15:14] Chipaca and aluria I'm here for any Grafana-specific questions now. Sorry for not being on here sooner [15:21] justinclark: 1 sec [15:21] 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 endpoint [15:21] (same, grafana-operator should have the grafana-source interface as requires, because it will use "get" methods) [15:21] justinclark: hey, sorry was on a call - this is the backlog https://pastebin.ubuntu.com/p/jGpsppkjHV/ [15:21] 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] 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 used [15:21] 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:22] oh, that will also work :D [15:22] justinclark: that's all the Qs :) [15:22] heh, sorry [15:24] Chipaca: 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 case [15:27] justinclark: wrt the 'v' prefix, you could use packaging instead of semver [15:27] ie from packaging.version import parse [15:27] parse('1.2.3') == parse('v1.2.3') [15:29] Chipaca thanks - let me take a look. I *really* don't like the current handling of the 'v' prefix [15:51] * facubatista -> lunch [15:53] Nice. 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 Chipaca [16:01] bthomas 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:04] justinclark: 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:06] Well, 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 has [16:07] I'm just thinking we should be safe and keep the original string rather than assume we can recreate the original. [16:07] sucks [16:07] * bthomas start barking loudly [16:09] justinclark: they seem to be more consistent on recent versions though. [16:09] anyway you decide [16:10] I 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:11] I am tempted to ask the question on the prometheus forum if the have a well defined format for the version tags ? ;-) [16:24] a shame packaging doesn't hang on to the original string, but ¯\_(ツ)_/¯ [16:26] Haha that would certainly give me confidence to reconstruct the version, bthomas. [16:27] yep. Again perhaps we should highlight your use case and create an issue on their issue tracker. [16:47] * justinclark lunch [17:47] cory_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#L38 [17:47] I guess I don't understand the second arg (self), and if it calls the on_database_lost method [17:48] I did see the .emit call comes from https://github.com/johnsca/interface-mysql/blob/master/interface_mysql.py#L97 [18:38] aluria: that no longer works, but when it did it was equivalent to self.framework.observe(self.mysql.on.database_lost, self.on_database_lost) [19:59] * facubatista eods, will be back on Friday