/srv/irclogs.ubuntu.com/2020/04/20/#smooth-operator.txt

jammorning all03:56
t0mb0this may or may not be an operator specific problem but i'll ask here - how would one ensure a container is secured with TLS? Should the operator framework create an ingress or is that a Juju thing? jam you may know?07:49
t0mb0I would have imagined that the operator pod would form a http relation with the ingress perhaps?07:50
t0mb0I've set the charm options juju-external-hostname and kubernetes-ingress-allow-http=true however I'm not seeing any ingresses being created!07:51
t0mb0note - I am using microk8s not charmed k8s07:55
niemeyert0mb0: The answer depends on the charm and the interface being used indeed.. TLS is used by several independent protocols (we're doing IRC over TLS just now)08:03
niemeyert0mb0: Is the question specific to microk8s?08:04
jamt0mb0, have you done "microk8s enable ingress" ?08:05
jamhttps://microk8s.io/docs/addons08:05
jamI believe for Juju itself you need to enable "dns" and "storage" but if the applications you're deploying need other K8s services like an ingress controller, then you need to have those enabled as well.08:06
niemeyerMorning jam08:10
jammorning niemeyer08:10
t0mb0jam, thanks! I believe microk8s enable ingress was what I was looking for08:16
t0mb0thanks for your input too niemeyer08:17
niemeyert0mb0: np, glad it's sorted08:25
jamhi Chipaca . just in time for me to step out for lunch :)08:44
Chipacajam: good morning! buen provecho :)08:45
niemeyer> We should be consistent on ordering. However, I do believe 'unittest.assertEqual' assumes (expected, actual) ordering. Because if you do:08:55
niemeyerjam: Added another comment there.. I don't think that's true.08:55
niemeyerLet's please keep the usual obtained, expected order.. even the examples in unittest.py itself order like that.08:56
niemeyerAlso: https://github.com/python/cpython/tree/3.7/Lib/unittest/test09:03
Chipacaniemeyer: what should I see in that link?09:07
niemeyerTests? :)09:07
niemeyerChipaca: It's the tests for unittest itself09:07
Chipacaah, gotcha09:07
niemeyerChipaca: All of them follow obtained, expected..09:07
niemeyerSo it'd be slightly awkward if the author intended the opposite09:08
Chipacai wonder why they chose the diff to go in the opposite direction then09:08
niemeyerChipaca: I don't see it as reversed09:08
niemeyerChipaca: I actually don't even know what I expect myself in that sense, though, to be honest09:09
Chipacafair09:11
jamso my first hit for: "python unittest assertEqual expected" was that it was "expected, actual" according to xUnit conventions09:11
jamPython itself carefully says "first, second"09:12
niemeyerjam: Not so carefully, though.. just read the docstrings of these functions09:12
jambut the diff does read backward in my head for that. (this has been added / missing relative to?)09:12
niemeyerself.assertEqual(the_exception.error_code, 3)09:13
niemeyerThis is in the docstring of assert raises09:13
niemeyerI find ("foo" == var) inverted given years of reading it the other way around, but I wouldn't mind adapting if we were following a pattern.. But we are not.. we'd both be making it awkward based on common style, and on the intended form of the testing library we use, so I'm -1 on it09:14
niemeyerjam: Isn't xunit coming from Java?09:15
jamhttps://bugs.python.org/issue10573 seems to be the bug, mfoord raised the issue of ordering so you get appropriate diffs09:17
jamhttps://mail.python.org/pipermail/python-dev/2010-December/106954.html is Guido's comment on it09:17
jam(old, new) matches diff and matches (expected, actual), but intentionally using "first, second" in the code instead.09:18
jamso, its fine, we can go with unittest's convention, but it does mean that all the diffs are "how expected differs from actual" rather than "how actual differs from expected"09:18
niemeyerThis second link makes me sad..09:19
niemeyerIt's a glimpse of poor leadership..09:19
niemeyer"Yeah, we do use that ordering in our code everywhere, but people elsewhere use different conventions.. so we don't care.. do whatever."09:20
niemeyerMultiply that by 3 decades, and bingo..09:21
jamthere is also https://youtrack.jetbrains.com/issue/PY-26471 for the ordering in PyCharm.09:23
jamAnd their example tutorial actually puts it as assertEqual(foo, 10), but then prints Expected: 'foo', Actual: 10.09:24
jamFirst, Second at least tells you where to look and makes you actually figure out which is expected and what is actual.09:24
jamI'll clean up Harness.09:24
jamto conform09:24
niemeyerHaha, priceless :P09:25
mup_PR operator#235 opened: test/test_harness.py: Fix the ordering to assume actual/expected <Created by jameinel> <https://github.com/canonical/operator/pull/235>09:42
facubatistaMuy buenos días a todos!11:01
jammorning facubatista11:01
facubatistahola jam11:01
niemeyerMorning Facundo11:11
facubatistahola niemeyer :)11:13
facubatistajam, I don't understand your comment about not replacing 'juju_exec_path' in Chipaca's branch11:53
jamfacubatista,         juju_exec_path = juju_exec_path.parent / dispatch_path11:54
facubatistajam, IIUC, we need to check if the juju_exec_path exist *and if it's not ourselves* (that check still missing), and only then execute it... but if we decide to execute it, we'll replace it, right?11:54
jamIf you replace it, it becomes harder to tell "if it is ourself"11:54
facubatistajam, but that verification should be done before11:55
jamfacubatista, well, I would expect to be done right around that point, as that is the point you are seeing if it exists and what it points at11:56
Chipacayes that check is still missing, fwiw11:56
facubatistaif juju_exec_path.exists() and juju_exec_path.resolve() != Path(sys.argv[0]).resolve():11:57
facubatistajam, I'd do something like ^11:57
jamfacubatista, sure. my point was that juju_exec_path was already Path(sys.argv[0]), so you could just use it if you don't replace the var first.11:57
facubatistaack11:58
pekkariHi guys, is there currently a path to retrieve the ip address of a unit? Model seems to hint you have to traverse the BindingMapping of the full model if you want so12:09
Chipacapekkari: I don't think there is another way12:14
Chipacapekkari: i'm not even sure there is an ip address of a unit without reference to a binding, so it's not clear to me this is a deficiency12:15
jampekkari, in the juju model, you might be deployed to a machine that has multiple network cards and the operator wants different applications on different interfaces, so you have to go via the binding so the operator can tell you how that piece is configured.12:24
jamthere is no "one true IP" for a unit as a whole12:24
pekkariyeah, multiple addresses is certainly something I understand, I'm just struggling to find from a charm event the way up to an ip address related to the binding of the relation we run on12:27
jampekkari, def _on_changed(self, event): self.model.get_binding(relation_name).network ?12:31
jamare you in a Charm, or in a separate component ?12:31
jambinding key can be a relation as well, so if you wanted12:32
pekkarijam that may be it12:32
jamself.model.get_binding(event.relation)12:32
pekkariI'm in a charm, defining the on_identity_service_relation_joined, and there I need the ip of the binding it talks to keystone12:32
jampekkari, I don't think you tell Keystone about the network details to keystone. I would expect you to tell keystone about some other binding.12:33
pekkarierm no, this charm tells it's ip address in the binding to keystone to setup the endpoint url12:34
jampekkari, OS traditionally had public/private/admin bindings to describe the application you were deploying, so that would be, self.model.get_binding('public')12:34
jampekkari, I would expect that a sysadmin would configure the binding of the keystone endpoint to "how keystone should talk to my app" but what you want to tell Keystone is "how should other apps (eg neutron/nova/etc) talk to my app"12:35
jamwhich is not the binding of the relationship to keystone, but a different binding on your charm.12:35
pekkarithat is very true, however hardcoding the public binding makes me wonder if there is a better way to put it12:36
pekkaricertainly may not be a problem, at the end of the day, you only want the service to be reached in public space12:37
jampekkari, if its your charm, you define what endpoint you are advertising to keystone12:38
pekkariit may be right jam, as long as if you want another you can simply configure the public binding to point to another space12:38
jamif it is "all openstack charms", then you can pass in the name of the public binding in __init__ and have your code track that.12:38
jampekkari, correct. that is the point of having an endpoint that sysadmins can bind12:39
pekkarithanks for the guidance!12:39
* facubatista brb12:53
mup_PR operator#235 closed: test/test_harness.py: Fix the ordering to assume actual/expected <Created by jameinel> <Merged by jameinel> <https://github.com/canonical/operator/pull/235>12:53
Chipacafacubatista: didn't #209 fix #198 ?12:57
mup_PR #209: Enable stderr logging if JUJU_DEBUG is set <Created by jameinel> <Merged by jameinel> <https://github.com/canonical/operator/pull/209>12:57
mup_Issue #198: DEBUG log messages not emitted <bug> <Created by stub42> <https://github.com/canonical/operator/issues/198>12:57
Chipacajam: or you :)12:57
jamChipaca, no. I didn't do both at the same time. We still only put INFO messages to juju-log, as it wasn't clear to me if we wanted to change that behavior. I wasn't clear why we didn't default to DEBUG from the start, so I needed to understand that first.12:58
jamits a trivial change to change the level of that logger12:59
jamChipaca, https://paste.ubuntu.com/p/3xf4gPctxV/12:59
jamits just a question of why was it at INFO to start with, and if we chose to change it, is a small fix for 19812:59
facubatistajam, Chipaca, we want that by default only INFO messages go to juju, and if charm developer decides to send DEBUG too, to be achievable (users always can control the level they see through `juju debug-log`, anyway)13:04
facubatistafor that behaviour to happen, we need:13:04
facubatista- the juju handler to be in DEBUG level13:04
facubatista- the logger to be in INFO by default <-- this is what the charm developer can control13:04
facubatistaI still didn't prepare a branch for #198 because I still do not understand how the charm code could change the log level according to something external, and if we could do that automatically13:05
mup_Issue #198: DEBUG log messages not emitted <bug> <Created by stub42> <https://github.com/canonical/operator/issues/198>13:05
facubatista(so the charm would emit INFO or DEBUG according to something, not harcoded)13:06
jamfacubatista, so if we call 'juju-log' then Juju itself will filter based on 'juju model-config logging-config'13:14
jamfacubatista, we could ask for a way for juju to tell us a given unit's logging config, if we wanted to avoid triggering juju-log in the first place13:14
facubatistajam, but we'd need to ask that for every message, right? as it may change at anytime13:15
jamfacubatista, so it can, but I could say that we don't notice a change inside a single hook execution13:15
facubatistajam, I like that optimization! JujuLogHandler will stop executing an external process for each message if it makes no sense13:17
facubatistajam, and all we need to do for that is set the level in JujuLogHandler according to what the config of the unit13:17
jamfacubatista, it would need a juju change, so we'd have to deal with versions-of-juju, etc.13:17
facubatistaif we have it, we use it13:18
Chipacafacubatista: jam: i think it's an optimisation we can add when/if juju gets the feature13:18
facubatistait's a good way also to "control the level of the charm"?13:19
facubatistaor there's a better way?13:19
facubatistamy point is:13:19
facubatistaI have 5 units with 5 charms; I call `juju debug-log` with level in DEBUG because I want to see debug messages of *one* of those charms, the rest I want to see them in INFO ... which is the best way to achieve that?13:20
facubatistajam, which is the unit's logging level by default?13:21
Chipacafacubatista: juju debug-log --include=theunit ?13:24
ChipacaThe '--include' and '--exclude' options filter by entity. The entity can be13:24
Chipacaa machine, unit, or application for vm models, but can be application only13:24
Chipacafor k8s models.13:24
facubatistaChipaca, that will not show me the other ones ... my point is seeing all of them, one in DEBUG the rest in INFO13:28
facubatistajam, how do I change the unit's logging config?13:28
jamfacubatista, 'juju model-config logging-config="unit.?=INFO"'13:29
jamby default 'unit=DEBUG'13:29
jamyou can do13:29
jam'juju model-config logging-config'13:29
jamto see what the default ais13:29
facubatista<root>=INFO;unit=DEBUG13:30
facubatistaroot?13:30
jamjuju model-config "logging-config=<root>=INFO;unit.unit-postgresql-0=DEBUG;unit=INFO"13:44
jamfacubatista, ^^13:44
Chipacaparallalysed == paralysed by parallelism13:56
jamniemeyer, https://github.com/canonical/operator/pull/196 still needs your follow up review14:09
mup_PR #196: Factor out the Harness changes for test_model.py <Created by jameinel> <https://github.com/canonical/operator/pull/196>14:09
jamfacubatista, I think #230 doesn't have a comment from you yet. but I think I addressed Chipaca's comments.14:09
mup_PR #230: Testing harness no events for own data <Created by jameinel> <https://github.com/canonical/operator/pull/230>14:09
jamniemeyer, looking at 196, I see a couple things that I think have been superseded. wait on that one until tomorrow.14:10
niemeyerjam: ack14:11
jamId like to land 230 and then clean up the diff14:11
facubatistajam, will check14:12
jamth14:12
jamthx14:12
Chipacatravis is slow today14:13
Chipacai guess it's because we share org with something else14:13
niemeyerjam: Added a comment in #23014:13
mup_PR #230: Testing harness no events for own data <Created by jameinel> <https://github.com/canonical/operator/pull/230>14:13
niemeyerjam: As I said, looks reasonable overall.. was just curious about that small detail14:14
Chipacahow reasonable would it be to make it so that, if you execute your charm directly with no JUJU_ stuff defined (or maybe the trigger is running it from a terminal) you get an interactive session?14:15
Chipacalike ipython with the charm already built for you to play with14:16
jamChipaca, so there are a bunch of bits that you'd need (what is your unit name, what app are you, what is your config, etc). that makes it a bit hard to be initialized and interactive  without sufficient context to know what to actually do14:16
jamwhat 'hook' are you wanting to run right now.14:16
niemeyerChipaca: That sounds like a pretty cool idea14:16
niemeyerjam: Imagine dropping it in a shell with a Harness14:16
facubatistathat would be neat14:17
Chipacaif we could do it without a harness even better (but yeah that'd require _some_ JUJU_ stuff14:17
Chipacaum14:17
jamniemeyer, I think having a good way to do that is great. I don't think 'dispatch' would quite be the entry point for that.14:17
Chipacadoes 'juju ssh' give you JUJU_ things?14:17
jamChipaca, 'juju run --unit X' does, IIRC14:18
niemeyerjam: It might error out nicely saying "Hey, you are not in a juju environment.. if you wanna play, try dispatch --foobar"14:18
Chipacayeah something like that14:18
Chipacaall the things :)14:18
niemeyerChipaca: Not sure we could do without a harness.. as jam mentioned, there's a bunch of things required. It's hard to do something when there's no data, no CLIs, no ...14:18
Chipacayep14:18
Chipacai'll try to spec it out a bit more so we can discuss (mostly just with examples of what i'd like to see)14:19
Chipacanow that i know it's not completely zany :)14:19
niemeyerThanks for that14:20
jamniemeyer, so 'relation.data[entity]' doesn't load that entities data until you do something with it. It actually doesn't even load the data if you do "relation.data[entity]['foo'] = 'bar'" because it doesn't need to know the old content of foo to set it to bar14:37
jamit only loads it if you access foo, or iterate or len(relation.data[entity])14:37
niemeyerjam: Makes sense. Would you mind to add a short note stating that, just to remind the next reader?14:38
jamsure14:38
niemeyerThanks!14:38
jamniemeyer, I confirmed with some debug statements inside the _load when you wouldn't want it to be loaded. :)14:40
* jam heads for EOD14:41
niemeyerCheers14:43
niemeyerjam: Have a good EOD14:43
* Chipaca shakes fist at multipass15:04
* facubatista -> lunch15:07
Chipacastub: 👋15:14
Chipacastub: is there a usable-for-simple-stuff postgres interface I could use?15:15
Chipacafacubatista: 2FA shenanigans, i'll be there as soon as it lets me16:00
Chipacawait, google signed me out everywhere again16:01
Chipacasigh16:01
Chipacafacubatista: I'm guessing something's come up at your end as well. Let's reschedule.16:09
mup_Issue operator#231 closed: Harness: Has errors on charms which define action handlers <Created by Vultaire> <Closed by chipaca> <https://github.com/canonical/operator/issues/231>16:10
mup_PR operator#232 closed: ops.testing.Harness actions metadata support.  (#231) <Created by Vultaire> <Merged by chipaca> <https://github.com/canonical/operator/pull/232>16:10
niemeyerChipaca: Is there something holding #203 back still?16:11
mup_PR #203: ops, test: revert the EventSet change, make EventsBase ObjectEvents <Created by chipaca> <https://github.com/canonical/operator/pull/203>16:11
Chipacaniemeyer: a review? (and now a deconflict also)16:11
niemeyerWe should make a push to these old PRs through or out16:11
niemeyerChipaca: My +1 has 12 days16:12
facubatistaChipaca, grrr, had the alarm off, sorry16:14
* facubatista is back16:14
Chipacafacubatista: huh16:29
Chipacafacubatista: https://github.com/canonical/operator/blob/master/test/test_framework.py#L77316:29
Chipacais a bit weird16:29
ChipacaI think you meant FooEvent(EventBase)16:29
ChipacaI'm mostly-EOD. Might pop in later to tinker with dispatch a little as i'm behind on where i wanted to be.17:04
Chipaca👋17:04
* facubatista brb17:09
facubatistaniemeyer, did you read this? https://setuptools.readthedocs.io/en/latest/pkg_resources.html#entry-points20:01
niemeyerfacubatista: I hadn't, will look in detail tomorrow, thanks!20:05
facubatista:)20:06
* facubatista eods21:22
mup_PR operator#203 closed: ops, test: revert the EventSet change, make EventsBase ObjectEvents <Created by chipaca> <Merged by chipaca> <https://github.com/canonical/operator/pull/203>21:59
=== narindergupta is now known as narinderguptamac

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