/srv/irclogs.ubuntu.com/2020/05/18/#smooth-operator.txt

MarkMaglanao/02:24
MarkMaglanaQuestion: When using the test harness, is there anything special we need to do in our unit test to make this line work in the SUT's code? `self.framework.model.resources.fetch('grafana-image')`05:16
jamMarkMaglana, I believe resource support is something that needs to be implemented07:07
jamMarkMaglana, I would expect to have some sort of setup on the Harness, where you tell it what paths you should return for a resource request07:08
jamMarkMaglana, issue #26207:08
* jam heads to take the coffee machine to the shop, critical infrastructure :)07:09
MarkMaglanajam: thanks for that!07:28
MarkMaglanaand black coffee for me today, please!07:29
MarkMaglanaanother question. what other steps do i need to perform prior to exposing a k8s workload via `juju expose <app-name>`08:09
Chipacamorning all08:09
MarkMaglanatop of the mornin' to ya Chipaca!08:11
MarkMaglanabottom of the afternoon for me though08:11
Chipaca*my* morning, all08:12
Chipaca:-p08:12
jamMarkMaglana, you shouldn't need to do much as a user, you can include "expose" as part of a bundle08:32
jamas a charm developer, you need to call 'open-port' in order to tell Juju what to expose.08:32
jamChipaca, good morning08:33
MarkMaglanajam: actually i discovered just now that i don't even need to run `juju expose`. I can access the app via its IP directly. but that's only if i access it from within the host. (i'm using microk8s)08:33
Chipacajam: how're things?08:42
jamChipaca, well, coffee machine broke.. so I took it into the shop, but otherwise things are going ok08:43
Chipaca/o\08:43
Chipacajam: i too have coffee woes … my postie has gone missing, with now two coffee deliveries missed (and some masks my mum made)08:43
Chipacai'm now down to instant08:44
jamChipaca, ouch! my deliveries have been regular, which is good. And we have a backup nespresso machine that my wife usually uses for decaf08:44
jamChipaca, but if you have instant, you have Dalgona, right?08:45
Chipacaon the one hand, yes08:45
MarkMaglanacold brew ftw!08:46
Chipacaon the other hand, that thing takes ages to make and dirties a lot more than just a coffee08:46
Chipacaone of the things i like about my aeropress is the minimal mess08:46
Chipaca¯\_(ツ)_/¯08:46
jampretty inexpensive to get a replacement, but you might need to go out of the house for that08:47
Chipacajam: still out of coffee for it tho08:47
Chipaca:)08:48
jamsometimes you can find places that sell things for money, which sometimes includes coffee :)08:48
Chipacajam: this is true, and i might resort to that if i tire of my instant08:48
Chipacathe instant is only ever meant as an emergency ration kind of thing :)08:48
Chipacamy delivered coffee is so much better than what i can get in the supermarket, the few times i have bought coffee there it ends up going off08:49
ChipacaANYway08:49
Chipacajam: is my approach on #284, wrt initial values for _status, reasonable? ie having unkown for app and maintenance for unit?08:50
Chipacajam: (and if maintenance for unit, is there any particular message i should set on it?)08:50
Chipacai tried seeing what message juju set but it was beyond my ken still08:50
jamChipaca, works for me08:51
jamNo message on the unit08:51
jamwhich is why you couldn't find it :)08:51
MarkMaglanaChipaca: aeropress is awesome. And I'm still wondering why I haven't bought one. Something is wrong with me.08:51
ChipacaMarkMaglana: because you're at a local comfort extreme and getting out of it requires work?08:52
MarkMaglanaChipaca: mystery solved!08:53
Chipacaboo, 3.5 doesn't like foo: bar = 'baz'09:03
jamChipaca,even if it is "foo: str = 'baz' " ?09:16
Chipacajam: yeah, it's a 3.6ism09:17
Chipacafor 3.5 we're stuck with the entirely unsatisfying  # type: str09:17
jamChipaca, I think I still need your review of couldn't find it :)09:17
jam<MarkMaglana> Chipaca: aeropre09:17
jamsorry bad paste09:18
jamhttps://github.com/canonical/operator/pull/27909:18
jamChipaca, I thought I had done that syntax, but it was probably '=None'09:18
Chipacajam: on it already :)09:18
Chipacajam: i could use one on #190 also09:19
jamChipaca, approved #190, I'd like to see us fix the bits that don't get PYTHONPATH set correctly, etc. but nothing in that is wrong, just doesn't quite 'juju deploy .' with the actual text that was written09:26
Chipacajam: yep, I'm going to be pushing for us to have at least that bit of charmcraft build done before the next biweekly email :)09:28
Chipacajam: which reminds me, did you get to give that a read?09:28
jamChipaca, yeah. it looks good to me, depends a bit on who the audience is. Is it just a Discourse "here's what we're doing" sort of thing?09:30
Chipacajam: and to our mailing list (!)09:30
jamChipaca, isn't Discourse the New(tm) mailing list?09:31
Chipacajam: for this sort of thing, i have 0 problem in posting it to the old *and* the new09:31
Chipaca:)09:31
jamChipaca, I just didn't know of an external mailing list that people wanting announcement style messages would be signed up to09:51
Chipacajam: there's probably at most one or two people on the list that aren't watching discourse, but i care for them :)09:52
facubatistaMuy buenos días a todos!11:16
* Chipaca reading https://www.conventionalcommits.org/en/v1.0.0/ and going "hmm" a lot11:31
Chipacafacubatista: how're you doing?11:32
davigar15Hey! qq11:34
davigar15Do you know if an async action will work in the operator framework?11:35
Chipacadavigar15: what's an async action in this context?11:35
Chipacaactions work :)11:35
Chipacabut i didn't know juju had 'async' actions11:35
davigar15```11:36
davigar15async def get_chat_id(name):11:36
davigar15    await asyncio.sleep(3)11:36
davigar15    return "chat-%s" % name11:36
davigar15```11:36
davigar15Coroutine I mean11:36
davigar15With asyncio11:36
davigar15Chipaca: So instead of having `def on_whatever_action`, we'd have `async def on_whatever_action`11:38
Chipacadavigar15: and what would that do?11:38
davigar15Well, I don't know about the internals of it, but basically when you put async in a function definition, that function is a coroutine that can `await` to other functions. Is the way to implement asynchronous functions in python11:40
Chipacadavigar15: yes, I know. I'm asking what that would do for the charm :)11:42
Chipacadavigar15: that is: what is the advantage of it for you, the charm writer11:42
Chipacacurrently we don't support this, fwiw11:43
davigar15In my usecase, I have a charm that SSH to a machine using paramiko. I'd like to remove that dependency, and implement the ssh function this way: https://github.com/juju/python-libjuju/pull/393/commits/7ceb7561b6eb3b070868eb28c4ad47791ae1aa7c11:43
davigar15For that I need to `await ssh(cmd)`, and we can only await in coroutines11:44
Chipacadavigar15: there's nothing stopping you doing that in the handler11:44
Chipacadavigar15: you don't need the event handler to be async for that11:44
Chipacathat is, you can write pretty much the same 'async def ssh(...)' and then await ssh() in your _on_foo event handler and it'd work11:45
davigar15import asyncio11:46
davigar15await asyncio.sleep(4)11:46
davigar15^ If I put that in an event handler, it says: undefined variable: await11:47
facubatistammm...11:47
davigar15warning that disappears  when I put `async` in the definition11:47
facubatistadavigar15, let me try something11:48
davigar15😉11:48
Chipacaah, i forgot the await-only-in-async11:52
Chipacadavigar15: from python 3.7, that'd be asyncio.run(asyncio.sleep(4))11:53
Chipacadavigar15: before 3.7 it's asyncio.get_event_loop().run_until_complete(asyncio.sleep(4))11:54
facubatistadavigar15, I just tried this as a script, but you can do the parallelism: https://paste.ubuntu.com/p/FBTdb5bVV9/11:54
Chipacafacubatista: poncho! :)11:54
facubatistadavigar15, you'd need to start the event loop on each call, though, and wait for everything to complete before ending11:54
facubatistadavigar15, and finally, take into account that any call *back to the framework* would be blocking11:54
facubatistaChipaca, :)11:55
davigar15What do you mean with "would be blacking"?11:55
facubatistadavigar15, "blocking", not blacking, as "it will not be async"11:56
* facubatista brb11:57
davigar15sorry for the typo. Okay, understood11:59
davigar15Thanks :)11:59
Chipacadavigar15: sorry if you already answered this, but what is the advantage to you to having your ssh function be async?11:59
* facubatista is back12:00
davigar15Basically I did that in the SSHProvisioner in libjuju, and was to reuse that function here.12:00
davigar15I can simply execute subprocess.check_call()12:00
davigar15And will be the same12:01
facubatistadavigar15, but it is an external process the one you're calling?12:02
facubatista*is it12:02
davigar15I'm doing `ssh <user>@<host>[...] cmd` in the charm12:03
davigar15The process is executed in the charm, but it basically does ssh to a machine to execute whatever function12:04
davigar15It is what we called in OSM: proxy charm.12:04
facubatistadavigar15, my point is that the process is NOT executed in the charm, it's a *sub*process12:04
facubatistadavigar15, so, you would need to wait for it from the charm12:04
davigar15yep12:04
davigar15exactly12:04
facubatistadavigar15, so I'm lost in how async helps you here12:05
* facubatista is trying to understand, but it's so early in the morning here :)12:05
davigar15Only to reuse the function I already made. Don't worry, you solved my problem12:05
davigar15As I need to wait anyways, it doesn't help me at all12:06
facubatistaack12:07
Chipacaone interesting thing for me, looking into this, is that there isn't AFAICT a way to tell a function from an async function before calling it12:09
Chipacaoh, inspect.iscoroutine12:11
Chipacaand iscoroutinefunction12:11
Chipacafair'nuf12:11
Chipacai first looked for async and only got isasyncgenerator[function]12:11
facubatistaChipaca, I can not land charmcraft branch because "The base branch requires all commits to be signed", I'm reading about this (how to do that), but just telling you in case we have something misconfigured12:16
Chipacahmm12:16
Chipacafacubatista: it's a toggle12:16
Chipacafacubatista: want me to un-toggle, or do you want to start pgp-signing commits? :-p12:17
Chipacai'll toggle it as i suspect i may be the only one signing commits here12:17
facubatistaChipaca, I can sign them12:17
facubatistaif I understand how :)12:17
Chipacafacubatista: made optional for now :)12:18
facubatistaChipaca, what I don't understand is if I need to sign the commits in my branch, or sign the commit which merges my branch into master12:19
Chipacafacubatista: git config user.signkey "somekeyid", and git config commit.gpgsign true12:20
Chipacafacubatista: from memory12:20
facubatistaChipaca, but that would sign the commits in *my branch*, not in master, is that what is needed?12:22
Chipacafacubatista: it'll sign your commits locally12:22
Chipacafacubatista: not on master, but i changed settings on charmcraft to use merge commits12:23
Chipacafacubatista: let's see how that works12:23
MarkMaglana> 16:32:32 <jam> as a charm developer, you need to call 'open-port' in order to tell Juju what to expose. <-- jam does this apply to k8s charms as well?13:02
Chipacaoh dang lunch13:05
facubatistaChipaca, yay, I'm now "Verified"13:17
Chipacafacubatista: ✓13:20
* facubatista adds a ✓ to own CV13:23
jamMarkMaglana, I'm not sure, as I believe part of the spec for the pod is what ports it is using. I haven't actively tested it either way.13:37
Chipacajam: one thing we looked at and confirmed with facubatista on Friday14:08
Chipacajam: is that Optional is not needed, as it's inferred automatically from =None14:08
Chipacajam: which is nice :)14:08
Chipacaas in, if you have a =None, it'll be Optional14:09
MarkMaglanajam: yeah i suspected that was the case.14:09
Chipacajam: surprisingly we have something marked Optional that _isn't_ =None14:10
jamChipaca, I think we have a couple things with default values, hence optional14:11
jamActiveStatus(message=''a)14:12
jametc14:12
Chipacajam: hmm. I think Optional just means 'can be None', not 'has default values'; the default values need to match the explicit types (unless they're None, which makes the explicit type get promoted to Optional)14:55
Chipacafacubatista: any chance for a review on 284?14:55
facubatistaChipaca, I was about to start my round on issues and prs14:56
facubatistaI'll start with 284, then14:57
Chipacafacubatista: also, you could land #273 :)14:57
Chipacaexcept conflicts14:57
facubatistaChipaca, +1, with comment15:31
* facubatista -> quick lunch before meeting15:31
vgrevtsevhi team, have a quick question: what's the right way to write a relation data inside of the event handler? I'm getting a "TypeError: 'Relation' object is not subscriptable" and I bet I'm doing something wrong...15:36
Chipacavgrevtsev: relation.data[...] ?15:38
Chipacavgrevtsev: instead of relation[...]15:38
Chipacavgrevtsev: i guess :)15:38
vgrevtsevNeither `event.relation` using `event` object in the handler nor self.model.relations[_rel] .. didn't work15:38
vgrevtsevAhh, `relation.data`, alright15:38
Chipacavgrevtsev: 1 sec15:38
vgrevtsevLet me try15:38
Chipacavgrevtsev: https://operator-framework.readthedocs.io/en/latest/#ops.model.Relation.data15:39
vgrevtsevok, so `event.relation.data['foo'] = 'bar'` should work then?15:40
Chipacavgrevtsev: event.relation.data[event.unit]['foo'] = 'bar'15:41
Chipacano wait15:41
Chipacathat's the _other_ side, you can't write to that15:42
Chipacavgrevtsev: event.relation.data[self.model.unit]['foo'] = 'bar' :)15:42
Chipacathat's the one you want15:42
Chipacaevent.unit won't be "you"15:42
Chipacaso you can't write to it15:42
vgrevtsevwell, so I can use [event.unit] to read the remote relation data being written by another charm (from another side of the relation) ?15:43
Chipacayep15:43
jamChipaca, I can see that is what it means to 'typing', but that isn't what Optional means to me as a person15:58
Chipacafacubatista: you there?16:01
facubatistayes16:01
Chipacafacubatista: ok :)16:01
facubatistafighting auth16:01
vgrevtsevChipaca: can a `ops.model.RelationDataContent` be casted to the regular dict to iterate over the relation data? (that's what I got after calling the `event.relation.data[event.unit]`)16:27
Chipacavgrevtsev: ops.model.RelationDataContent is a MutableMapping, just use it as you would a dict and it should do the right thing16:28
vgrevtsevah I see, will try, thanks a lot!16:29
Chipacavgrevtsev: https://docs.python.org/3/library/collections.abc.html#collections.abc.MutableMapping if that helps16:29
vgrevtsevI'm on it atm :)16:29
Chipacait's also a LazyMapping, which is the same thing but lazier ;-p16:30
vgrevtsevthat helps - it tells me that .keys() and .items() are implemented in Mapping16:30
vgrevtsevso I can use them ^_^16:30
vgrevtsevnice, that works, thanks again Chipaca :)16:44
ChipacaI am *so* happy we went with sphinx for the docs!!!17:06
* Chipaca sings a ballad to intersphinx17:06
Chipacawith #285 things like MutableMapping will be a link straight into python 3's docs about that :-D17:08
Chipacaanyhoo, EOD for now. I'll bbl to tinker with ops.lib but might not come onto IRC as I need to do a large refactor to get things testable17:08
Chipaca👋17:08
facubatistaChipaca, bye17:09
* facubatista eods22:03
MarkMaglanawhat? but i just got here! was it something i said??23:43

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