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

=== oscar12 is now known as oscar0
oscar0Can I ask, does anyone know how to set version number in a charm developed with the operator framework? The version number for the charm should be visible when typing "juju status".08:30
oscar0I'm looking for a way to set the version number in a charm developed using operator so that it is visible when typing "juju status"08:36
bthomasoscar0: jam and Chipaca may be able to give you a more authoritative answer. Here is a hack. How about setting the version string as the message passed to ActiveStatus() .08:47
Chipacaoscar0: is the "version" file picked up automatically by juju for a default status message or something?08:48
Chipacawe have an issue about creating a "version" file in the charm, but I thought that was just for the store08:49
oscar0thanks bthomas and Chipaca. I will try those things today.08:49
=== oscar0 is now known as oscar0|afk
oscar0|afkthe "version" file approach does not work.11:02
oscar0|afkApp                       Version  Status   Scale  Charm                     Store       Rev  OS      Notesmycharm                            active       5  mycharm                   local         0  ubuntu11:03
oscar0|afkthe second field is where it would be good to have a version number, but I don't know how to set it there :)11:03
=== oscar0|afk is now known as oscar0
Chipacaoscar0: did you try the ActiveStatus("your version here") approach?11:16
oscar0Chipaca: I will try it now11:18
oscar0Chipaca: Is this the way you suggest to use it:11:19
oscar0self.unit.status = ActiveStatus('version')11:20
Chipacaoscar0: do you want to set it there, or do you want to set the application version?11:21
oscar0application :)11:21
oscar0self.app.status?11:21
Chipacaoscar0: self.unit.set_workload_version(...) might actually be what you want11:21
oscar0Chipaca: I will try it11:21
Chipacaoscar0: FWIW set_workload_version takes a string11:21
Chipacaoscar0: and that will be shown in 'juju status' automatically11:22
oscar0sweet, trying it out right now11:22
Chipacaoscar0: i probably should have realised this was what you wanted earlier, sorry for the runaround :)11:22
oscar0no problem :)11:23
oscar0it worked, thanks Chipaca!11:26
Chipaca\o/11:26
oscar0love this channel! :)11:26
oscar0but what is the actual purpose of the 'version' file? is it only relevant for the charm store?11:27
jambthomas, oscar0 : I think you are looking for Unit.set_workload_version()11:30
jamah, chipaca already found that for you11:31
oscar0yep!11:32
Chipacaoscar0: the version file is something we're wanting to add so that the store can show it to the user as they browse that11:49
Chipacaoscar0: 'charm upload' did that automatically, 'charmcraft build' does not yet11:49
Chipacaor is it 'charm push'11:50
* Chipaca gets confused with snapcraft too much11:50
oscar0Chipaca: okay, I understand11:51
oscar0thanks!11:51
Chipacaoscar0: np! happy charming11:51
bthomasI understood the requirement as displaying Charm version in status not Version of application deployed by Charm. jam thanks for clarifying.11:52
jamChipaca, I thought 'upload' was the new 'push'11:54
Chipacajam: that's what they want you to believe, man11:55
jam'version' is a way to encode the VCS version of the charm, so that people who work with stores and offline charms can know that it is actually the same charm11:55
jamIts the "back link to the source"11:55
Chipacafwiw we have charmcraft#37 and charmcraft#15912:04
mupIssue charmcraft#37: Populate the 'version' file as part of 'charmcraft build' <build> <Created by jameinel> <https://github.com/canonical/charmcraft/issues/37>12:04
mupIssue charmcraft#159: Snapcraft-style version metadata handling <Created by devec0> <https://github.com/canonical/charmcraft/issues/159>12:04
mupIssue operator#390 closed: Only one role allowed <Created by camille-rodriguez> <Closed by camille-rodriguez> <https://github.com/canonical/operator/issues/390>15:08
Chipacahave i mentioned before how slow the unit tests are on windows15:18
jamChipaca, that's because it is all python startup overhead and not bash, right? Is it plausible to cut down the set of things that need to be run on Windows?15:58
Chipacajam: i think it's just exec overhead on windows, but i'm not sure15:59
Chipacajam: this is without the everything-is-python-now change15:59
Chipacabut there's a .bat that calls bash, for fake_script15:59
Chipacathe alternative is to call subprocess.run with shell=True which is just as slow and more insecure16:00
Chipaca(granted in tests the latter shouldn't be an issue)16:00
Chipacaie fake_script('foo', ...) creates the regular foo bash script, and a foo.bat that does bash.exe foo %*16:01
crodriguezhello hello16:41
crodriguezso I was using self.framework.model.unit.is_leader() , and someone told me now it's better to use self.model.unit.is_leader() ? Are we getting rid of the "framework" in all calls?16:42
crodriguezwhat about self.framework.model.unit.status , should I switch to self.model.unit.status as well ?16:42
Chipacacrodriguez: it's only better in that it's shorter :)16:46
Chipacacrodriguez: it's the same16:46
Chipacacrodriguez: actually i would write self.unit.is_leader() directly16:47
crodriguezalright, so from what I see in the docs, anytime I'm calling model I can drop the framework ahead of it16:47
Chipacacrodriguez: crodriguez: CharmBase has app, unit, meta, and charm_dir all proxied to the appropriate places16:47
crodriguezok cool, thank you16:47
Chipacawrt status, self.unit.status and self.app.status, as appropriate 🙂16:48
Chipacacrodriguez: fwiw 'self.model' won't work unless you've done that yourself :)16:50
Chipacaanyhoo. i'm off16:50
jam@Chipaca, where do you get bash from on Windows?16:53
Chipacajam: it comes with git19:43
Chipacajam: https://gitforwindows.org/19:44
jamChipaca, what are you doing back? go away :)19:44
Chipacajam: just got back from walking the dog and buying dinner19:44
jamcheers19:44
Chipaca(boys are with their mum)19:44

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