[00:00] :-) [00:32] wing-commander upstart% dbus-send --system --dest=com.ubuntu.Upstart --type=method_call --print-reply /com/ubuntu/Upstart/jobs/bar com.ubuntu.Upstart.Job.GetInstanceByName string:"debug" [00:32] method return sender=:1.1602 -> dest=:1.1605 reply_serial=2 object path "/com/ubuntu/Upstart/jobs/bar/debug" [00:32] kewlios [00:33] wing-commander upstart% dbus-send --system --dest=com.ubuntu.Upstart --type=method_call --print-reply /com/ubuntu/Upstart/jobs/foo com.ubuntu.Upstart.Job.GetInstanceByName string:"active" [00:33] Error com.ubuntu.Upstart.Error.Singleton: Singleton jobs do not have named instances [00:35] I'm thinking that perhaps there should be no differentiation between singleton jobs and ones with multiple instances ‒ just assume 'instance default' or something similar as the default, which makes it a singleton and the same logic applies to all jobs. [00:36] the plan is for a GetInstance(Array of String env) function [00:36] which will hide the difference [00:36] But does there need to be a difference in the first place? [00:37] it saves having a "magic" instance name [00:37] or other strange behaviours like all names are true [00:40] the difference is exposed to the job as well [00:40] singleton jobs don't get a $UPSTART_INSTANCE variable in their environment [00:41] nor do they export an $INSTANCE variable in their events [00:41] start on stopped apache failed [00:41] instead of [00:41] start on stopped apache MAGIC failed [00:42] it seemed like the right approach ;) [00:42] of course, it's more code to actually do it that way, so I'm willing to be persuaded ;-) [00:42] (after my bath - bbiab) [00:47] I was thinking that it would be more elegant if the implementation under the hood didn't know the difference between singleton and instanced jobs and the user interface was the one that does something (didn't think that far yet) to avoid exposing the "magic" variable. It wouldn't really be magic, it would just be anything constant. [00:50] But if the part about moving the separation from the job implementation to UI makes the UI code suck, it's not worth it of course. [00:51] With UI, i mean the public API and job files. [00:54] For instance, the API could expose a GetInstance method that only returns a single instance when the job's "instance" value does not reference a variable. [00:57] And it would be kind of nice if 'start on stopped apache failed' caused the job to start whenever 0) any apache instance fails if apache has instances or 1) the apache instance fails if it's singleton. [01:00] Perhaps have the instance after 'failed'? That wouldn't be as pretty though. [01:32] I originally put $INSTANCE at the end [01:32] but moved it forwards because it made more sense [01:32] start on stopped getty tty1 [01:32] start on stopped rc 2 [01:33] Yeah [01:33] internally there isn't *much* difference [01:33] singleton jobs have a single instance called NULL [01:33] the "get instance" function always returns it [01:34] and things like job name in messages and environment know not to add the instance name [01:40] it is, admittedly, quite odd that [01:40] instance blah [01:40] and omitting instance have exactly the same effect [01:40] but behave differently [01:41] It seems they decided that running water isn't needed here. [01:44] heh [01:44] badness [01:44] eh, who needs it? [01:44] maybe the right thing to do is accept "" as NULL [01:44] so GetInstanceByName("") would return it [01:45] That sounds okay. [01:45] should it have UPSTART_INSTANCE="" in its environment and INSTANCE="" in its events? [01:46] ah, you can't _have_ empty environment variables [01:46] heh [01:46] Hm [01:46] % export foo=; env | grep foo [01:46] foo= [01:46] % sh [01:46] $ env | grep foo [01:46] foo= [01:47] $ foo= [01:47] $ $ env | grep foo [01:47] $ [01:47] oh, forgot export [01:47] damn [01:47] so back to the question [01:48] Exactly what are the implications of having INSTANCE="" in the events? Still using the same parameter order for e.g. 'failed' events? [01:49] well, you'd have to do [01:49] start on stopped apache "" failed [01:49] or just use [01:49] start on stopped apache RESULT=failed [01:49] Yeah... The latter one isn't that bad IMO. [01:50] is this nicer? [01:50] start on stopped apache FAILED=pre-start [01:50] or [01:50] start on stopped apache FAILED=* [01:50] ie. rather than have RESULT=failed /and/ PROCESS=pre-start, combine them [01:51] I'm not quite sure which is nicer. [01:51] FAILED=* is a little less readable I guess [01:51] True [01:51] and you can't invert match [01:51] ie you wouldn't be able to match _not_ failed ; [01:51] RESULT=ok works [01:51] Right [01:53] So, the default would be 'instance ""', where "" would be the canonical instance name for a singleton job? [01:54] yup [01:55] Sounds good to me. [01:55] based on the above logic, that could be any string [01:55] is there something better than just "" ? [01:55] The user would have the ability to do 'instance foo', but would just have to accept that then the canonical GetInstanceByName("") wouldn't work. [01:55] or should we leave the something better for people who want to "instance xxx" it for nefarious purposes [01:56] right, GetInstanceByName("foo") is what worked - they defined the instance name [01:56] I find "" a good default. Just document that 'instance ""' is the right thing to do (and the default value) for a singleton job and GetInstanceByName("") is the canonical way to get to it. [01:57] and its dbus name would be /_ or something? [01:59] Hm. Or perhaps have such magic in the d-bus code that GetInstanceByName("") and /_ point to the single instance whenever 'instance foo' doesn't refer to any variables? [01:59] That would be the Official™ definition of singleton jobs: 'instance ...' doesn't refer to any variables. [01:59] that would be hardy [01:59] harder [01:59] freudian slip there [01:59] and I'm not sure that's right either [02:00] Yeah... [02:00] I think it's quite valid to have a getty job with just "instance tty1" [02:00] you want to be compatible with someone else's getty job that does use instances [02:00] and you wouldn't want that working for tty2 [02:01] How about 'instance $TTY' and fail if $TTY != "tty1" in pre-start script? [02:01] that's another way to do it [02:01] less clean though [02:02] I think that the instancebyname returning the answer for anything would be a little surprising [02:02] and leading people to actually check the name after to ensure what they had [02:02] e.g. [02:02] name = "tty4" [02:02] True [02:02] instance = GetInstanceByName(name) [02:02] // can't assume instance->name == name [02:35] ok [02:35] as usual, 20s to do, 20m to update the tests [02:35] but now Upstart has _no_ singleton functionality [02:35] it just happens that the default value for instance is "" [02:36] Nice [02:46] and yay [02:46] I got rid of the annoying function [02:47] What was that? [02:51] job_instance () [02:51] it can now just be nih_hash_lookup [02:56] it was annoying because it really should have been inside job_class, but couldn't be, because it returned Job [03:06] wing-commander upstart% dbus-send --system --dest=com.ubuntu.Upstart --type=method_call --print-reply /com/ubuntu/Upstart/jobs/foo com.ubuntu.Upstart.Job.GetInstanceByName string:"" [03:06] method return sender=:1.1669 -> dest=:1.1671 reply_serial=2 object path "/com/ubuntu/Upstart/jobs/foo/_" [03:06] there we go [13:00] Hmm [13:00] keybuk: How about foo: 'instance $BAR', start foo BAR="" [13:01] It would *work*, of course, but e.g. a GUI could not just test whether there's a running instance called "" and say it's singleton, it would have to check the value of 'instance ...' [13:13] why would the GUI care? [13:14] one of the things I like is that there's no such thing as a singleton job anymore [13:14] all jobs are multi-instance, just for different values of multi, including one [13:18] Yeah, i didn't really think *why* the GUI should care. :-) But yeah, that's the elegance i meant. [13:56] Keybuk: Fedora comes out on Tuesday [14:00] cool [14:01] man, D-Bus arrays are fiddly