/srv/irclogs.ubuntu.com/2007/02/23/#upstart.txt

=== j_ack [n=rudi@p508D8205.dip0.t-ipconnect.de] has joined #upstart
=== Amaranth [n=travis@ubuntu/member/Amaranth] has joined #upstart
=== int0x0c [n=ben@161.253.47.133] has joined #upstart
=== int0x0c [n=ben@161.253.47.133] has joined #upstart
=== space-m0nkey [n=chatzill@client-82-3-73-143.manc.adsl.virgin.net] has joined #upstart
=== maro [n=mark@0x55511dab.adsl.cybercity.dk] has joined #upstart
=== Md [i=md@freenode/staff/md] has joined #upstart
=== Md [i=md@freenode/staff/md] has joined #upstart
=== __keybuk [n=scott@wing-commander.netsplit.com] has joined #upstart
__keybukcomplex-event-config is complex :-/03:24
AlexExtreme:/03:25
__keybukfor example:03:25
__keybukon starting apache until stopped apache and starting dbus until stopped dbus03:25
__keybukdo we stop apache from starting until dbus is starting? :p03:26
AlexExtremehmmm03:27
AlexExtremegood point03:28
AlexExtremethat would be the only way to do it03:28
AlexExtremeas far as I can see03:29
AlexExtremebecause otherwise if you let one of them start, it wouldn't satisfy the starting part03:29
__keybukso if dbus never starts, neither would apache?03:30
AlexExtremeyes03:30
AlexExtremebut that's a bit stupid03:30
AlexExtremebecause it introduces an unnecessary dependency on dbus for apache03:31
__keybukindeed03:32
AStormProper way would be to rewrite it into:03:53
AStormon starting apache and starting dbus03:54
AStormstop on stopped apache and stopped dbus03:54
AStorms/stopped/stopping/03:54
AlexExtremeno03:54
AlexExtremethat's one of the points of complex-event-config, to have until :)03:55
AStormuntil is the same :P03:55
__keybukno it's not03:55
__keybukuntil pairs the events, where that doesn't03:55
AStorm"pairs"03:55
AStormExplain what you mean by that :-)03:55
__keybukon foo until bar or frodo until bilbo03:56
__keybukfoo happens. frodo happens03:56
__keybukboth are TRUE03:56
__keybukbar happens, that only cancels the foo03:56
__keybukthe right side is still true, so the job is still running03:56
__keybukon (foo or bar) until (frodo or bilbo)03:57
__keybuk(or start on (foo or bar) ... stop on (frodo or bilbo))03:57
AStormShouldn't and do the same with "stop on x stopped and y stopped"?03:57
__keybukfoo or bar happens, job is running03:57
__keybukerr,03:57
AStormOr is that one-shot?03:57
__keybukfoo or frodo happens, job is running03:57
__keybukbar happens, job would be stopped whichever of the two happened03:57
__keybukusing a real example:03:58
AStormThe "and" would group the events, but disregard ordering?03:58
__keybukon started gdm until stopping gdm and started kdm until stopping kdm03:58
__keybukgdm starts and kdm starts, job is running03:58
__keybuknow let's say kdm stops, the job stops again because kdm is no longer running03:58
__keybukso far, that *is* equivalent to just using and03:59
__keybukexcept say kdm starts again03:59
AStormAh, so it's like I thought.03:59
AStorm"and" is one-shot.03:59
__keybukI don't understand "one-shot"03:59
AStormThat means, the flag is read only once, because it isn't linked with the starting event.03:59
__keybukflag?04:00
AStormSo, when stopped fires, the next started doesn't reset it.04:00
__keybukI still don't follow, sorry04:00
__keybukcould you use an example to illustrate?04:00
AStormon x started and y started04:01
AStormstop on x stopping and y stopping04:01
AStormThis would mean:04:01
AStormI start x and y04:01
AStormthen stop y04:01
AStormthen start y again04:01
AStormthen stop x, the job is stopped.04:01
__keybukright04:01
AStormWhile with "until" that wouldn't happen.04:01
__keybukno, that'd happen with until too04:02
AStormHmm.04:02
__keybukthe point about "until" vs. "and" is that if you stop y then stop x, then start x again -- the job would be running if "and" is used, but not running if "until" is used04:02
__keybukcompare:04:02
__keybukx started = FALSE, y started = FALSE04:02
__keybukx stopping = FALSE, y stopping = FALSE04:02
__keybukstart x, x started = TRUE04:02
AStormAha, now I get it.04:02
__keybukstart y, y started = TRUE04:02
__keybukso the and is TRUE, so the job starts04:03
__keybukstop y, y stopping = TRUE04:03
__keybukthe and is FALSE, so the job stops04:03
AStormBecause the "x started" has already been set.04:03
AStormYes.04:03
__keybukstop x, x stopping = TRUE04:03
__keybukthe and is still FALSE, so the job is still stopped04:03
__keybukstart x, x started = TRUE04:03
__keybuknothing has "reset" the y started = TRUE, so the and is still TRUE, so the job starts again04:03
__keybukthe point about "until" is that it is a reset04:04
AStormWhile until  resets the condition when the last one happens. So both would have to be started again, if both have been stopped.04:04
__keybukwhen the expression on the right side becomes TRUE, it explicitly resets the values on the left to FALSE04:04
__keybukright04:04
__keybukthat's why we invented the complex thing04:06
__keybukwe'd originally tried to just do it with adding and/or to start on/stop on04:06
AStormHmm...04:09
AStormHow would one do then failover services, which would be something like:04:10
AStorm-start when any of foo, bar started04:11
AStorm-stop when both of foo, bar stopped04:11
AStorm(stopped means not running, not "stopped" event)04:12
__keybukerr?04:12
__keybukthat's what the stopped event means04:12
AStormYou know, when you stop task, it sends that stopped event.04:12
AlexExtremeAStorm, that's what the state machine is for04:13
AlexExtremeit will be in the stopped state04:13
AStormBut it won't send one, when it hasn't ever been ran.04:13
AStormAha, great.04:13
AlexExtremeat least04:13
AlexExtremeI think so :)04:13
__keybukthat's true, you don't have an event if it's never been run at least once04:13
AlexExtremehmm04:14
__keybukwe had "with" for that04:14
__keybukon not (with foo or with bar)04:14
AlexExtremeso if it hasn't been run then using stopped won't do anything?04:14
__keybukAlexExtreme: if you don't run a job, you don't get events for it ;p04:14
__keybukthere's no "stopped foo" event just because it exists04:14
AStormIt won't fire, if you mean that.04:14
AlexExtremetrue :p04:14
AlexExtremeso you can't use 'on' based on something's state?04:14
AStorm"on" won't reset.04:15
AlexExtremeor whatever ;)04:15
__keybukAlexExtreme: dunno yet, "on" is still being defined04:16
AStormwith would work best.04:16
AlexExtremek04:16
AStormWhat would happen then, if:04:16
AStormon not (with foo or with bar)04:16
AStormfoo gets started04:17
AStormbar gets started04:17
AStormfoo gets stopped?04:17
AStormStill running or not?04:17
__keybukwith bar is true, so the on is false04:17
__keybukso not running04:17
AStormHmm, not what I would like to :>04:18
__keybukuse "and" then04:18
__keybukon not (with foo and with bar)04:18
AStormI figured that out...04:18
__keybuknow running when either foo or bar or both are not running04:18
AStormBut then, both foo and bar have  to be started?04:18
AStormAh, either? Really?04:18
__keybukyes, not ... and04:18
AStormThis "and" is nonintuitive :D04:19
__keybukerr, why?04:19
__keybukit's boolean04:19
AStormActually... yep, it's alright.04:19
AStormWe invert it, so we get a "nand"04:19
__keybukwith doesn't combine well with until though04:19
__keybukwhich is why I haven't coded it yet04:20
__keybukand also acts strangelty04:20
AStorm:|04:20
AStormWhat would: on (with foo or with bar) mean?04:23
AStormEither one of them, but stop if any of them is stopped?04:23
AStormOr stop if both are stopped?04:24
__keybukrunning when either one of them is running04:24
__keybukstopped only if both are stopped04:24
AStormwith counts as stopped if it isn't running, right?04:24
__keybukright04:25
__keybukI'm increasingly thinking that complex-event-config is wrong04:25
__keybukit's cute, but doesn't fit in with existing behaviours04:25
AStormwith sounds like a "need" dependency04:26
AStormalmost exactly.04:26
__keybukwhat are the different deps?04:27
AStormOk: use and need04:27
AStormThere are 2 special orderings: before and after04:28
AStorm(which map directly to "on")04:28
AStormWell, before doesn't actually.04:29
AStormIt works like a "pre-start", but isn't tightly bound to the job.04:29
AStormafter x == on x started04:30
AStormneed x == with x04:31
AStormuse x is special. Like a conditional after.04:31
AStormWrong. Like a conditional need.04:32
__keybukuse only applies if the job exists?04:33
__keybukwhereas need always applies, so if the job doesn't exist, it isn't started?04:33
AStormYes, if it's "added" to the "runlevel"04:33
AStormDoesn't map directly to events.04:33
AStorm__keybuk, yes.04:33
AStormOr, when it's started, it pulls these as dependencies04:33
AStormSo, it would be like: foo has "need bar"04:34
AStormif foo is started, bar is pulled in04:34
AStormif foo is stopped, bar is removed (or not, in case of Gentoo init - but that's a misfeature)04:34
AStorm(should be removed when nothing else "needs" it)04:34
AStormwhen bar is stopped, foo is stopped too.04:35
=== int0x0c [n=ben@161.253.47.141] has joined #upstart
AStormIt probably is possible to emulate using events alone, but isn't easy.04:36
__keybukhow about with states?04:37
__keybukcould you define them using states?04:37
AStormHmm. there would be 4 conditions:04:37
AStormfoo is started -> bar is started04:37
AStormfoo is stopped -> nothing needs bar -> bar is stopped04:38
AStormfoo is stopped -> something needs bar -> nop04:38
AStormfoo is started -> bar is started -> bar is stopped -> everything needing bar is stopped04:38
AStorm(including foo)04:38
AStormThis would be hard to implement nicely with autoresurrecting services.04:39
AStormIt would mean, when bar is restarted, restart everything needing it04:40
__keybukthat works with the events at the moment04:41
__keybuksince a job that's respawned emits stopping, starting, started04:41
AStormYes.04:42
AStormBut the hardest part is "something needs bar -> nop"04:42
__keybukwhy would it nop?04:42
AStormBecause something else besides foo requires it.04:43
AStormso in this case, stopping foo shouldn't stop bar04:43
AStormwhile when only foo needs bar, bar should be stopped04:43
AStormWould require another event, let's say "lastneed"04:43
AStormor rather "noneed"04:44
AStormA simplel integer counter :P04:44
AStormbar noneed would be fired if it reaches zero04:44
AStormdecreased when something needing bar is stopped04:45
AStormincreased when something needing bar is started04:45
AStormUsually it's implemented using a stack and not events.04:48
AStorms/stack/array/04:48
AlexExtreme__keybuk, in the replacement-initscripts branch, what is getmntent for?05:03
__keybukAlexExtreme: parsing /etc/fstab and /etc/mtab properly05:04
__keybukand not using grep or $IFS05:04
__keybukwhich are both broken if you want spaces in your mount points :p05:05
AlexExtremeah05:05
AlexExtremek :)05:05
AlexExtremegonna hack them a bit05:05
__keybukwing-commander scott% sudo getmntent -f /dev/hda105:05
__keybukUUID=68210f07-2d06-416e-9db5-15db2b3e6b70 / ext3 defaults,errors=remount-ro 0 105:05
__keybuk"where should /dev/hda1 be mounted?" ... note UUID lookup05:05
__keybukwing-commander scott% sudo getmntent -md /05:06
__keybuk/dev/hda1 / ext3 rw,errors=remount-ro 0 005:06
__keybuk"what's mounted on /"05:06
__keybuketc.05:06
AlexExtremek05:06
AlexExtremethanks05:06
_ionYou can also get the value of a specific field.05:06
__keybukI also intend to add an option to output FOO=... fields for use with udev05:11
__keybukso you could do SUBSYSTEM=="block", ACTION=="add", IMPORT{program}="/sbin/getmntent -f %k"05:12
__keybukthen ENV{FSTAB_DIR}=="?*", RUN+="/sbin/initctl emit fstab-device-added %k"05:12
__keybuketc.05:12
AlexExtremeyes05:12
__keybukand then, more usefully05:13
__keybukSUBSYSTEM=="block", ACTION=="remove", ENV{FSTAB_DIR}=="?*", RUN+="/sbin/initctl emit fstab-device-removed %k"05:13
__keybuk:p05:13
__keybuksince you can't do a UUID lookup on a removed device05:13
_ionNeat.05:13
=== j_ack [n=rudi@p508DAAE9.dip0.t-ipconnect.de] has joined #upstart
=== __keybuk is wondering whether "until" is unnecessary
__keybuk  start on starting foo05:29
__keybuk  stop on stopped foo05:29
__keybukis equivalent to05:29
__keybuk  on starting foo until stopped foo05:29
AlexExtremehmm05:30
AlexExtremeall it does then is shortens things?05:30
__keybukcomplicates things05:31
__keybukthinking about whether it's better to make states a first-class thing, rather than something that can be defined with until05:32
__keybukso05:35
__keybukI tend to believe that if something is difficult to explain, or if something behaves in strange ways, then there's a problem with that something05:36
__keybukon/until is proving difficult to explain and behaving in strange ways05:36
__keybukwhich is starkly different from start on/stop on which behave simply05:36
__keybukvague thought05:38
__keybukstart on EVENTEXPR05:38
__keybukstop on EVENTEXPR05:38
__keybukEVENTEXPR := EVENT | EVENT 'and' EVENT | EVENT 'or' EVENT | 'not' EVENTEXPR05:38
AlexExtremehmm05:39
__keybukthat's not that difficult05:39
__keybukstart on foo or bar05:39
__keybukstop on foo and bar05:39
AlexExtremethat looks easy enough05:39
__keybukthen add05:40
__keybukwhen STATEEXPR05:41
__keybukSTATEEXPR := STATE | STATE 'and' STATE | STATE 'or' STATE | 'not' STATEEXPR05:41
__keybukwhere a STATE is just the name of a job05:41
AlexExtremefollowed by an actual state such as started or stopped?05:42
__keybukno just the name of a job05:42
__keybukso just use job files instead of until05:42
__keybuknot sure that solves the issue though05:43
AlexExtremehmm05:44
AlexExtremeso STATE would be true if it is started?05:44
AlexExtremeand false if stopped?05:44
__keybukright05:45
AlexExtremeok05:46
_ionThat syntax doesn't look bad.05:46
AlexExtremeyeah05:46
__keybukfor the networking and filesystem case, you'd need:05:51
__keybukan /etc/event.d/networking file containing05:52
__keybuk  start on network-up05:52
__keybuk  stop on network-down05:52
__keybukan /etc/event.d/filesystem file containing05:52
__keybuk  start on filesystem-mounted05:52
__keybuk  stop on filesystem-unmounted05:52
__keybukand then any file would have05:52
__keybuk  when networking and filesystem05:52
AlexExtremeyes05:54
__keybukdoesn't solve all of the problems though, I don't think05:55
AStorm__keybuk, for the fsck, in order to get the device ID, use udevinfo --name=<partition> --query=env | grep ID_PATH05:58
AlexExtreme<AlexExtreme> __keybuk, in the replacement-initscripts branch, what is getmntent for?05:59
AlexExtreme<__keybuk> AlexExtreme: parsing /etc/fstab and /etc/mtab properly05:59
AlexExtreme<__keybuk> and not using grep or $IFS05:59
AlexExtreme<__keybuk> which are both broken if you want spaces in your mount points :p05:59
AlexExtremenote the grep part ;)05:59
__keybukAStorm: udev is not a database :P06:01
=== Amaranth [n=travis@ubuntu/member/Amaranth] has joined #upstart
AStorm__keybuk, udev knows the device ID.06:22
AStormgetmntent doesn't know which device you're scanning :P06:22
AStormSo, you would mount many things from one device at once. (unless watershed is powerful enough to avoid that)06:23
AStorm/dev/sda1 and /dev/mapper/wtf may be on the same device.06:23
AStormUdev knows about these, so does sysfs06:23
AlexExtremeas far as I can tell getmntent also knows about that06:24
AStormNot the device part.06:24
AlexExtremeit uses libvolume_id from udev06:24
AStormSo it doesn't tell you the data. :>06:25
AStormtry it on some DM or RAID volume.06:25
AStormudevinfo also doesn't tell everything :/06:25
AStormls-ing /sys/block/.../slaves tells more06:25
AStormor ls-ing /sys/block/.../holders instead06:26
AStormBut how to resolve /dev/mapper/wtf to dm-0?06:26
AStormBlah@me06:27
AStormdmsetup table...06:27
AStorm(but that requires cut use)06:27
=== AStorm [n=astralst@chello084010114027.chello.pl] has left #upstart ["Bye"]
=== AStorm [n=astralst@chello084010114027.chello.pl] has joined #upstart
__keybukAStorm: devmap_name06:51
__keybuk(on Ubuntu)06:51
AStorm       Invoking the command as devmap_name is equivalent to06:52
AStorm       dmsetup info -c --noheadings -j major -m minor.06:52
AStormBlah, I'd have to know the minor and major number06:52
__keybukthat's easy06:52
__keybuk$MAJOR and $MINOR in the uevent06:54
=== phsdv [n=paul@dyn-83-152-239-123.ppp.tiscali.fr] has joined #upstart
=== Md [i=md@freenode/staff/md] has joined #upstart
phsdvHi, I made an upstart script to fsck all file systems on a certrain blockdevice. It checks /etc/fstab with getmntent for filesystem on this block device08:20
phsdvyou can find the script here: http://upstart.pauldevries.homelinux.com/wp-content/uploads/fs-check.txt08:20
=== AlexExtreme looks
phsdvIt does not check the root partition, that will be dealt with seperately08:22
AlexExtremeyess08:22
AlexExtreme*yes08:23
AlexExtremeemit fs-checked $partition << shouldn't that be 'initctl emit fs-checked $partition' ?08:23
phsdvyes, I made a link08:23
AlexExtremeab08:23
AlexExtreme*ah08:23
AlexExtremeok08:23
phsdvIn this way you only have one fsck per block device at a time.08:24
phsdvand you can have multiple block devices checked in paralel08:24
phsdvit probably does not handle yet names with spaces in there. But adding some "" should help out there08:25
phsdvthe script to fsck the rout partiton you can find here: http://upstart.pauldevries.homelinux.com/wp-content/uploads/fs-check-root.txt08:28
phsdvI still need to get rid of the sleep statement though :(08:28
AlexExtremeok08:29
phsdvIf I do not wait, I get errors...08:29
AlexExtremei'll look at it later, i need to go now :)08:29
phsdvok08:29
_ionIt doesn't take LVM, RAID etc. into account.08:32
_ionOr fsck returning a non-zero value.08:33
phsdvno, not yet08:33
phsdvbut I do not have experience with LVM and RAID08:33
=== juergbi [n=juerg@80-219-17-102.dclient.hispeed.ch] has joined #upstart
=== pornflake [n=garret@Ta56c.t.pppool.de] has joined #upstart

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