/srv/irclogs.ubuntu.com/2008/05/09/#upstart.txt

ion_:-)00:00
Keybukwing-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
Keybukmethod return sender=:1.1602 -> dest=:1.1605 reply_serial=2 object path "/com/ubuntu/Upstart/jobs/bar/debug"00:32
Keybukkewlios00:32
Keybukwing-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
KeybukError com.ubuntu.Upstart.Error.Singleton: Singleton jobs do not have named instances00:33
ion_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:35
Keybukthe plan is for a GetInstance(Array of String env) function00:36
Keybukwhich will hide the difference00:36
ion_But does there need to be a difference in the first place?00:36
Keybukit saves having a "magic" instance name00:37
Keybukor other strange behaviours like all names are true00:37
Keybukthe difference is exposed to the job as well00:40
Keybuksingleton jobs don't get a $UPSTART_INSTANCE variable in their environment00:40
Keybuknor do they export an $INSTANCE variable in their events00:41
Keybukstart on stopped apache failed00:41
Keybukinstead of00:41
Keybukstart on stopped apache MAGIC failed00:41
Keybukit seemed like the right approach ;)00:42
Keybukof course, it's more code to actually do it that way, so I'm willing to be persuaded ;-)00:42
Keybuk(after my bath - bbiab)00:42
ion_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:47
ion_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:50
ion_With UI, i mean the public API and job files.00:51
ion_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:54
ion_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.00:57
ion_Perhaps have the instance after 'failed'? That wouldn't be as pretty though.01:00
KeybukI originally put $INSTANCE at the end01:32
Keybukbut moved it forwards because it made more sense01:32
Keybukstart on stopped getty tty101:32
Keybukstart on stopped rc 201:32
ion_Yeah01:33
Keybukinternally there isn't *much* difference01:33
Keybuksingleton jobs have a single instance called NULL01:33
Keybukthe "get instance" function always returns it01:33
Keybukand things like job name in messages and environment know not to add the instance name01:34
Keybukit is, admittedly, quite odd that01:40
Keybuk  instance blah01:40
Keybukand omitting instance have exactly the same effect01:40
Keybukbut behave differently01:40
ion_It seems they decided that running water isn't needed here.01:41
Keybukheh01:44
Keybukbadness01:44
Amarantheh, who needs it?01:44
Keybukmaybe the right thing to do is accept "" as NULL01:44
Keybukso GetInstanceByName("") would return it01:44
ion_That sounds okay.01:45
Keybukshould it have UPSTART_INSTANCE="" in its environment and INSTANCE="" in its events?01:45
Keybukah, you can't _have_ empty environment variables01:46
Keybukheh01:46
ion_Hm01:46
ion_% export foo=; env | grep foo01:46
ion_foo=01:46
ion_% sh01:46
ion_$ env | grep foo01:46
ion_foo=01:46
Keybuk$ foo=01:47
Keybuk$ $ env | grep foo01:47
Keybuk$ 01:47
Keybukoh, forgot export01:47
Keybukdamn01:47
Keybukso back to the question01:47
ion_Exactly what are the implications of having INSTANCE="" in the events? Still using the same parameter order for e.g. 'failed' events?01:48
Keybukwell, you'd have to do01:49
Keybukstart on stopped apache "" failed01:49
Keybukor just use01:49
Keybukstart on stopped apache RESULT=failed01:49
ion_Yeah... The latter one isn't that bad IMO.01:49
Keybukis this nicer?01:50
Keybuk  start on stopped apache FAILED=pre-start01:50
Keybukor01:50
Keybuk  start on stopped apache FAILED=*01:50
Keybukie. rather than have RESULT=failed /and/ PROCESS=pre-start, combine them01:50
ion_I'm not quite sure which is nicer.01:51
KeybukFAILED=* is a little less readable I guess01:51
ion_True01:51
Keybukand you can't invert match01:51
Keybukie you wouldn't be able to match _not_ failed ;01:51
KeybukRESULT=ok works01:51
ion_Right01:51
ion_So, the default would be 'instance ""', where "" would be the canonical instance name for a singleton job?01:53
Keybukyup01:54
ion_Sounds good to me.01:55
Keybukbased on the above logic, that could be any string01:55
Keybukis there something better than just "" ?01:55
ion_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
Keybukor should we leave the something better for people who want to "instance xxx" it for nefarious purposes01:55
Keybukright, GetInstanceByName("foo") is what worked - they defined the instance name01:56
ion_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:56
Keybukand its dbus name would be /_ or something?01:57
ion_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
ion_That would be the Officialâ„¢ definition of singleton jobs: 'instance ...' doesn't refer to any variables.01:59
Keybukthat would be hardy01:59
Keybukharder01:59
Keybukfreudian slip there01:59
Keybukand I'm not sure that's right either01:59
ion_Yeah...02:00
KeybukI think it's quite valid to have a getty job with just "instance tty1"02:00
Keybukyou want to be compatible with someone else's getty job that does use instances02:00
Keybukand you wouldn't want that working for tty202:00
ion_How about 'instance $TTY' and fail if $TTY != "tty1" in pre-start script?02:01
Keybukthat's another way to do it02:01
Keybukless clean though02:01
KeybukI think that the instancebyname returning the answer for anything would be a little surprising02:02
Keybukand leading people to actually check the name after to ensure what they had02:02
Keybuke.g.02:02
Keybukname = "tty4"02:02
ion_True02:02
Keybukinstance = GetInstanceByName(name)02:02
Keybuk// can't assume instance->name == name02:02
Keybukok02:35
Keybukas usual, 20s to do, 20m to update the tests02:35
Keybukbut now Upstart has _no_ singleton functionality02:35
Keybukit just happens that the default value for instance is ""02:35
ion_Nice02:36
Keybukand yay02:46
KeybukI got rid of the annoying function02:46
ion_What was that?02:47
Keybukjob_instance ()02:51
Keybukit can now just be nih_hash_lookup02:51
Keybukit was annoying because it really should have been inside job_class, but couldn't be, because it returned Job02:56
Keybukwing-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
Keybukmethod return sender=:1.1669 -> dest=:1.1671 reply_serial=2 object path "/com/ubuntu/Upstart/jobs/foo/_"03:06
Keybukthere we go03:06
ion_Hmm13:00
ion_keybuk: How about foo: 'instance $BAR', start foo BAR=""13:00
ion_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:01
Keybukwhy would the GUI care?13:13
Keybukone of the things I like is that there's no such thing as a singleton job anymore13:14
Keybukall jobs are multi-instance, just for different values of multi, including one13:14
ion_Yeah, i didn't really think *why* the GUI should care. :-) But yeah, that's the elegance i meant.13:18
sadmac2Keybuk: Fedora comes out on Tuesday13:56
Keybukcool14:00
Keybukman, D-Bus arrays are fiddly14:01

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