From 39a9ed4faa642ddbd4b3fae1c2bd409efd29441d Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Tue, 7 Sep 2021 14:37:36 +1000 Subject: [PATCH] hood: fix update ordering When we receive the %mere gift from clay, the kernel has not yet been reloaded. This means any attempts to bump desks will fail, as they will be bumped against the old kernel. Rectifies this by continuing the %base desk update flow in +on-load, instead of +take-merge-main. Also adds a wef=(unit weft) to the state in order to discriminate whether or not the kernel has just been reloaded --- pkg/arvo/app/hood.hoon | 5 +-- pkg/arvo/lib/hood/kiln.hoon | 64 ++++++++++++++++++++++++++++++------- pkg/base-dev/sur/hood.hoon | 10 +++--- 3 files changed, 61 insertions(+), 18 deletions(-) diff --git a/pkg/arvo/app/hood.hoon b/pkg/arvo/app/hood.hoon index 326f64fbd..92aac0def 100644 --- a/pkg/arvo/app/hood.hoon +++ b/pkg/arvo/app/hood.hoon @@ -2,8 +2,8 @@ /+ drum=hood-drum, helm=hood-helm, kiln=hood-kiln |% +$ state - $~ [%18 *state:drum *state:helm *state:kiln] - $>(%18 any-state) + $~ [%19 *state:drum *state:helm *state:kiln] + $>(%19 any-state) :: +$ any-state $% [ver=?(%1 %2 %3 %4 %5 %6) lac=(map @tas fin-any-state)] @@ -19,6 +19,7 @@ [%16 drum=state-4:drum helm=state:helm kiln=state-3:kiln] [%17 drum=state-4:drum helm=state:helm kiln=state-4:kiln] [%18 drum=state-4:drum helm=state:helm kiln=state-5:kiln] + [%19 drum=state-4:drum helm=state:helm kiln=state-6:kiln] == +$ any-state-tuple $: drum=any-state:drum diff --git a/pkg/arvo/lib/hood/kiln.hoon b/pkg/arvo/lib/hood/kiln.hoon index 31f532add..ae1a4cb6f 100644 --- a/pkg/arvo/lib/hood/kiln.hoon +++ b/pkg/arvo/lib/hood/kiln.hoon @@ -5,7 +5,8 @@ =, format =* dude dude:gall |% -+$ state state-5 ++$ state state-6 ++$ state-6 [%6 pith-6] +$ state-5 [%5 pith-5] +$ state-4 [%4 pith-4] +$ state-3 [%3 pith-3] @@ -14,13 +15,32 @@ +$ state-0 [%0 pith-0] +$ any-state $~ *state - $% state-5 + $% state-6 + state-5 state-4 state-3 state-2 state-1 state-0 == +:: ++$ pith-6 + $: wef=(unit weft) + rem=(map desk per-desk) :: + syn=(map kiln-sync let=@ud) :: + ark=(map desk arak) :: + commit-timer=[way=wire nex=@da tim=@dr mon=term] :: + :: map desk to the currently ongoing fuse request + :: and the latest version numbers for beaks to + fus=(map desk per-fuse) + :: used for fuses - every time we get a fuse we + :: bump this. used when calculating hashes to + :: ensure they're unique even when the same + :: request is made multiple times. + hxs=(map desk @ud) + == :: +:: + +$ pith-5 $: rem=(map desk per-desk) :: syn=(map kiln-sync let=@ud) :: @@ -253,13 +273,19 @@ |= a=arak-4 ^- arak [[paused=| ship desk aeon] next rein]:a + =? old ?=(%5 -.old) + [%6 ~ +.old] :: - ?> ?=(%5 -.old) + ?> ?=(%6 -.old) =. +<+.$.abet old =< abet - ?~ old-ota - kiln - abet:(install:vats %base [her sud]:u.old-ota) + =? kiln ?=(^ old-ota) + abet:(install:vats %base [her sud]:u.old-ota) + =? kiln ?=(^ wef) + =/ except=(set desk) (sy %base %kids ~) + (bump:vats u.wef (all-desks-but:vats except) %.n) + =. wef ~ + kiln :: ++ on-peek |= =path @@ -479,7 +505,7 @@ =/ ded (find-blocked kel except) ?: force =. kiln (suspend-many ded) - (bump-many kel (all-desks-but except)) + (bump-many kel (all-desks-but (~(uni in except) ded))) ?: =(~ ded) (bump-many kel (all-desks-but except)) =- (^emit (pyre:pass leaf/- ~)) @@ -496,6 +522,7 @@ |= dead=(set desk) ^+ kiln =/ ded ~(tap in dead) + |- ^+ kiln ?~ ded kiln $(ded t.ded, kiln abet:(suspend i.ded)) @@ -598,9 +625,19 @@ (emil sync-ud:pass (diff:give diff) ~) ?: (lth num.new-weft num.old-weft) ~> %slog.0^leaf/"kiln: future version {}, enqueueing" + :: retry upgrade if not blocked anymore + =/ base=arak (~(got by ark) %base) =. next.rak (snoc next.rak [(dec aeon.rail.rak) new-weft]) + =. ark (~(put by ark) loc rak) =/ =diff [%block loc rak new-weft blockers=(sy %base ~)] - (emil sync-ud:pass (diff:give diff) ~) + =. vats (emil sync-ud:pass (diff:give diff) ~) + ?. &(?=(^ next.base) =(~ (get-blockers weft.i.next.base))) + vats + ~> %slog.0^leaf/"kiln: unblocked system update, updating" + =. kiln + (bump-one weft.i.next.base %base) + vats + :: ~> %slog.0^leaf/"kiln: merging into {here}" =. next.rak +:(crank-next %& (dec aeon.rail.rak)) (emil ~[merge-main sync-ud]:pass) @@ -617,6 +654,9 @@ (emil sync-ud:pass (diff:give diff) ~) ~> %slog.0^leaf/"kiln: applying OTA to {here}, kelvin: {}" =. next.rak +:(crank-next %& (dec aeon.rail.rak)) + =. wef + ?: =(old-weft new-weft) ~ + `new-weft (emil ~[merge-main sync-ud]:pass) :: ++ take-merge-main @@ -639,8 +679,7 @@ (update-running-apps (get-apps-diff our loc now rein.rak)) ?. =(%base loc) vats - =/ except=(set desk) (sy %base %kids ~) - =. kiln (bump-many zuse/zuse (all-desks-but except)) + ~> %slog.0^leaf/"kiln: bumping {}" (emit merge-kids:pass) :: ++ take-merge-kids @@ -774,7 +813,10 @@ :: ++ poke-bump |= [except=(set desk) force=?] - =/ kel=weft zuse/+(zuse) + =/ =arak + (~(got by ark) %base) + =/ kel=weft + ?~(next.arak zuse+zuse weft.i.next.arak) abet:(bump:vats kel except force) :: ++ poke-cancel diff --git a/pkg/base-dev/sur/hood.hoon b/pkg/base-dev/sur/hood.hoon index f67f69096..9bb9aaa63 100644 --- a/pkg/base-dev/sur/hood.hoon +++ b/pkg/base-dev/sur/hood.hoon @@ -202,11 +202,11 @@ kelvin+(numb num.w) == :: - ++ woof - |= =rung + ++ rung + |= r=^rung %- pairs - :~ aeon+(numb aeon.rung) - weft+(weft weft.rung) + :~ aeon+(numb aeon.r) + weft+(weft weft.r) == :: ++ rein @@ -222,7 +222,7 @@ :~ ship+s+(scot %p ship.rail.a) desk+s+desk.rail.a aeon+(numb aeon.rail.a) - next+a+(turn next.a woof) + next+a+(turn next.a rung) rein+(rein rein.a) == --