/srv/irclogs.ubuntu.com/2012/01/25/#upstart.txt

glenn___spamaps: ive been trying out all the options, expect fork, expect daemon, expect stop... even tried no expect09:38
jodhglenn___: you need to know how many times the app forks initially before it is ready to start its real work (in other words its initialisation phase).09:39
glenn___jodh: i tried the count on fork/clones... it is about 2209:41
glenn___but the strace is showing clones, not forks09:41
jodhglenn___: the maximum any process needs to fork is twice before it is fully initialized.09:42
glenn___jodh: so the guys cant code at puppetlabs? :)09:42
jodhglenn___: any further forks are for setting up "helpers". You don't care about those though - you need the pid of the master parent process before it does its fork bomb.09:42
glenn___jodh: the master process is about 22 pids later09:43
jodhglenn___: it can't be.09:43
glenn___ill show you09:43
glenn___root@puppetclient:/etc/init# start puppet09:46
glenn___puppet start/running, process 114209:46
glenn___root@puppetclient:/etc/init# ps auxf |grep puppet09:46
glenn___root      1167  0.0  0.0   9744   876 pts/0    S+   10:46   0:00          \_ grep --color=auto puppet09:46
glenn___root      1163  7.0  3.9 122540 40488 ?        Ssl  10:46   0:00 /usr/bin/ruby1.8 /usr/bin/puppet agent09:46
glenn___root@puppetclient:/etc/init# 09:46
glenn___i can use the init script to shut it down, not with upstart09:47
glenn___init script is using the pid file09:48
glenn___root@puppetclient:/etc/init# grep clone /tmp/strace.log | wc -l 09:49
glenn___2409:49
glenn___1217  clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f6ee51809f0) = 121809:50
glenn___etc etc09:51
glenn___1217  clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f6ee51809f0) = 123809:51
glenn___it behave the same for version 0.25 2.6 and 2.709:51
glenn___the expect options go to a max of 2, i think with daemon09:52
glenn___so either upstart isnt the right tool, their daemon is weird, or i just dont get it09:53
glenn___ive been trying for at least an hour :)09:53
glenn___fyi, the daemon is just a ruby script, starting puppet from ruby09:59
glenn___i suppose thats causing the problem10:00
jodhglenn___: as stated, there is no reason to fork more than twice (that's why upstart only tracks up to 2 forks). I think you should talk to the puppet guys to understand what is going on there. For now, you might need to consider using start-stop-daemon with upstart: http://upstart.ubuntu.com/cookbook/#alternative-method10:08
glenn___jodh: i think i picked the wrong software to test upstart :)10:10
jodhglenn___: this isn't a problem with upstart - it's either ruby and/or puppet.10:11
glenn___jodh: hence my point :) i picked the wrong software <- puppet10:11
jodhglenn___: are you using "respawn" by any chance?10:14
glenn___jodh: if i use any expect it all start will hang10:15
glenn___s/it/at10:15
jodhglenn___: but are you using "respawn"?10:15
glenn___jodh: nope10:15
glenn___that started the process several times10:16
glenn___:)10:16
glenn___jodh: sorry i misread i thought u said expect instead of respawn10:16
jodhglenn___: ok. please keep us posted on this as we need to understand exactly what is going on here.10:17
glenn___jodh: im trying to get it to work with start-stop-daemon first, then ill try the puppetlabs guys10:17
glenn___which doesnt work at all :(10:19
glenn___exec start-stop-daemon --start --exec /usr/bin/puppet agent10:19
glenn___i did a reboot though, now its starting10:23
glenn___still the same issue though, seems to make no difference10:23
jodhglenn___: what problem? why are you rebooting? I'd get puppet working with start-stop-daemon on the command-line first, then put that into an upstart .conf file.10:25
glenn___jodh: it is working on the commandline10:25
glenn___jodh: i tried start puppet, it hangs, i reboot, i start it again and it works10:25
glenn___jodh: i tried several reboots :) the upstart wass messed up10:26
glenn___sometimes it even keeps track of the pid while that id is not even there anymore10:26
jodhglenn___: that's telling you your .conf file is incorrect - upstart just does what you tell it to :)10:27
glenn___there is just a few lines10:27
glenn___to be exact 410:27
glenn___description     "puppet client"10:28
glenn___start on filesystem or runlevel [2345]10:28
glenn___stop on runlevel [!2345]10:28
glenn___exec start-stop-daemon --start --exec /usr/bin/puppet agent10:28
glenn___also when i try stop, it says unknown instance, which would mean the job is not running, while it is... 10:31
glenn___need more spresso10:31
jodhglenn___: your 'start on' is incorrect - that will try to start *two* instances of the job (which will fail).10:32
jodhglenn___: make it 'start on runlevel [2345]'10:32
glenn___same behaviour10:35
glenn___i dont think this will work with upstart :(10:37
glenn___for now10:37
glenn___i have an idea perhaps it will help 10:43
=== glenn___ is now known as glenn
jodhglenn___: glenn: 'exec start-stop-daemon --start --exec /usr/bin/ruby /tmp/fork.rb' works as expected for me.11:05
glennjodh: thanks for checking11:07
glennjodh: it just does 1 fork i suppose?11:07
glennjodh: could show me the contents of that ruby file11:19
jodhglenn: http://paste.ubuntu.com/816328/11:20
glennjodh: yup seems to work correct11:23
glennjodh: when i include their code in the fork.rb script it forks 21 times11:50
jodhglenn: maybe you should raise a bug on that - sounds broken.11:51
glennthis is kind of nice12:17
glennthere is a flag called --no-daemonize, with that it works as expected12:18
jodhglenn: great. please raise the issue with the puppet folk though as it sounds like there is a bug in there.12:20
glennim staring at their ruby code for half an hour now :) maybe ur right12:20
glenninteresting material though12:27
glennthey are using Process.detach12:28
glennlol :)12:30
glennjodh: jodh: im pretty sure its something weird in their code13:20
glennhttp://paste.ubuntu.com/816410/ http://paste.ubuntu.com/816411/13:22
jodh'music13:23
jodhoops :)13:23
glennmusic? :)13:23
glennjodh: i appreciate ur help btw 13:23
jodhignore - tmux window searching :)13:23
glennlearning a lot regarding upstart13:23
glennshould just use spottify :)13:23
jodhglenn: glad your'e making progress. afk for a while ...13:24
glennjodh: im filing a bug at puppetlabs right now after discussing it with someone in their irc-channel15:03
jodhglenn: great news!15:09
glennjodh: Yup :)15:10
glennjodh: im not exactly sure what to file but hey :P15:10
glennits something with redmine facter within puppet15:10
glennits doing system calls to which, ifconfig, hostname things like that15:10
glennthat seems to spawn the forks15:11
glennwhich seems correct because in the strace there is exec's to that15:11
glennjodh: and i probably have a workaround for now to upstart15:12
glennwoot :)15:14
glennroot@puppetclient:~# start puppet15:14
glennpuppet start/running, process 180615:14
glennroot@puppetclient:~# stop puppet15:14
glennpuppet stop/waiting15:14
glennnice15:14
glenn:)_15:14
glennjodh: for my understanding, if software is daemonized, this should take no more then 2 forks?15:47
jodhglenn: there is no additional benefit to forking more than twice.15:47
glennjodh: could you explain that a bit more15:47
jodhglenn: not right now (in a meeting). it's standard unix/linux semantics though.15:48
SpamapS_glenn: I'm curious what your workaround was16:35
glennspamaps: ah :) ill paste my script16:36
glennspamaps: im kind of confused still, regarding the max of 2 forks in upstart16:36
=== SpamapS_ is now known as SpamapS
glennspamaps: im using the --no-daemonize function for puppet 16:36
SpamapSglenn: puppet may be an example of something that reasonably *does* fork twice before daemonization for legitimate reasons.. I think this may be worth a bug report in upstart16:37
SpamapSWhy shouldn't a program be able to exec stuff before it daemonizes itself?16:37
glennspamaps; thats the same disucssion i had with our developers16:37
SpamapSjodh: ^^ Perhaps 'expect exit' will fix this?16:38
glennspamaps: maybe it should track only forks of itself, instead of all other calls16:38
glennspamaps: upstart seems to track all pid's instead of just the forking of the daemon itself16:38
SpamapSglenn: well its trying to figure out what the "main" pid is16:39
glennspamaps: i understand16:39
SpamapSThe method it uses works for most regular daemons.16:39
glennspamaps: but in the puppet case, it does about 20 system calls, and then it has all the information for starting the daemon (dont ask me why)16:40
SpamapSglenn: I think I understand why.. and this is an example of where expect fork is just incapable of doing it right16:40
SpamapSSo --no-daemonize is the only other option.. though then you have the trouble of needing to write a post-start which determines when the daemon is actually ready16:41
glennits working properly already16:42
glennwhen puppet is not daemonized it will run in the foreground, and thus not doing forks to system calls16:42
glennor however i should pronounche this :)16:42
SpamapSglenn: perhaps puppet should add a --upstart mode where it sends itself SIGSTOP when it is ready (upstart will SIGCONT it)16:42
SpamapSglenn: then you could use 'expect stop'16:42
glennspamaps: yeah that would be a solution16:42
SpamapSglenn: you're saying system calls, but what you mean is it is forking and execing system programs, I assume16:43
glennspamaps: i think so yes :)16:43
glennspamaps: correct me if im wrong, this is kind of new genre too me16:43
glennthe paste right16:43
SpamapSglenn: that should be valid and expected behavior for lots of daemons, not just puppet.16:44
glennspamaps: but its not really nice of upstart to say: build in an upstart function :)16:45
glennelse we dont support you16:45
glennthe problem exists because upstart wants to track the pid itself16:46
glennmy mind is boggling16:46
glennhttp://paste.ubuntu.com/816657/16:50
glennthere this is one works16:50
SpamapSglenn: well its more of upstart saying "help us determine your pid"16:50
glennspamaps: puppet creates a pid file already16:50
glennspamaps: why would upstart need to find it again? :)16:50
SpamapSglenn: IMO, upstart should have the ability to use pidfiles, but Keybuk is (was?) convinced that pidfiles are too unreliable.16:50
glennspamaps: upstart is more unreliable16:51
glenn:)16:51
SpamapSNot sure I agree with that16:51
glennspamaps: concerning starting software16:51
SpamapSbut I can see how it might feel that way given the difficulty in writing jobs16:51
glenni was reading the cookbook16:51
glennit seems really awesome16:51
glenna new init16:51
SpamapSglenn: upstart is actually quite reliable.. its just that it reliably does weird things. :)16:51
glennits fast, parallel et16:51
glennbut the pid tracking, is really weird16:52
glenni did some reboots, and even 2 reinstalls (through auto deployment)16:52
glennit was tracking pid's that didnt exist16:52
SpamapSusing ptrace the way it does is the only thing I don't like16:52
glenneven restarting upstart didnt help16:52
SpamapSglenn: the tracking pids that don't exist thing is a known bug16:52
SpamapSglenn: happens whenever you use expect fork on something that doesn't fork16:53
SpamapSglenn: or.. something like that, I forget. Anyway, there's a workaround that doesn't require a reboot.. but it does require you to exhaust pid space and roll-over16:53
SpamapSglenn: anyway, the --no-daemonize option is still the simplest. But again, if you have other things that might depend on it running.. you need to have a post-start that verifies it is ready to serve their requests.16:54
SpamapSalso the --no-daemonize thing fails on programs that fork/exec/exit on SIGHUP .. which I just figured out python-paste does.16:54
glennspamaps: ah ok, i tried the expect option, that probably created the issue16:56
glennspamaps: spamaps: --no-daemonize is a flag specific for puppet17:01
SpamapSglenn: right, its pretty common for daemons to have a "stay in the foreground" flag tho17:03
glennspamaps: still, the pid tracking seems a bit strange17:10
glennspamaps: i can imagine a lot of software does exec system programs before it starts17:11
glenn+ as daemon17:11
SpamapSglenn: when daemons behave the way upstart expects them to, its quite nice. But I estimate thats only about 50% of daemons that I've tried to write jobs for17:11
glennspamaps: well if upstart wants to be ground breaking, either a pid file support should be available, or software developers need to code in sigstop 17:12
glennspamaps: i dont think there is a common practice for this when developing software 17:12
glennspamaps: the only thing i could think of is that there should be a pid file 17:13
glennspamaps: which there is, but upstart wont support it17:13
glennspamaps: also, software like puppet is supported on redhat and not on ubuntu17:14
SpamapSglenn: thats just crazy talk. puppet is very well supported on Ubuntu17:14
SpamapSglenn: upstart's pid tracking is not necessary to use services.17:14
SpamapSglenn: you can have an upstart job with no pid, that just tracks whether or not the boot/shutdown thinks it should be started/stopped17:15
glennspamaps: the enterprise version is indeed supporting ubuntu now, sorry for that17:15
SpamapSand puppet is in main17:16
SpamapSso it is supported by Canonical17:16
glennspamaps: i had the newer puppet backported to lucid17:16
glennfrom onerice17:16
glenn-e17:16
SpamapSI think we (Ubuntu) should backport more stuff to LTS's17:16
glennspamaps: i had some great help from people at ubuntu getting this to work17:17
glenntook about 1 month i guess17:17
glennnow 2.7.1 is in lucid backports17:17
SpamapSglenn: thank you for working on backports then!!17:17
glennlol np17:17
SpamapSI hope to have some official Canonical resources working on backports going forward17:17
SpamapSat least, for server17:17
glennthat would be nice17:19
glenni did some cool stuff to debian preseed too :)17:19
glennbut that was just on my side, not on the preseed package17:19
trondmcan an upstart job tell the difference between a restart and stop? i.e. can I make my job do something else than a simple stop/start during a restart?17:39
SpamapStrondm: no17:41
SpamapStrondm: restart simply changes the goal to stop, then back to start17:42
SpamapStrondm: its a dangerously misunderstood command.. it does not re-load the upstart job.17:42
trondmAh. Too bad. 17:42
trondmIn my case, I have a parent job than spawns several instances. I'd like each instance to be restarted separately when the parent is restarted, instead of having them all be stopped, then started17:43
glenntrondm: it sounds the same, restart them all, or stop them all and start them all17:44
trondmIt's not a huge problem, though (and this is the way it worked before I started using upstart)17:45
trondm(I was just hoping it would be possible to improve on the current state)17:47
glenntrondm: is there is difference when you restart your instance or stop/start your instance?17:48
trondmglenn: there's a difference between stop/start 0; stop/start 1; stop/start 2; and stop 0 1 2; start 0 1 2. Basically I'm offline for a shorter period if everything stops, then starts. 17:49
glennas far as i knew restart == stop -> start17:49
glennoh ic17:49
glennmaybe you can create several jobs?17:49
glennor would that do the same17:50
trondmI think that would do the same. Part of the problem is that the parent is an instance itself, and it's not possible to use variables in the "stop on" stanza. So I have a "post-stop" script in the parent that stops all child-instances17:54
glennhey spamaps you know what would be nice17:58
glennthe documentation regarding expect doesnt mention what to do if there is more then 2 pid forks17:59
glenni.e. you should change the software, or use sigstop18:01
glennjodh: spamaps: http://projects.puppetlabs.com/issues/1214618:09
glenni just made this issue18:09
glennhopefully it makes sense 18:09
glennthanks a bunch again for your support/help really appreciate it18:20
glennim off, gonna play starcraft 218:20
glennyo18:20

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