[06:18] <xavpaice> is there a current documentation repo for making fresh shiny new charms using charmcraft?  Other than the obvious readme in the repo (which is really good), there was some stuff on discourse which is somewhat out of date now given that we're not doing submodules and so on
[08:18] <Chipaca> bthomas: ｇｏｏｏｏｏｏｏｏｏｏｏｏｏｏｏｏｏｏｏｏｏｏｄ  ｍｏｒｎｉｎｇ！
[08:20] <bthomas> Morning Chipaca
[08:21] <bthomas> Chipaca: I may have a couple (probably more) questions today. I will try and type them here. Do you prefer I ask you in the morning or post lunch ?
[08:21] <bthomas> This is for the hook documentation.
[08:21] <Chipaca> bthomas: why wait :)
[08:21] <bthomas> Awesome thank you.
[08:21] <Chipaca> ask them now, and i'll answer when and if i'm able :)
[08:21] <Chipaca> irc is async \o/
[08:21] <Chipaca> (less async than email, but hey)
[08:22] <bthomas> Ok. I like to dig a bit before asking. So it will be intermittent through the day.
[08:22] <Chipaca> 👍
[08:23] <Chipaca> please don't wait to ask 🙂 better wait for me to reply than that
[09:07] <bthomas> Chipaca: I will number questions through the day. This is Q1) What is the operator interface for a leader to set some key/value pair ? (i.e. what is the equivalent of "leader-set" from the reactive world). Same question for "leader-get"
[09:09] <bthomas> I am reading this reactive docs for leadership api : https://discourse.juju.is/t/implementing-leadership/1124
[09:37] <bthomas> Chipaca: Q2): I am going through the Hook Context and Tools docs at https://discourse.juju.is/t/the-hook-environment-hook-tools-and-how-hooks-are-run/1047 . How much of this is still valid in the operator framework ? For instance are all the environment variables (including relation variables) and hook tools still available to Operator Charm hooks ?
[10:15] <Chipaca> bthomas: leader-get and -set are not implemented by operator. I think (but would like jam to confirm) that it's because we haven't yet found a use case that wouldn't be better served by setting data on the peer relation.
[10:16] <Chipaca> (that's for Q1)
[10:17] <bthomas> Got it. Thanks.
[10:17] <Chipaca> bthomas: re Q2, the hook environment and tools are what operator builds on to present the interface that it does to charmers. There shouldn't be a need to use things from the lower level, but they're there if needed (and if we see it being needed, we would typically model it inside operator somehow)
[10:18] <Chipaca> bthomas: munging Q1 and Q2, the pgsql interface uses leader-set and -get to poke at leader data directly (we think it would be better done on the peer relation, and that's part of an ongoing conversation)
[10:24] <bthomas> Chipaca: In view of your answer to Q2 it sounds prudent to hide these lower level interfaces and not expose them in Charmhub documentation, thereby discouraging their use. I shall adopt this approach for now and followup with jam and jldev, regarding their viewpoint on the matter.
[10:24] <Chipaca> sgtm
[11:12] <facubatista> ¡Muy buenos días a todos!
[11:16] <facubatista> xavpaice, did you check this tutorial? https://discourse.juju.is/t/how-to-build-a-charm-using-modern-tools/3246
[12:26] <mup> PR operator#401 closed: fix docstring on Harness.add_relation_unit WRT events <Created by chipaca> <Merged by chipaca> <https://github.com/canonical/operator/pull/401>
[12:27] <bthomas> Chipaca: Your response to Q1 implies that only Juju decides which unit is leader. A Charm can not decide this. Correct me if I am wrong here.
[12:28] <Chipaca> ah, the problem with "do X if Y" is that ¬Y means I can do *anything* :-D
[12:30] <bthomas> Indeed. But Charm can not set leadership since it has no means to trigger and leader_elected event or leader_settings_chagned event.
[12:33] <Chipaca> bthomas: electing leadership is beyond the abilities of the proles^Wcharms
[12:34] <bthomas> Ok thanks. I get it quorum sensing, paxos and the like, is stuff a charm would rather leave to Juju :-).
[12:38] <bthomas> I asked the question because the discourse hook doc linked above suggests a Charm may decide if a unit is the leader, in the leader-elected doc lines (quoted) "If the election process is done internally to the application, other code should be used to signal the leader to Juju."
[12:39] <Chipaca> bthomas: that's the application deciding it's the leader, not the charm
[12:44] <bthomas> Chipaca: In that case, the differences between an application deciding its leader and the units deciding their leader is not obvious. It is not clear if and why a cham needs to be aware of or respond to an "applications electing leader".
[12:44] <Chipaca> bthomas: I don't follow
[12:48] <bthomas> Chipaca: I was just explaining why I asked the question if we can assume that only Juju decides the leader unit. I pointed out that the current charm hook docs suggest that "application" may make the leadership decision "internally" . I interpreted your response as meaning leadership among units is different from leadership within the application. I did not understand this response and was trying to probe it further.
[12:49] <Chipaca> bthomas: in the normal case, juju decies who the leader is, and sends an event to the charm to that effect, and the charm reconfigures the application (or whatever is needed to implement "you be the leader now")
[12:49] <bthomas> Got it . Thanks.
[12:49] <Chipaca> bthomas: in some cases instead the application itself decides who the new leader is, and needs to arrange some way to tell juju
[12:49] <Chipaca> bthomas: this way does not involve the charm
[12:50] <bthomas> Chipaca: Ah I see now. Do we need to document this, if it does not involve the Charm ?
[12:51] <Chipaca> no, i don't think we do
[12:51] <bthomas> great thank you.
[13:20] <Chipaca> bthomas: could i get a review of https://github.com/canonical/charmcraft/pull/150 ?
[13:20] <mup> PR charmcraft#150: when failing to create hard link attempt to use shutil.copy2 <Created by matuskosut> <https://github.com/canonical/charmcraft/pull/150>
[13:20] <bthomas> Chipaca: will do
[13:33] <bthomas> Chipaca: Q3) Since a Charm is expected to use relation data rather than setting leader data, only one use case remains for the "leader_settings_changed" event. This is the use case of notifying the current leader, that it will no longer be the leader. Is this correct ? However soon after this event, one would also expect a "leader_elected" event to also invariably fire, when the new leader is elected. Can I hence say, that the 
[13:33] <bthomas> of the leader_settings_chagned event is solely, for a leader to do, what needs to be done, in order to relinquish leadership.
[13:35]  * bthomas goes to make some coffee
[13:54] <Chipaca> huh, first time i've seen "* Chipaca has quit (Ping timeout: 240 seconds)" myself
[14:06]  * Chipaca brb
[16:56] <Chipaca> i'm off for now (run + dinner + etc), will bb(much)l
[20:06] <facubatista> Chipaca, jam, a pattern I've seen a lot is this (quite useful) sequence:
[20:06] <facubatista> msg = "whatever we want to communicate"
[20:06] <facubatista> logger.info(msg)
[20:06] <facubatista> self.unit.status = MaintenanceStatus(msg)
[20:06] <facubatista> I wonder if we could provide a shortcut for that
[20:07] <facubatista> maybe something like `self.unit.status = MaintenanceStatus(msg, log=True)` (or even log by default)
[20:20] <jam> facubatista, I know 'juju show-status-log' will tell you about the various value the status went through, but it doesn't appear in the default log messages
[20:22] <jam> Chipaca or facubatista  in case bthomas comes back, it feels like he has it backwards. leader_settings_changed notifies *non* leaders that the settings have changed, leader_elected is telling the unit that they are now the leader.
[20:27] <facubatista> jam, thanks
[21:35] <Chipaca> jam: ah, thanks. I'll let him know in the morn.