/srv/irclogs.ubuntu.com/2020/11/13/#smooth-operator.txt

bthomasMorning Chipaca09:44
bthomasChipaca: I was wondering how would rasing exceptions work for WaitingStatus where the common use case is to set waiting status, do something and then set Active status ? Also for ActiveStatus would it make sense to raise an exception, when the intention is to indicate an error free condition ?09:45
Chipacabthomas: morning09:45
Chipacabthomas: not for active status, no. And my idea is/was/had been that there'd be 2 ways: one with an exception, ie eg raise BlockedStatus("..."), and one with a context manager, ie eg with MaintenanceStatus("..."): …09:48
bthomasAh Ok. Contenxt managers would make sense of MaintenanceStatus. Personally I am inclined to "There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you are Dutch" ... :-)09:51
bthomasChipaca: In the same vein as the request to clarify doc string of event.defer() shouldn't we make explicit in docstring for Status (especially BlockedStatus) that the event handler continues to execute even after setting the status unless an return call is made.09:56
bthomasChipaca: I need a 1:1 to show you the behaviour I mentioned in standup yesterday and get a second opinion . Can I add a 30 min session to your calendar ?10:35
Chipacasure10:35
bthomasdone (made it 45 min just in case - sneeky :-) )10:37
Chipacabthomas: i commented on your #446 but (as i say there) i'd like jam's input10:53
mupPR #446: Minor clarification for deferred event doc string <Created by balbirthomas> <https://github.com/canonical/operator/pull/446>10:53
bthomasChipaca: I really like what you have written. Kudos.10:55
facubatista¡Muy buenos días a todos!11:10
bthomasBuenos días facubatista11:14
facubatistahola bthomas11:16
JoseMassonBuongiorno!12:17
jamChipaca: bthomas: so one piece is that only the handler that defers stays registered. eg if you have config-changed register 2 event handlers foo.on_config() and bar.on_config(); if foo defers, but bar does not, only foo will be called again.12:24
Chipacajam: yeah i should make that explicit also12:31
Chipacajam: it's kinda half there :)12:31
jamChipaca: I'm writing something up, I'll have you look at it.12:31
jam(editing your version)12:31
Chipacajam: awesomesauce12:31
Chipacajam: meanwhile i've spent a fun hour stepping through logs. Is it possible that in k8s, juju does install → start → config-changed rather than install → config-changed → start?12:32
Chipacajam: also, is it expected / supported / a feature, that setting app data causes the charm to let itself know that app data changed? 🙂12:32
Chipaca(the mongodb uses this to trick juju into what is in effect a busy wait)12:33
Chipacasetting app data *to the same thing as it was before*, even12:34
jamChipaca: posted on the PR. I think the best text will be a hybrid of yours and mine.12:37
Chipacajam: ta12:38
jamChipaca: If start is happening before the first config-changed, I would consider that a bug, because you shouldn't be ready to start before knowing your config.12:38
jamChipaca: changing your own application data will tell the other units of your application that there is new data. On K8s it is 1 application agent, but many unit agent threads.12:38
jamSo unit/0 (leader) setting new app data should wake up unit/1 and unit/2 to see the new data.12:38
jamHowever, unit/1 and unit/2 should not be allowed to set app data as they are not the leader.12:39
jamI do know there was some confusion, because there is only 1 application agent, so it needs to be telling the controller "on behalf of unit/0 set the leader data"12:39
Chipacajam: unless I'm much mistaken, I'm seeing unit/0 setting app data and getting woken for it12:39
Chipacabthomas: do you think you could pastebin the log?12:39
Chipacabthomas: it shows both these things12:40
bthomasChipca will do now12:40
bthomasops Chipaca will do now12:40
jamChipaca: thinking through it, it is plausible that we aren't properly trapping it. (you have to record when unit/0 sets app data to rev 2, that unit/0 has now 'seen' rev 2 of the data, otherwise it would wake up again)12:41
Chipacajam: mostly i don't want us to write a charm that uses this behaviour if it's a bug :)12:41
jamChipaca: so exploiting it will also wake up all the other units over and over.12:41
Chipacait is very convenient though, in the absence of an app ready event12:42
jamChipaca: though it could be done with a cron job running juju-run, IIRC, and that would be intended to work :)12:45
jamIt does take effort to fix on our part, but I can't help but feel that we should.12:45
* bthomas is struggling to copy and paste the entire terminal window :( . will get there eventually12:45
bthomasChipaca: jam : https://pastebin.canonical.com/p/pBtvTfc8YJ/12:47
Chipacabthomas: apt install pastebinit 🙂12:47
bthomasthanks12:47
Chipacabthomas: i think you forgot the --replay?12:48
bthomaslet me fix that12:48
bthomasChipaca: jam : https://pastebin.canonical.com/p/jyvCYnwJvb/ should be fixed now12:51
jambthomas: Chipaca: line 342. why are we seeing 2 logs of Operator Framework12:53
jamah, because we have hooks/start as a symlink to dispatch12:54
Chipacajam: yeah, calling itself12:54
Chipaca(and detected)12:54
Chipacajam: from that log, the events seen are, in order: install, cluster-relation-created, leader-elected, config-changed, start, db-storage-attached, …12:54
jamChipaca: 175 we run install, 265 we run config-changed,332 we run start12:55
Chipacahmm12:55
jamI'm surprised storage attached is so late, but maybe we can't tell you about the storage on k8s until the pod is actually running.12:55
Chipacajam: i/we must've gotten confused before, sorry for the noise :)12:55
Chipacajam: yeah the storage-attached happens after config-changed has fired a pod-spec-set12:56
Chipacajam: ah! and a config-changed after db-storage-attached12:58
jamChipaca: there is nothing that says config-changed won't be run later, I believe in that case it is because your IP address has become available.12:58
jam(networking calling config-changed is one of the warts)12:58
Chipacajam: gotcha12:58
Chipacajam: i think we just missed the first config-changed when we were walking through it12:59
jamlooking at 821 "running cluster-relation-changed", it ran relation changed, and then gets ready to run it again12:59
jamruns a bunch of "state-get, state-set" and relation-get, relation-list, but I don't see a relation-set12:59
jamthat would cause it to fire the next one.12:59
Chipacajam: relation-set is called from the start event handler13:00
jamChipaca: but why would we fire app-relation-changed over and over if it isn't *changing*13:00
Chipacajam: including the deferred one that is re-emitted from cluster-relation-changed waking up the charm13:01
Chipacajam: i'm asking you 🙂13:01
Chipacano backsies13:01
bthomasjam: firing app-relation-changed again and again is a busy loop hack that makes this charm initialize fast (afaiu) . Not my invention .13:02
jamChipaca: sure, it was more rhetorical13:02
jamIt seems more that we just aren't doing the right thing for peer application relation data, and we just fire forever, which is *definitely* a bug.13:02
Chipacabthomas: do you think you could tear this down, patch ops so that ops.framework.StoredList.__repr__ returns repr(self._under), and deloy it again?13:03
bthomasChipaca: I can certainly try.13:03
bthomasChipaca: https://pastebin.canonical.com/p/bxBc2FFtRS/ is my change. Deploying and regenerating lows now13:09
Chipaca👍13:09
ChipacaI think I'll drop in a __repr__ for all of these13:10
bthomasChipaca: https://pastebin.canonical.com/p/V6wTgfbdMg/ Please check if I got this right and is what you required.13:15
Chipacabthomas: if this is the new log, i suspect it hasn't packaged the modified ops in there13:16
bthomashmm13:16
Chipacabthomas: look for replica_set_hosts= in that log13:16
bthomasI just did a pip3 install in the operator git repo. git diff shows me the changes are there (not committed). pip3 list shows my that ops is installed.13:17
bthomasChipaca: ^ I just checked the file in my ~/.local/lib/python pip3 install location and the ops.framework.StoredList does have the __repr__ method added.13:24
jambtw, I'm doing breakfast/family stuff for abit13:24
bthomasfacubatista: where does Charmcraft build pull operator framework from ? Is there way to tell it to pull from local pip repository ?13:27
bthomasChipaca: You were right . ^13:28
* bthomas goes to boil some pasta13:28
facubatistabthomas, sure! by default it gets it from PyPI, but if you need to get it from your disk, just tell that to pip13:28
facubatistabthomas, like putting this in your requirements.txt (untested): file:///your/absolute/path/to/the/ops/project/13:29
bthomasThanks13:30
facubatistabthomas, let me know if you can not make it work13:31
bthomaswill do13:33
Chipacagithub down?13:38
Chipacagithub down13:38
bthomasfacubatista: https://pastebin.canonical.com/p/6rVmZrBBgg/13:42
* bthomas is still boiling pasta13:42
facubatistathis is weird: ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/home/balbir/.local/lib/python3.8/site-packages/ops'13:43
bthomashmm13:43
bthomasmy charmcraft version is 0.6.0+10.g635bad013:45
facubatistabthomas, how the '/home/balbir/.local/lib/python3.8/site-packages/ops' directory gets into play? are you located there? you have some environment variable to configure pip behaviour?13:46
facubatistabthomas, which permission has that directory?13:47
bthomasfacubatista: "drwxrwxr-x 4 balbir balbir 4096 Nov 13 13:22 /home/balbir/.local/lib/python3.8/site-packages/ops"13:50
* bthomas -> lunch13:50
facubatistabthomas, let me know when you come back13:50
* bthomas -> back14:14
bthomasfacubatista: directory has global read . I wonder can I manually copy a file into build directory and repack it.14:14
facubatistabthomas, no, there's a more weird problem, let's find it14:16
facubatistabthomas, what happens if you run pip3 install --target=/home/balbir/src/charms/mongodb-operator/build/venv --requirement=/home/balbir/src/charms/mongodb-operator/requirements.txt14:17
bthomastrying now14:17
bthomasfacubatista: https://pastebin.canonical.com/p/9B5n9ZtC89/14:20
facubatistabthomas, what's the content of requirements.txt ?14:20
bthomasfacubatista: file:///home/balbir/.local/lib/python3.8/site-packages/ops14:21
bthomasalong with pymongo and git repo for OCI image lib14:21
bthomasgit+https://github.com/juju-solutions/resource-oci-image/@c5778285d332edf3d9a538f9d0c06154b7ec1b0b#egg=oci-image14:22
bthomas 14:22
bthomasand pymongo14:22
facubatistabthomas, ah, that's where that .local weird path is involved14:22
facubatistabthomas, you should point to the project's directory14:22
facubatistato the source code14:23
facubatistayou can not "install from installed"14:23
bthomasah ok let me try that14:23
bthomasfacubatista: that worked perfectly. Thank you. So much gets "Lost in Translation" . Checkout the movie if you haven't :-)14:25
facubatistabthomas, I love Scarlett Johansson installing python packages14:25
bthomas:-)14:26
* Chipaca just did 'git pish' and giggled for a full minute before fixing the typo14:32
mupPR operator#447 opened: give StoredFoo classes a useful __repr__ <Created by chipaca> <https://github.com/canonical/operator/pull/447>14:33
bthomasChipaca: https://pastebin.canonical.com/p/khMPWtx5pw/ Lunch is served :-)14:35
Chipacabthomas: buen provecho14:35
bthomas:-)14:36
Chipacajam: in bthomas's pastebin above you can see it's relation-set'ing it to the same value every time, fwiw14:36
Chipacabthomas: when you get back from lunch, can you deploy one with N nodes?14:37
Chipacaunits14:37
Chipacato see how chatty it gets14:37
Chipaca(probably: very)14:37
jamChipaca: why do some lines have: DEBUG unit.mongodb/0.juju-log Deferring <StartEvent via MongoDBCharm/on/start[13]>. and some: DEBUG unit.mongodb/0.juju-log cluster:0: Deferring <StartEvent via MongoDBCharm/on/start[13]>.14:42
jamis it different versions of the charm?14:42
jamI do see relation-set in those lines, I didn't find them before, but maybe I was just missing it?14:42
Chipacajam: I don't know where the cluster:0 in a lot of those log lines is coming from14:44
Chipacajam: i don't think it's 'us'14:44
bthomasChipaca: With 3 units https://pastebin.canonical.com/p/nfrp3wMDZk/14:45
jamthat *looks* like it is relation-name:relation-id14:45
Chipacajam: note it's also there for the 'ops up and running' line14:46
Chipacajam: application-mongodb: 14:44:19 DEBUG unit.mongodb/1.juju-log cluster:0: Emitting Juju event cluster_relation_changed.14:47
Chipacajam: not sure what it is14:48
jamit seems to me that something hacked ops logging to inject a prefix. it is possible that Juju is doing it, but then I would expect it to be consistent.14:48
jamChipaca: so the original paste "https://pastebin.canonical.com/p/jyvCYnwJvb/" actually does show relation-set, just not in the early calls, it happened in the later ones.14:52
justinclarkbthomas, is there a canonical/mongodb-operator? Working on the Graylog docs and wanted to point to that repo. If not I'll make one quickly15:43
* facubatista -> quick lunch before standup15:43
bthomasjustinclark: there is15:44
bthomashang on15:44
bthomasjustinclark: https://github.com/canonical/mongodb-operator However15:44
bthomasIt does not have the relation code and it does have the bug15:45
bthomasthat mongodb may not be fully initialized when graylog connects15:45
justinclarkI see. It's also a private repo.15:45
bthomasoops15:45
bthomaswe can make it public.15:46
bthomasBut use that link in your README15:46
justinclarkSounds good. I think we need to submit a request with IS to make it public.15:46
justinclarkI'm not sure how Jeremy did that for Elasticsearch and Graylog, though15:47
bthomasjustinclark: I thought we can just mark it public in the settings. I may be wrong.15:47
bthomasHowever I prefer checking with jldev before we do15:47
justinclarkHe mentioned the other day in the private channel that we shouldn't be making private repos so I'm sure it's true for this also.15:48
justinclarkLet me see if I can find the comment.15:48
justinclarkFrom November 5: "Yeah, and organization admin (IS) will have to change it. We shouldn't be making private repos to begin wtih."15:49
justinclarkIt was a fairly quick change, though. I'm sure we can get it changed today no problem.15:51
justinclarkJust submitted a ticket with IS.16:04
bthomasjustinclark: can I leave that with you then. Alternatively we can delete the repository and I can just re-create a public one ?16:05
bthomasoops can not delete repo either16:06
justinclarkNah I don't think it's really a big deal. It won't take too long. It might even be better this way since we still need to merge your refactored branch and that's what we want to be public.16:07
jamChipaca: https://bugs.launchpad.net/juju/+bug/190419617:01
jamI was able to reproduce that relation-set --app triggers a relation-changed for the current leader.17:01
jam*however* setting it a second time did *not* trigger a second relation-changed event.17:01
jambthomas: ^17:01
Chipacajam: this in k8s?17:03
Chipacajam: or is that the difference here17:04
jamChipaca: this is in my ubuntu-operator charm which is running in LXD. I would confirm that you really are setting identical data for the charm (which you could be, just confirm that it is the case)17:05
Chipacajam: in the second of the pastebins you link we're logging the actual data that's set17:05
Chipacajam: (bthomas patched ops with a __repr__ on the StoredList)17:06
Chipacajam: so if you search for replica_set_hosts, that's the app data17:06
Chipacajam: (or, if you'd ratehr, search for relation-set; the app data is two lines further down)17:06
jamChipaca: if you are talking this one, I do see it changing, though not always17:09
jamhttps://pastebin.canonical.com/p/nfrp3wMDZk/17:09
Chipacajam: ah because i asked bthomas to spin up N17:10
Chipacafor extra chatty17:10
Chipaca¯\_(ツ)_/¯17:10
Chipacajam: anything we can do to properly clarify this?17:11
Chipacai guess write an ad-hoc charm17:11
Chipacayeah, i'll do taht17:11
jamChipaca: hence why I updated ubuntu-operator that does nothing but the bit I add :)17:11
Chipaca🙂17:12
jamChipaca: from what I see, it looks like on_start is being deferred but *also* calling relation-set17:12
Chipacayes, that's part of the mud in the charm that balbir will refactor17:12
Chipacait's deferring it _twice_, just for funsies17:12
jamah, and then storage-attached runs the deferred start, causing it to call relation-set again17:13
jamand then we get relation-changed (the first time), which causes us to run start, and ultimately causes us to call relation-set 2x17:13
jamand the rest look like actual changes causing us to wake up again17:14
jamChipaca: so from my perspective, the relation-set calls are because on-start is calling it, and being deferred and thus woken up again, and there isn't a busy-wait loop17:14
jamjust a 'wake up every time I tell myself something'17:14
Chipacahmm17:15
Chipacajam: i'll try to isolate it 🙂17:15
jamChipaca: I'm looking at trying to avoid waking yourself up, but it would be good to know if we're doing something even weirder with k8s. You probably can just edit the mongodb charm and have it do less 'other stuff'17:21
Chipacafun fact, you can't log "-".18:13
Chipacajam: 18:30:22 INFO juju.worker.uniter unit "mongodb/0" shutting down: %!s(<nil>)18:30
Chipacafwiw18:30
jamChipaca: already have a patch for that in 2.8.718:31
Chipaca👍18:31
jamChipaca: did you know that gullible isn't in the dictionary?18:31
Chipacajam: it is not! mostly becuase it's in Spanish18:31
jamChipaca: though more directly, can you not 'logger.debug('-')' ?18:32
jamit seems like a case of 'juju-log -- -' or some fashion to avoid having it be misinterpreted18:32
Chipacalogger.debug("--------") got very upset at me18:32
Chipacajam: setting app data to the same value does not seem to trigger the event, in k8s, at least with this pruned back operator18:34
jamno such option '------'18:35
jam:)18:35
Chipacaand with that, EOW, have a good one, etc etc18:35
Chipacasee y'all sometime next week :-D18:35
jamhave a good one Chipaca18:35
Chipacajam: you too!18:37
* facubatista eods, and eows!21:21
facubatistasee you all on Monday21:21

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