/srv/irclogs.ubuntu.com/2012/12/19/#juju-dev.txt

rogpeppemornin!08:01
dimiternrogpeppe: ping08:34
rogpeppedimitern: pong08:34
dimiternrogpeppe: hey, I wanted to ask you about your suggestion to implement a response which is also an error08:35
rogpeppedimitern: ok08:35
dimiternrogpeppe: what do I need there? func (resp..) Error() string ?08:35
rogpeppedimitern: exactly that08:35
dimiternrogpeppe: and how to verify the type? x.(respError) ?08:36
rogpeppedimitern: i suggest you use *response throughout, as it's conventional to use pointer types for errors08:36
dimiternrogpeppe: ok08:36
rogpeppedimitern: the type is already verified - it's the receiver08:36
rogpeppedimitern: ah, you mean for actually sending the error?08:37
dimiternrogpeppe: a short example of your idea will be appreciated08:37
rogpeppedimitern: ok, one mo08:37
rogpeppedimitern: i'm thinking of something like this: http://paste.ubuntu.com/1449605/09:08
dimiternrogpeppe: 10x!09:08
rogpeppedimitern: there are quite a few places that might be different based on requirements, but i *think* the basic idea is sound09:10
dimiternrogpeppe: I'll try it out, looks good09:11
dimiternrogpeppe: couldn't I instead of having all the fields of the response object, just embed it, then I'll have send(w, r) already and just need Error() string09:13
rogpeppedimitern: do you actually need the response type any more?09:14
dimiternrogpeppe: also, is there a particular reason to create *errorResponse vars instead of non-pointers?09:14
dimiternrogpeppe: ah, you mean replace it, ok09:14
rogpeppedimitern: error types are conventionally pointers09:14
dimiternrogpeppe: but is it enough to have Error() on it to be treated like *error ?09:15
rogpeppedimitern: it is, yes09:15
rogpeppedimitern: but concrete error types are usually pointers09:15
dimiternrogpeppe: ok, cool, I though it was more complex :)09:15
rogpeppedimitern: BTW s/*error/error/ above09:16
rogpeppedimitern: the error interface is just interface{Error() string}09:16
dimiternrogpeppe: but then not all responses are errors, wouldn't it be misleading to call it errorResponse?09:16
rogpeppedimitern: AFAICS you're only using the response type for errors currently09:17
dimiternrogpeppe: well, not exactly - noContentResponse is one example09:18
dimiternacceptedResponse is another09:18
rogpeppedimitern: both of those seem like things that could be done inline or with a simple helper function09:19
rogpeppedimitern: (neither include any significant nova-specific text)09:19
dimiternrogpeppe: well, they're exactly as nova sends them, but I'll think of a helper09:20
rogpeppedimitern: both of them can be done by simply setting the http status code09:21
rogpeppedimitern: as in, w.WriteHeader(http.StatusNoContent)09:21
rogpeppedimitern: i don't think you need anything more09:21
dimiternrogpeppe: I need the body for accepted09:22
dimiternrogpeppe: but I'll create a simpleResponse or something for that09:22
rogpeppedimitern: accepted has an empty body - don't you get that by default?09:23
dimiternrogpeppe: yes, you're right, actually for swift there was a body09:23
rogpeppedimitern: anyway, if you do need a custom body, a helper like your sendJSON function would work fine09:24
dimiternrogpeppe: ok09:25
jamrogpeppe: I found the reason mongod is failing to start: error command line: unknown option sslOnNormalPorts10:12
rogpeppejam: ah!10:13
rogpeppejam: you need to use the mongodb that we're using in the cloud10:13
rogpeppejam: doh, i should have thought of that10:13
jamdimitern: ^^ so the issue is that mongod that is available by default from Ubuntu doesn't have the new flags that juju-core wants.10:13
jamrogpeppe: where can you get that one? A ppa?10:14
jambuild from scratch?10:14
jamrogpeppe: oddly enough, .Start() sees no failure, but we also don't set cmd.Stderr or cmd.Stdout to anything, so we never see that it actually says there is a problem.10:14
rogpeppejam: fetch it from s3. you can find the URL in environs/cloudinit.10:14
dimiternjam: so that was the problem10:14
jamd10:14
jamdimitern: that was the first problem at least10:14
rogpeppejam: start won't see a failure, because the binary started just fine10:15
jamrogpeppe: and then put it where?10:15
rogpeppejam: in your path10:15
rogpeppejam: http://juju-dist.s3.amazonaws.com/tools/mongo-2.2.0-$series-$arch.tgz10:16
rogpeppejam: i think we've only built it for precise and quantal so far10:17
rogpeppejam: and amd6410:17
jamrogpeppe: I'm on quantal which is fine, but 32-bit, and http://juju-dist.s3.amazonaws.com/tools/http://juju-dist.s3.amazonaws.com/tools/mongo-2.2.0-quantal-amd64.tgz still gives me 40410:17
rogpeppejam: presumably you didn't double up the URL when you actually tried it?10:17
jamI did, I guess.10:18
jami386 doesn't exist10:18
jamamd64 does10:18
rogpeppejam: there's a builddb charm if you want to build your own10:18
rogpeppejam: unfortunately there's a chicken/egg problem, i think10:19
rogpeppejam: 'cos i'm not sure we can have units with a different architecture to the bootstrap node yet10:19
rogpeppejam: you might be able to use the python juju to run the builddb charm on 38610:21
jamrogpeppe: so to go back to a bit more basic, what is a good way to make sure the test suite doesn't just hang with no information in these circumstances?10:22
jamIt seems to wait indefinitely to try to connect to a mongod that isn't running10:22
rogpeppejam: it's a good question. the problem is that mongodb prints out shitloads of info, far too much to log by default10:23
jam(I may have to switch to 64-bit, but dimitern still has that problem without indication of what is wrong)10:23
rogpeppejam: i'm not sure if it prints to stdout or stderr though10:23
rogpeppejam: one possibility might be to wait for a little while after starting mongodb, to make sure it doesn't exit quickly with a usage or similar startup error10:24
jamrogpeppe: well my thought is that whatever bit is polling trying to connect to the port could timeout if it hasn't connected, then check if the child process is running, then try to connect again10:25
jamrather than to just hang trying to connect.10:25
jamnot sure how the layering is.10:25
jamUnfortunately, the "bad command line" error message goes to Stdout, just like all the other spew when things are working correctly.10:25
rogpeppejam: the code that is trying to connect is just the regular state open code - it has no idea that it's connecting to a local mongodb10:25
jamwe could still put that into a bytes.Buffer in case we want to log it because the process died early.10:25
jamrogpeppe: but why would state.Open wait indefinitely either?10:26
rogpeppejam: because we might be connecting to a mongodb on an instance that's starting up, which may take 10 minutes10:26
rogpeppejam: i think that probably the code that starts mongodb should log something when mongodb dies.10:27
jamrogpeppe: so the code starting mongo is MgoTestPackage, which has a defer destroyMgoServer10:31
rogpeppejam: yup10:31
jamwould it be sensible to start a goroutine to monitor it for stopping early (not by destroy) and log something?10:31
rogpeppejam: i think so. although there may be subtle issues around that. i'll have a look.,10:32
jamrogpeppe: there doesn't seem to be a exec.Cmd.Poll()10:33
jamjust Wait()10:33
rogpeppejam: Wait should be sufficient10:33
jamrogpeppe: so how does it get layered if you want to Wait() to see if it exits early, but have a kill switch in destroy...() so that if destroy is stopping it, that the Wait goroutine doesn't print debug info.10:35
jamI'd also arguably like to grab log info, but preferrably not buffer all of it for the whole lifetime of the process.10:36
rogpeppejam: it's not too hard - i'll knock something up10:36
rogpeppejam: i think it's easier just to buffer the whole thing10:36
rogpeppejam: otherwise you'll need to implement some kind of bounded buffer, which is probably unnecessary.10:37
jamwell, its easier, but the total output from mongodb during the course of a full test suite (it is started once at the beginning, and not shut down until the test suite finishes) could be a bit much10:37
rogpeppejam: i guess, but what's a few MB these days? :-)10:37
jamso dimitern, short answer for you is to download http://juju-dist.s3.amazonaws.com/tools/mongo-2.2.0-quantal-amd64.tgz and put the binary in your path, we'll try to sort out the rest.10:38
jamrogpeppe: as long as it is small MB, not a big deal.10:38
dimiternjam: yeah, pity I'm still on precise10:38
jamdimitern: there should be a precise-amd64 as well10:38
rogpeppedimitern: precise works too10:38
jamthere just isn't a i386 version.10:38
dimiternah, ok10:39
jamrogpeppe: a thought. You could wait until you get 1 line of output from mongodb since you end up waiting for it to start regardless.10:44
jamif it then dies, you can log the output10:44
jamat least, if there is a commandline problem, you'll see it right away.10:45
jamthough having a bigger "dump the mongodb output if the process dies" would be useful for lots of other sorts of failures10:45
jamso it is probably good to have something more generic anyway.10:45
rogpeppejam: you'll see the line of output before you know if it's died with an error10:45
rogpeppejam: so you'll still have to wait a while to see if you want to print the line10:46
jamrogpeppe: well the one line is "error command line: ..."10:46
rogpeppejam: so we catch that one particular class of error, but there may be other kinds of error that don't fit that pattern10:47
jamyeah10:47
jamso if you had a way to short-term Wait() it would work10:47
jambut you don't, you have to put out a goroutine to wait and put it on a channel or whatever.10:47
rogpeppejam: we can easily short-term wait if we want to10:47
jamrogpeppe: I don't see a way to interrupt Wait()10:47
jamso how do you make it 'short-term' ?10:47
rogpeppejam: as you say, start a goroutine that does wait and sends the result on a channel10:48
jamrogpeppe: which means it is around forever?10:48
rogpeppejam: sure, why not?10:48
jamrogpeppe: I don't see a "builddb" charm in the charmworld "precise" list that I downloaded, I do see mongodb, but no mention of builddb. Is there a doc I should be looking at?12:14
jamBTW, the 'README' should be updated with how to install mongodb, since "apt-get install mongodb" isn't sufficient anymore.12:15
rogpeppejam: builddb is a command in the source tree. tbh, i think it should just be a charm, but it was an interesting experiment.12:34
rogpeppejam: BTW it seems that mongodb always does exit(0) even when it gets a usage error12:35
rogpeppejam: marvellous12:35
jamrogpeppe: how very nice of it. But at least you could detect that it had exited early, I guess.12:36
jamso just running "builddb" it tries to bootstrap my environment and says it is already bootstrapped...12:36
rogpeppejam: that's true. i think it should never exit unless killed, and that's easy to detect12:36
rogpeppejam: yeah, it shouldn't bootstrap. have you actually got a bootstrapped environment, or is that just a hangover from a previous bootstrap?12:37
jamrogpeppe: I probably ran something in the past12:37
rogpeppejam: if the latter, just do juju destroy-environment first12:37
rogpeppejam: https://codereview.appspot.com/696604513:07
dimiternrogpeppe, fwereade_: PTAL https://codereview.appspot.com/6940073/13:11
rogpeppedimitern: looking13:11
=== bcsaller1 is now known as bcsaller
rogpeppedimitern: you've got another review14:05
dimiternrogpeppe: cheers!14:05
dimiternrogpeppe: ok, I'm a bit confused why you think sendError(err, w, r) is redundant - how can I send errors which are not errorResponse then?14:19
rogpeppedimitern: novaHandler.ServeHTTP handles this case14:20
rogpeppedimitern: that's why you're testing for err.(http.Handler)14:20
dimiternrogpeppe: you mean after the internal handler is called?14:20
dimiternrogpeppe: I see, ok14:21
rogpeppedimitern: basically, we allow some errors to know how to marshal themselves as an http response.14:21
rogpeppedimitern: others we use the default internal error for14:22
dimiternrogpeppe: and others we wrap, yeah, nice!14:22
dimiternrogpeppe: I wanted something like that initially, but wasn't sure how's best14:22
rogpeppedimitern: i think it works quite nicely :-)14:22
rogpeppedimitern: it's a pity that we need to match all the real server's errors so exactly. it really clutters the code.14:24
dimiternrogpeppe: yeah, but I was thinking of implementing like a generic subhandler for a path + method14:25
dimiternrogpeppe: then, I can have several of these which are just doing the same (like put/post or get/delete pairs - lots of these can be trimmed)14:25
rogpeppedimitern: that probably wouldn't be too hard.14:26
dimiternrogpeppe: assuming we define them similarly in a map like setupHTTP14:26
dimiternrogpeppe: or, maybe even better - implement them an get a helper to be called for a list of methods, path and handler14:27
dimiternrogpeppe: come to think of it, not even the path is needed14:30
dimiternrogpeppe: can I have a handlersMap := map[[]string][]*handler14:33
rogpeppedimitern: no14:33
rogpeppedimitern: but there's actually no particular reason for handlersMap to be a map14:33
rogpeppedimitern: tbh, i'm not sure how much you'd win14:34
dimiternrogpeppe: yeah, probably shouldn't bother anyway - this is just a testing service14:35
dimiternrogpeppe: i should just work14:35
rogpeppedimitern: i think it's quite nice to have all the irregularity of the server's interface laid out so it's easy to see. like errNotFound vs errNotFoundJSON, wtf?!14:36
dimiternrogpeppe: yep, it's like that - probably as a result of stitching different backends together :)14:38
dimiternrogpeppe: or more likely smart inner and quick and dumb outer API handlers - the inner taking into account I said Accept: json14:41
dimiternrogpeppe: and the outer just returning 404 plain early for unexpected URLs14:42
hazmatrogpeppe, do you happen to recall which version of golang has the broken http client.. one of our lbox users is still hitting panics.. even after a manual compile of lbox with 1.0.3 ... https://pastebin.canonical.com/80719/15:39
rogpeppehazmat: 1.0.315:40
rogpeppehazmat: the most recent version, unfortunately15:40
hazmateek15:40
rogpeppehazmat: they could use tip or 1.0.215:40
hazmatrogpeppe, so 1.0.2 which is the default in the quantal archive should work ok then15:40
hazmatcool15:40
rogpeppehazmat: it should15:41
hazmatrogpeppe, thanks15:41
rogpeppehazmat: np15:41
hazmatrogpeppe, i think he tried it with 1.0.2 as well, but i'll verify next year (he's on holiday)15:41
dimiternrogpeppe: ping16:18
rogpeppedimitern: pong16:18
dimiternrogpeppe: I'm almost done, fixing a few tests, but I'm having trouble debugging "multiple WriteHeader calls" message - how can I plug into the log that gocheck uses?16:19
rogpeppedimitern: is that a panic, or is WriteHeader returning an error?16:20
dimiternrogpeppe: "2012/12/19 17:20:12 http: multiple response.WriteHeader calls" - think it's more like a warning16:21
rogpeppedimitern: i recommend just finding that log message in the http package and turning into a panic, then running the test again16:21
rogpeppedimitern: (remember to change it back afterwards...)16:22
rogpeppedimitern: there are other ways, but that's the easiest16:22
rogpeppedimitern: alternatively, change all occurrences of WriteHeader in your code to call a local function that writes a log message before calling WriteHeader16:23
rogpeppedimitern: (that should be easy enough to do with a global substitution)16:23
dimiternrogpeppe: ha, ok.. wouldn't think it's that easy :)16:24
dimiternrogpeppe: ok, all done, please take a look, I'd really like to land this today https://codereview.appspot.com/6940073/16:49
rogpeppedimitern: looking (thanks for bearing with me - i hope you think it's worth it!)16:49
dimiternrogpeppe: sure, I appreciate your comments and see how to do things simpler in the future16:50
rogpeppedimitern: reviewed17:11
dimiternrogpeppe: thanks!17:12
dimiternrogpeppe: ready with all suggestions - do you want to look at it or I should just submit it?17:35
rogpeppedimitern: i'll just have a quick look17:36
rogpeppedimitern: have you proposed it?17:36
dimiternrogpeppe: it's under way17:36
dimiternhttps://codereview.appspot.com/694007317:36
rogpeppedimitern: reviewed. looks great. two small things still to do, but it looks great in general.17:44
dimiternrogpeppe: thanks again17:45
dimiternrogpeppe: with these, I'm submitting17:50
rogpeppedimitern: great17:50
dimiternI'm off then, 'night guys!17:52
* rogpeppe is off too.18:22
rogpeppeg'night all18:22
fwereade__rogpeppe, heyhey, I'm very much not working -- but if you are later this week, I'd love a final look at https://codereview.appspot.com/6944058/23:09
rogpeppefwereade__: me neither currently (just playing with new camera) but will look tomorrow23:10
fwereade__rogpeppe, cheers :)23:11

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