/srv/irclogs.ubuntu.com/2011/03/11/#upstart.txt

twbIn lucid, I have an upstart task that runs "iptables-restore /etc/iptab".04:08
twbIf this fails, I want the system to freak out and disable all services -- say, switching to single-user mode.04:09
twbHow would I configure this?04:09
twbCan I have two "pre-start exec" lines (instead of a pre-start script)?04:46
mbiebltwb: no06:06
twbOkey dokey06:40
atpa8ahello18:21
atpa8aany clues how i can enforce that the all of the network interfaces are up before sysvinit scripts run?..18:21
Keybukatpa8a: I've already answered your question three times18:28
* ion notices Keybuk isn’t a Conan fan.18:29
KeybukConan?18:29
atpa8aKeybuk: sorry, must've missed18:30
Keybukatpa8a: to change the state in which sysvinit scripts are run, you edit the /etc/init/rc-sysinit.conf file18:30
ionkeybuk: http://www.youtube.com/watch?v=iNu3MW-lb6Y18:30
Keybukand change the "start on" kine18:30
Keybukas you can see, right now it says to start when the *loopback* network interface is up18:31
Keybukbut no other18:31
Keybukif you alter that start on line, you can delay sysvinit scripts as long as you like18:31
Keybuke.g. until all network interfaces are up18:31
Keybukor until the cows come home18:31
atpa8aKeybuk: i tried removing that IFACE= at all and tried making it IFACE=eth0 but nothing helped18:31
atpa8astill slapd fails to start because the network is not up yet18:32
atpa8astart on filesystem and net-device-up IFACE=eth018:33
atpa8athat's what i have there now18:33
atpa8a slapd[2826]: daemon: bind(9) failed errno=99 (Cannot assign18:35
atpa8a requested address)18:35
Keybukatpa8a: is eth0 the right interface?18:36
Keybukthen it's likely that slapd is in fact waiting for something else18:36
atpa8ayes18:36
atpa8awell18:36
atpa8aslapd needs eth0:0 really18:37
atpa8ashould i try that?18:37
Keybukaha! bridges18:37
atpa8aaliases18:37
Keybukright18:37
Keybukso you need to add something like "and started networking"18:37
Keybuke.g.18:37
atpa8ais there like... IFACE=all?18:37
Keybukstart on filesystem and net-device-up IFACE=lo and started networking18:37
Keybukmeaning filesystem ready, loopback device up, and all virtual devices18:38
Keybukno, because then you'd have to define "all"18:38
atpa8agotcha18:38
atpa8astarted networking should work18:38
Keybuke.g. on a laptop with a USB ethernet device, does "all" mean including that or not?18:38
Keybukand if it means including that, what if it's not plugged in?18:38
atpa8ai see18:38
Keybukyou may want18:39
Keybukstart on filesystem \18:39
Keybuk  and net-device-up IFACE=lo \18:39
Keybuk  and net-device-up IFACE=eth0 \18:39
Keybuk  and started networking18:39
Keybukbecause you'll want eth0 as well as the alises18:39
atpa8acan't i just use 'and started networkin' without net-device-up?..18:40
SpamapSstarted networking just means ifup -a returned18:40
atpa8aok... so that would supercede net-device-up, right?18:40
Keybukno18:40
Keybukthey do different things18:41
SpamapSnope.. ifup just starts the things that configure the ifaces18:41
Keybukphysical network devices, for which you have hardware, are up when you get net-device-up18:41
Keybuknon-physical network devices (virtual, bridges, aliases) are up on the ifup -a18:41
atpa8agot it18:41
atpa8atrying18:42
SpamapSTho it does mean all statically configured devices are up.. right?18:42
atpa8athanks a bunch18:42
atpa8ahmm18:42
KeybukSpamapS: no, because at the point networking runs, the actual devices may not have modules loaded yet ;)18:42
KeybukSpamapS: so you can't guarantee that18:42
atpa8ashould i... just in case add eth1 as well?18:42
Keybukatpa8a: at some point it's worth filing a bug that slapd should use IP_FREEBIND18:42
SpamapSKeybuk: so ifup -a may fork modprobes and such, even for   iface eth0 inet static ?18:42
Keybukbut that's for another day ;)18:42
KeybukSpamapS: ifup doesn't fork modprobes unless you've stuck modprobe in a pre-up ;)18:43
atpa8aKeybuk: thought about just filing a bug with ubuntu to fix rc-sysvinit.conf18:43
Keybukatpa8a: fix?18:43
Keybukatpa8a: this is not considered a bug in Ubuntu18:43
KeybukUbuntu has *never* delayed starting services until after network interfaces are configured18:43
Keybukthis is because the default out-of-the-box behaviour in Ubuntu isn't to configure network interfaces until *user login*18:43
Keybukservices are supposed to work without a configured network interface18:44
SpamapSKeybuk: so started networking should mean all statically configured, non transient hardware, has been configured. yes?18:44
Keybukthus the IP_FREEBIND18:44
KeybukSpamapS: yes18:44
KeybukSpamapS: assuming you have such a thing18:44
atpa8ahmm18:44
SpamapSKeybuk: thinking about servers mostly18:44
SpamapSIs IP_FREEBIND POSIX or a linux innovation?18:45
atpa8aso if my interfaces are all static, 'and started networking' should be enough?18:45
KeybukLinux I believe18:45
Keybukatpa8a: yes18:45
SpamapSI could see it being a problem for some upstreams if its linux only.18:45
Keybukatpa8a: though see notes about modprobe above18:45
KeybukSpamapS: #ifdef is their friend18:45
SpamapSRight, most will be fine w/ that18:46
atpa8aKeybuk: sure, thanks a bunch18:46
SpamapSsome will be adamantly opposed.18:46
atpa8ai've a feeling slapd might be one of those18:46
KeybukSpamapS: if you can find any upstream not using at least one Linux-specific API, I'd be impressed ;-)18:46
Keybukand that's why distros carry patches18:46
Keybukafter all, as soon as you see setsockopt() or ioctl() or anything like that - you're in linux-specific-land18:46
SpamapSKeybuk: I've recently proposed hanging rc-sysinit to start on filesystem and started networking rather than net-device-up IFACE=lo so that users can expect that any static interfaces will always be configured before runlevel 2.... given what we've talked about here.. I think that its still a good idea.18:47
SpamapSs/hanging/changing/18:47
KeybukSpamapS: the trouble there is you run the risk of locking the boot18:47
Keybukbecause people use sysvinit to bring up the dependencies of static interfaces18:47
Keybukin theory though I have no problem with delaying rc-sysinit as long as you like18:48
Keybukbecause things should not be using rc-sysinit18:48
Keybukslapd should have its own .conf etc.18:48
SpamapSHanging it or failing a bunch of stuff.. I'll choose failing a bunch of stuff. But we need a generic solution.18:48
SpamapSKeybuk: its own.conf that will 'start on runlevel [2345]' ? ;)18:49
Keybukwe don't even *have* rc-sysinit on Chromium OS after all ;-)18:49
KeybukSpamapS: I thought you were introducing jobs to replace those? :)18:49
SpamapSI am.. definitely. Haven't gotten much traction on those.18:49
KeybukI always take no traction as silent assent ;18:49
Keybuk;)18:49
SpamapSRight.. my DMB app has been delayed twice unfortunately.18:49
atpa8aupstart scrips for slapd and a few other services are nowhere to be found for ubuntu18:50
SpamapSotherwise I might have uploaded network-services.conf and wait-for-state.conf already. :)18:50
atpa8ai did consider making my own but... i'm not an experienced SA18:50
Keybukatpa8a: bug! :p18:50
atpa8adon't know the intricacies18:50
atpa8aKeybuk: there's a bug already but it's on hold18:50
* atpa8a is java dev18:50
atpa8aSA is a hobby :P18:51
atpa8abb18:52
atpa8atesting the script18:52
Keybukion: you realise that killed my X server and I hate you, right? :-)18:55
ionEh :-D18:56
Keybukflash seems to hate dual-head non-twinview nvidia18:56
wraidenhello, is anyone actively working on /proc/PID/oom_score_adj support? /proc/PID/oom_adj is deprecated and upstarts oom stanza uses this interface...19:00
Keybukwraiden: nobody is actively working on it19:00
wraideni ask because i don't want to do duplicated work on this if anyone has picked the issue up allreda19:00
wraidenk19:00
Keybukso please feel free to pick it up19:00
wraidenk19:01
KeybukI believe both APIs are still supported, right?19:01
wraidenwill take a similar aproach as udev19:01
wraidenyes19:01
Keybuktry and write to oom_score_adj19:01
wraidenbut it polutes dmesg with a warning19:02
Keybukif that fails with EEXIST, fall back to oom_adj ?19:02
wraidenyes19:02
wraidenand no19:02
wraidenudev checks for filepointer lower than 019:02
wraidenso other errorcodes are picked up to19:02
wraideni think19:03
Keybukright, but you also want to check errno19:03
Keybukif you got EPERM from oom_score_adj you shouldn't fall back to oom_adj19:03
wraideni cook something up over the weekend19:03
Keybukbecause you'll just get the same error ;-)19:03
KeybukEEXIST should be the only reason to fallback19:03
Keybukbut please do cook a patch up, and send it to the ML19:03
Keybukgratefully accepted19:03
wraidenaye sir ;)19:04
wraidenthe only thing is that the score interface has grater values19:05
wraidenso the off case must be -100019:05
wraidenthe testsuite tests the values... could be problematic... as it will produce falsepositives on the offbound value checks19:06
Keybukthat is why we have a test suite ;-)19:06
Keybukdecide on appropriate behaviour, write tests for it, etc.19:06
wraidenmhm19:06
atpa8ahello again19:08
atpa8athose changes seem to hange the boot...19:08
atpa8ahang that is19:08
Keybukatpa8a: that implies to me that your network interfaces are (at least, in part) brought up by sysvinit scripts19:08
Keybukso your boot is:19:08
Keybuk - waiting for networking to start sysvinit19:08
Keybuk - unable to start networking because it's waiting for sysvinit19:08
atpa8aok...19:08
Keybukie. deadlock19:08
Keybukso here's your next trick:19:09
Keybukremove the bits you added to rc-sysinit19:09
Keybuknow create a new job19:09
Keybuk/etc/init/slapd-interlock.conf19:09
Keybuk  start on slapd-interlock and net-device-up IFACE=eth1 and started networking19:09
Keybuk(that's it)19:09
Keybukand in /etc/init.d/slapd, in the start case, add19:09
Keybuk  initctl emit slapd-interlock19:09
atpa8ahmm19:10
Keybukyou may need some protection here to make sure it only runs on actual boot, e.g. by checking $RUNLEVEL or some shit - I haven't fiddled with sysvinit scripts in a while to remember what that is19:10
Keybukwhat this will do is:19:10
Keybuk  sysvinit scripts will start as normal19:10
Keybuk  slapd will start19:10
Keybuk  it will run "initctl emit slapd-interlock" and wait for that event to complete19:10
Keybukthe .conf file in Upstart will pick up that event, and block it19:10
Keybukwhile it also waits for net-device-up IFACE=eth0 and started networking19:10
atpa8a(i think) i'm following...19:11
Keybukand then when all three happen, that ".conf" is running, so the event is unblocked, so initctl emit finished, so slapd carries on19:11
atpa8alet me try\19:11
atpa8athanks a bunch19:11
atpa8ahmm19:15
atpa8aseems like i cannot boot into single user mode either...19:16
wraidenkeybuk: is it ok if i change the tests for offbound values in the testsuite to values for the score interface? the will be offbound in booth cases then and we can avoid to check two interfaces with distinct test code...19:20
atpa8alivecd ftw!19:21
Keybukatpa8a: single user mode is a sysvinit thing ;-)19:23
Keybukwraiden: you can change the tests, but be careful to not change the thing they're testing19:23
Keybukcurrent job files should work unchanged19:23
atpa8ahmm20:03
atpa8aKeybuk: would you say... it'd be better to call it networking-interlock.conf?20:03
atpa8akinda a common thing for all services that face the same situation20:04
atpa8aand emit networking-interlock as well?20:04
Keybukyes, but the first job would release the interlock20:04
Keybukthe second would hang20:04
Keybukwhich is why it's specific to slapd20:04
atpa8ai see20:05
atpa8acan it be made generic?..20:05
Keybuknot without converting slapd to upstart20:09
atpa8agotcha20:11
atpa8ahmm20:15
atpa8ajust to confirm... i don't need 'start on filesystem' in slapd-interlock.conf, right?20:15
Keybukright20:17
atpa8athanks20:18
atpa8awhat would happen if i just do /etc/init.d/slapd restart when there's the emit in it?20:22
atpa8anothing happened...20:24
atpa8aok...20:25
atpa8atrying booting now20:25
atpa8ahmm20:31
atpa8asomething didn't work...20:31
atpa8aheh20:33
atpa8atypos :P20:33
atpa8aok20:35
atpa8anow that i fixed it... it's not working when starting manually20:35
atpa8agotta do the emit conditionally...20:35
atpa8a[ $RUNLEVEL ] && initctl emit slapd-interlock20:46
atpa8athat should do it\20:46
atpa8atesting20:46
wraidenmhm, the changed valid range of values for the oom handling isn't easy to handle...20:58
wraidenif i change it do accept 1000 to -1000 in the parser and change it by divide with 59 in the fallback (ugly hack, i know) we could get away wir21:00
wraiden*with a string change for any supported locale...21:00
wraidenanother approach would be to check for the existence of /proc/self/oom_score_adj in init startup code, set a flag according to existence and use that to change behavior accordingly wich would eliminate ugly hacks to adapt the value in fallback case21:04
wraidenbut that would complicate the testcase...21:05
wraidenbtw: isn't EEXIST the error for "i want to crate a file but it exists" and not "file i want to open don't exist" ?21:07
wraidenposix manpage for open (which fopen refers to) defines it as the fist rather than the second...21:08
wraideni'll take the flag oom_score_adj and check for the flag road...21:24
wraiden+existence21:24
atpa8ahmm21:37
atpa8asomething isn't working...21:37
atpa8ahttp://pastie.org/166117421:37
atpa8abut it says initctl status slapd-interlock                            ~21:51
atpa8aslapd-interlock start/running21:51
atpa8ahmm22:09
atpa8afixed it by using 'net-device-up IFACE=eth0:3 \'22:10
atpa8aworking now22:10
atpa8athank you gents22:10
atpa8aKeybuk: thank you much!22:10
Keybukoh cool22:10
wraidenisn't networking enough to check for?22:10
KeybukI didn't even know you could do that :p22:10
atpa8awraiden: apparently not22:11
wraideny?22:11
atpa8ahttp://pastie.org/166117422:11
atpa8athat was before i used IFACE=eth0:3 and it didn't work22:11
wraideny do you add the interface up events?22:12
atpa8ahmm :P Keybuk recommended22:12
wraidenarnt they prerequisites for networking?22:12
atpa8ano22:13
wraidenah22:13
atpa8aif you have a wiki i can drop this solution into, i'll document it22:14
atpa8aputting it in my private wiki now22:14
=== atpa8a_ is now known as atpa8a
atpa8athank you folkes22:44
atpa8avery helpful22:44
wraidenKeybuk: first compiletested only version without messing with the testsuite is here: http://pastie.org/166138622:48
Keybukmy concern about that approach is that it changes the behaviour of Upstart if you reboot into an older kernel22:51
Keybuksuddenly jobs go from running to "parse error"22:51
wraidenyes22:52
wraidenproblem here is that the interfaces arnt compatible with respect to value range ...22:53
Keybukone approach to that would be22:54
wraidena possible way out would be to accept the new range by default and22:54
Keybukoom NN = old range22:54
Keybukoom score NN = new range22:54
wraidendivide the value22:54
Keybukand accept both22:54
Keybukaccepting the new range only would change the behaviour of existing jobs22:54
Keybuk(though I bet there are none out there using the score rather than just "never")22:54
wraidenthat was my thinking eighter...22:55
wraidena percent value would be nice22:57
wraidencould be used as operator to calculate the right value for each interface22:57
wraiden-operator + base22:57
Keybukthat's no real difference than just sticking to the old vange22:58
Keybukrange22:58
Keybukmore fun, "oom less than <other job>" and let upstart pick the values? :P22:58
wraidenthat would by far overwehlm my rusty c skills *hehe*22:59
bigdatahow do I set an environment variable in a job file?23:00
wraidenby reading: man 5 init23:02
wraidensearch foe env23:02
wraiden*for23:02
wraideni'll go for the "oom score =" one i think ...23:04
Keybukwell, no = in upstartyland but I think that makes the most sense23:04
wraidenjepp23:05
wraidenwe need to support both interfaces, as noone upstream boundling conf files for upstart can predict which interface a user might have avaiable...23:06
wraidenthat leads to the question: is any upstream package shipping upstart definitions?23:07
wraidenanyway a nice to have23:09
Keybukwraiden: there are definitely both upstreams and distributions shipping upstart config files23:10
Keybukso they must not be broken23:10
wraidenwhat to do in a case where the new interface is usable  but only the old one has defined value?23:10
Keybukmultiply it by sufficient numbers to turn it into the new value23:10
wraiden+ and the old one is not available (after its removal)23:11
Keybukthe behaviours are the same, just the ranges have changed23:11
wraidenk23:11
Keybuklikewise if you only have new value in the .conf and only the old interface is available, you divide23:11
wraidenwill hack that together...23:11
Keybuk(I'd multiply when parsing the old value so that the oom score in the job is always -1000..1000)23:11
Keybukthen divide again when writing to the old interface23:12
wraidenmhm23:12
KeybukI wonder just how many bugs on LP, at this point, are about pre-stop being fucking busted?23:25
wraidenwhats busted with it?23:27
wraidenthe multiplying and dividing isn't easily possible...23:28
Keybukwhy not easily possible?23:29
Keybukthere's an operator for them in C and everything <g>23:29
wraidenthe values on the old interface are asyncronous reguarding positive and negative values23:29
Keybuknormalise the base, adjust the scale23:29
wraidenyou cant get -1623:29
Keybukmaths 10123:29
Keybuk-16 is "the minimum" and -17 is "never" with +15 being "always"23:30
Keybukso I guess you make +15 be 1000, -17 be -100023:30
wraideni would have used a simple * 62.5 23:30
Keybukoptionally -16 is either -999 or -1000-1000/1723:31
Keybuklook at what the kerneld oes23:31
Keybukie. the code that deals with writing to the deprecated interface23:31
KeybukI'm sure it already has the exact algorithm to scale to the new one23:31
wraidenif (task->signal->oom_adj == OOM_ADJUST_MAX)23:35
wraiden                task->signal->oom_score_adj = OOM_SCORE_ADJ_MAX;23:35
wraiden        else23:36
wraiden                task->signal->oom_score_adj = (oom_adjust * OOM_SCORE_ADJ_MAX) /23:36
wraiden                                                                -OOM_DISABLE;23:36
* wraiden feeds his cats...23:37
bigdatastill trying to get the env setup up, I did read 'man 5 init', but the script being called does not see the PERL5LIB, any ideas http://pastebin.com/VDRdWM3V23:47
Keybukit should23:49
Keybuk(though the "export PERL5LIB" there doesn't do what you think)23:49
Keybukkeybuk /root#    23:51
Keybukkeybuk /root# cat /etc/init/test.conf23:51
Keybukenv DEMO=this:is:a:test23:51
Keybukexec echo $DEMO > /tmp/demo23:51
Keybukkeybuk /root# start test23:51
Keybuktest start/running, process 1350723:51
Keybukkeybuk /root# cat /tmp/demo23:51
Keybukthis:is:a:test23:51
wraidenhow about adding a oom_score_adj int to job_class so that we only need to calculate in the conf parsing case and just use what we have calculated?23:54
Keybukthat's what I meant23:54
bigdatayour right, it did work23:59

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