/srv/irclogs.ubuntu.com/2014/07/24/#maas.txt

JJ__hi03:13
JJ__Hello?03:18
=== CyberJacob|Away is now known as CyberJacob
=== CyberJacob is now known as CyberJacob|Away
rvbabigjools: please have another look at my branch (https://code.launchpad.net/~rvb/maas/retry-power-changes/+merge/227884);  I've kept the hardcoded list of power types that support querying for now.  The way we're using the power type registry is a bit nasty: the objects it stores are JSON representation of the fields the power type requires, not proper objects that can be extended cleanly.  If we're going to09:22
rvbaextend this, I think it's worth taking a step back and seeing if we can't refactor this a bit before we had more cruft on top of what we have now.09:22
bigjoolsrvba: sure09:22
bigjoolsgimme a few, just writing an email09:23
rvbaNo worries09:23
rvbabigjools: also, if you have time after that, I'd like to talk about error reporting with you.09:24
bigjoolsrvba: first comment - the test_change_power_state_marks_the_node_broken_if_exception test won't fail if there's no Failure.  You need to do d.addBoth() and check the result is a Failure.09:38
bigjoolsdid you ever get the test to fail?  :)09:39
bigjoolsrvba: see self.assert_fails_with() which does what you want09:47
rvbabigjools: I actually *did* get the test to fail…09:49
rvbabigjools: if you apply http://paste.ubuntu.com/7846674/ the test fails.09:49
bigjoolsrvba: wrong kind of failure09:51
bigjoolsif there is no failure at all, the test will pass09:51
* bigjools writes on MP09:51
rvbabigjools: I get http://paste.ubuntu.com/7846676/, that's what I'm expecting09:51
rvbai.e. the node not being marked as broken09:52
bigjoolsrvba: wait for my MP comments, the test needs a simple fix, that's all09:52
rvbabigjools: oh, I see what you mean now09:55
bigjools:)09:55
bigjoolsrvba: there is a test helper that does it all in one line09:55
rvbaRight.09:55
bigjoolsrvba: see email09:59
bigjoolsalso a useful nugget is that you can pass debug=True to make_factory() which gives you a bunch of info about Deferreds when debugging your tests (full stack trace of where they were created is tremendously useful)10:04
rvbabigjools: hum, looks like you need to "return" assert_fails_with()10:06
bigjoolsrvba: ah yes10:06
bigjoolsreturns the deferred to the reactor10:06
rvba        d = power.change_power_state(10:08
rvba            system_id, power_type, power_change, context)10:08
rvba        d.addErrback(check)10:08
bigjoolsrvba: well what you can do, since you're adding an extra check is this (let me just write it down)10:08
rvba        return assert_fails_with(d, Exception)10:08
rvbabigjools: this ^ works.10:08
rvbaAnd check is:10:08
rvba        def check(failure):10:08
rvba            # The node has been marked broken.10:08
bigjoolsrvba: you don't need the check func you can do a lambda10:08
rvba            self.assertThat(10:08
rvba                client.mark_node_broken, MockCalledOnceWith(system_id))10:08
rvba            raise failure.value10:08
bigjoolsd.addErrback(self.assertThat, ...)10:09
bigjoolsnot a lambda... heh10:09
bigjoolsrvba: ok?10:10
rvbaHaving a cleanly defined check() method is easier on the eyes.10:10
rvbaI think.10:10
bigjoolsrvba: I massively disagree10:10
bigjoolsinline funcs are to be avoided at all costs10:10
bigjoolswell, not all, but they are hideous10:10
rvbaNot in tests when they encapsulate a tiny bit of logic that is nice to see isolated from the rest of the code.10:11
* bigjools continues to disagree10:12
rvbabigjools: in this case, I need to do two things in check(): the test itself and then re-raise the exception10:12
bigjoolsrvba: no you don't need to re-raise10:12
bigjoolsif you add the errbacks in the right order, anyway10:12
rvbabigjools: if I don't re-raise, the exception is swalled and assert_fails_with fails10:12
rvbaoh, I see.10:13
bigjoolsrvba: d = self.assert_fails_with ...10:13
rvbaassert_fails_with returns a deferred10:13
rvbabigjools: yeah10:13
bigjoolsd.addErrback(...10:13
rvbabigjools: so that's what you're suggesting then? http://paste.ubuntu.com/7846751/10:17
bigjoolsrvba: no need to re-assign d10:17
bigjoolsbut basically, yeah10:18
rvbaIt's not failing properly when no exception is raised…10:18
* rvba reads the documentation for d.addErrback…10:19
rvbabigjools: http://paste.ubuntu.com/7846769/ that's better10:20
bigjoolsah yes sorry, forgot the extra arg :)10:21
bigjoolsnormally it's not needed but because you have other callbacks ...10:21
rvbaRight.10:23
bigjoolsrvba: that;s interesting.  The test func where you added the yield doesn't have inlinecallbacks10:43
rvbabigjools: ah!10:43
bigjoolsIt's fine, but ...10:44
bigjoolsrvba: is assert_fails_with not on the testcase?10:44
bigjoolsself.assert_fails_with ... ?10:44
rvbaNo, it's not.10:44
bigjoolshuh, weird.  Someone must have patched it in on the LP tests then10:45
bigjoolsrvba: I reckon we should change our test cases to have it10:46
rvbabigjools: it's only used in two places now (including the one I'm adding) so the fix should be tiny.10:47
rvbabigjools: how do you explain "yield method()" works without the inlinecallbacks decorator?10:49
bigjoolsit's a generator...10:49
rvbaBut how come the test runner deals with that transparently?10:50
bigjoolsI suspect you don't need the run_tests_with10:51
bigjoolsit's never hitting the reactor10:51
rvbabigjools: when I call power.change_power_state() without explicitly passing a reactor, the default one gets used…10:53
bigjoolsI mean the tests are not relying on it10:53
rvbaBut when 'yield pause(waiting_time, reactor)' gets called, this should hit the reactor shouldn't it?10:55
bigjoolsrvba: not if inlinecallbacks is missing it's not :)11:08
rvbabigjools: but I've got other test methods with inlinecallbacks.  They pass with or without it.11:09
bigjoolsmeh, the lack of an easy way to run a quick image import on canonistack is annoying11:09
bigjoolsneed a sources file now11:09
bigjoolsrvba: right, because the tests are not relying on the reactor spinning, just the clock11:09
rvbabigjools: but the clock defaults to twisted.internet.reactor11:12
bigjoolsrvba: not the one you're relying on11:12
rvbabigjools: I'm talking about other tests which don't use Clock() at all.11:13
bigjoolsI'm not doing a good job of explaining, sorry11:13
jtvWho wants to review my database migration fix for trunk?  https://code.launchpad.net/~jtv/maas/bug-1347579/+merge/22809912:27
bigjoolsjtv: I would be delighted to12:27
jtvThank you.12:27
allenapPlease can a review get I? https://code.launchpad.net/~allenap/maas/rpc-get-preseed-data-helper/+merge/22808613:40
rvbaallenap: I'll look at it in a sec13:40
allenaprvba: Thanks.13:40
bigjoolsallenap: pserv logging.  it's, erm, not doing a lot13:52
bigjoolsis the python logger wired up?13:52
bigjoolsto twisted's, I mean13:53
=== jfarschman is now known as MilesDenver
allenapbigjools: What’s happening specifically?13:56
bigjoolsallenap: two problems:14:08
bigjools1. logger.info() is not appearing in the log14:09
bigjools2. the log is swamped with RPC connection reporting which is annoying14:09
roaksoaxbigjools: so I was thinking, would it be a good idea to start working on Unified Logging?14:13
roaksoaxsince most of the new logging that we will be doing in all of the work14:13
roaksoaxwill need to end up in a unified log14:13
bigjoolsroaksoax: that's a terrible idea right now, but when everything else in progress is done, it will be an excellent idea14:13
roaksoaxbigjools: right, but we need to start consolidating logs in a single location anyway, instead of creating new logs for new stuff14:15
allenapbigjools: I shall look.14:16
bigjoolsroaksoax: there is nothing that I know of that is going to require a new log14:16
allenaproaksoax: Yeah, let’s just clean up what we have for now, get over the hump, no new development right now. In a month we can do something a bit more structured.14:17
bigjoolsallenap: thanks.14:18
allenapbigjools: logger.info() probably not appearing because we’re not configuring the standard lib's logging in pserv.14:23
bigjoolsallenap: I think we need to build some retrying backoff algorithm into getClient()14:23
bigjoolsallenap: yes that;s what I guessed at 14:5214:23
bigjoolsgetClient fails hard and quick, and this is not a normal situation, we expect RPC to always be up.  It could be that we're trying to access too quickly after startup.14:24
allenapbigjools: We can wire up Twisted’s log to the standard lib’s logging with PythonLoggingObserver.14:25
allenapAnd that’s probably a good thing to do.14:25
bigjoolsyes14:25
bigjoolsallenap: how evil would it be to put inlineCallbacks on __init__ ? :)14:27
bigjoolsI need a startup pause for the image checking service because of this getClient thing14:27
allenapbigjools: We could add a queue to ClusterClientService for getClient requests.14:30
allenapbigjools: inlineCallbacks on __init__ won’t work.14:30
bigjoolsyeah I figured14:30
bigjoolsallenap: client(GetBootSources) is returning a string.  Is that right?14:45
allenapbigjools: Nope, it returns a {“sources”: {…lots of stuff…}}. See GetBootSources.response for the schema.15:03
bigjoolsallenap: I am getting a very very weird error15:03
bigjoolslet me paste15:03
bigjoolsallenap: http://paste.ubuntu.com/7848044/15:04
bigjoolsthe returned data looks ok15:04
bigjoolsoh no.... do I really have to do returned_data['sources'] ...15:05
allenapbigjools: Yep, that’s it.15:09
bigjoolsallenap: so did that, got further: http://paste.ubuntu.com/7848059/15:09
bigjoolsI feel we're lacking in some integration tests15:09
allenapYep :)15:11
bigjoolsallenap: seriously - there's too much connection mocking, we really need end-to-end tests15:12
allenapbigjools: I’m not sure that the response that GetBootSources gives was designed to exactly slot into existing code. It was designed to make sense first of all :)15:12
rvbabigjools: I know you're busy right now but here is the MP that implements what we talked about earlier: https://code.launchpad.net/~rvb/maas/improve-broken-state/+merge/22813215:12
bigjoolsroaksoax: ack15:13
allenapbigjools: You’re the one wiring it up for the first time, so you get to write the integration tests.15:13
bigjoolsrvba: ack15:13
bigjoolsffs15:13
bigjoolsallenap:yay?15:13
allenapbigjools: Think of how good you’ll feel when it’s done :)15:18
bigjoolsallenap: I always enjoy finishing someone else's work ;)15:19
allenapbigjools: Great, I think I have some more for you :)15:21
bigjoolsallenap: arf!15:23
bigjoolsallenap: do we have any infra to set it up in a test?15:23
allenapbigjools: There’s ClusterRPCFixture for the other direction. You could replicate that for cluster->region.15:32
bigjoolsallenap: right15:43
bigjoolsallenap: so I see the problem15:45
bigjoolsthe keyring data is returned in sources, but the importer code wants it in a file15:45
bigjoolsI love it when the rabbit hole deepens like this15:45
bigjoolsso I can't just pass that sources obj that rpc returns15:46
bigjoolswhat I want to know is, how is the file written normally when the celery job runs15:46
bigjoolsargh15:49
allenapbigjools: That’s done in boot_resources.import_images, right? write_all_keyrings15:50
bigjoolsargh arfg argf15:50
bigjoolsallenap: the rpc code has a bug15:52
bigjoolsit's returning the data in a field with an incorrect name15:52
bigjools"keyring" is the filename, "keyring_data" is the, well, data15:52
bigjoolsbut the call uses the former for the latter15:52
bigjoolsallenap:15:54
bigjools        keyring_data = source.pop("keyring_data")15:54
bigjools        source["keyring"] = b64decode(keyring_data)15:54
bigjoolswhy!15:54
bigjoolsthinko or deliberate?15:55
allenapbigjools: Deliberate. BootSource.to_dict() is the one smoking crack for the benefit of Celery. The cluster never needs to know the filename. To the cluster the keyring is the keyring, it does not need to be qualified with a _data suffix. Once the Celery task is gone we can fix BootSource.to_dict().15:59
bigjoolsallenap: I'm changing it back to keyring_data, because it's the least path of resistance15:59
allenap(It’s smoking crack because the model is where the base-64 encoding is happening, instead of where the task is dispatched.)16:00
bigjoolsthe code in import_resources relies on all of this16:00
bigjoolsit's not just celery16:00
allenapbigjools: Jumping off a cliff is a quick way to the bottom.16:00
bigjools\o/16:00
bigjoolsI prefer keyring_data tbh.  I doesn't leave me wondering if it's a filename or the data16:01
bigjoolskeyring on its own is ambiguous16:01
bigjoolsand in fact more confusing because the gpg executable uses --keyring=<filename>16:01
allenapbigjools: Either way, fix BootSource.to_dict() when you delete the import_boot_images task.16:02
allenapbigjools: Note that everything assumes that keyring_data is base-64 too. You’ll need to disabuse everything of that notion.16:03
bigjoolsallenap: sigh :(16:05
bigjoolsallenap: for now I am going to ensure that everything RPC is bytes and not b6416:05
bigjoolsit's a good cutpoint.16:05
allenapYeah.16:06
bigjoolsallenap: I have a dilemma16:43
bigjoolsthere's a time when the importer code needs to deal with both b64 and bytes for the keyring16:44
bigjoolsbefore both the scheduled job and manual import are migrated to rpc16:44
allenapThe only way out is through.16:44
* allenap is the font of aphorisms today.16:45
allenapbigjools: Well, you /could/ name one "keyring_data" and the other, oh, I don’t know, just “keyring”? :)16:46
bigjoolsallenap: fooey16:46
bigjoolsdoesn't help anyway16:47
bigjoolsall the underlying code assumes b6416:47
bigjoolscan I detect which it is and DTRT16:47
allenapbigjools: You could try decoding base-64 and catch exceptions, but that’s not without risk.16:51
bigjoolsyeah16:51
bigjoolsI'll decode it when the task is called16:51
allenapYeah, that works.16:51
bigjoolsnot when pumped right into the underlying code :/16:51
allenapPerfick.16:51
bigjoolsthen when the task gets removed eventually, all will be well16:52
bigjoolsallenap: so there is a slight flaw in the plan for detecting when to run a download :(16:59
bigjoolsalthough it's not the end of the world16:59
bigjoolsmaas.meta only gets updated when there is something to download.  So once it's a week old, we run the downloads hourly :)16:59
bigjoolsallenap: bug 1271188 is getting more attention now, and I am also a little frustrated.  Let's stick it on the list while we're doing this work?17:11
ubot5bug 1271188 in MAAS "maas-import-ephermerals provides no feedback on progress" [High,Triaged] https://launchpad.net/bugs/127118817:11
bigjoolsallenap: if you want a gander I have a WIP MP, I'm offski now.  There's a bit more to do to stop that hourly checking.17:18
bigjoolshttps://code.launchpad.net/~julian-edwards/maas/replace-celery-download-job-with-pserv/+merge/22816817:18
allenapbigjools: Ha! We could ensure that maas.meta is touched after each successful run, or use another reference file.17:25
allenapbigjools: I’ll be back online later, but I’m off now too. I’ll try to have a look at that wip.17:26
=== CyberJacob|Away is now known as CyberJacob
=== roadmr is now known as roadmr_afk
=== jfarschman is now known as MilesDenver
=== roadmr_afk is now known as roadmr
=== jfarschman is now known as MilesDenver
=== CyberJacob is now known as CyberJacob|Away
=== CyberJacob|Away is now known as CyberJacob
=== jfarschman is now known as MilesDenver
=== CyberJacob is now known as CyberJacob|Away

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