Skip to content

Commit 3c34170

Browse files
changes to support vere 4 (#734)
* changes to support vere 4 * fix casing of function * run prep with old binary * add trap for stale snapshots * update defaults --------- Co-authored-by: reid <reid@scogg.in>
1 parent 369e0a6 commit 3c34170

File tree

5 files changed

+172
-52
lines changed

5 files changed

+172
-52
lines changed

goseg/defaults/scripts.go

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,23 @@ var (
200200
echo "File .vere.lock containing PID 1 has been deleted."
201201
fi
202202
fi
203-
203+
204+
trap_urbit() {
205+
local args="$@"
206+
local logfile=$(mktemp)
207+
208+
urbit $args 2>&1 | tee "$logfile"
209+
local exit_code=${PIPESTATUS[0]}
210+
211+
if [[ $exit_code -ne 0 ]] && grep -q " stale snapshot: " "$logfile"; then
212+
echo "Detected stale snapshot, replaying with previous binary"
213+
rm -f "$logfile"
214+
exec prev-urbit -Lx $args
215+
fi
216+
217+
rm -f "$logfile"
218+
exit $exit_code
219+
}
204220
205221
if [ $devMode == "True" ]; then
206222
echo "Developer mode: $devMode"
@@ -215,7 +231,8 @@ var (
215231
exit 0
216232
else
217233
echo "urbit $ttyflag -p $amesPort --http-port $httpPort --loom $loom --snap-time $snapTime $dirname"
218-
urbit $ttyflag -p $amesPort --http-port $httpPort --loom $loom --snap-time $snapTime $dirname
234+
235+
trap_urbit $ttyflag -p $amesPort --http-port $httpPort --loom $loom --snap-time $snapTime $dirname
219236
fi`
220237

221238
RollScript = `#!/bin/bash
@@ -317,7 +334,7 @@ var (
317334
log_file="pack.log"
318335
exec > >(tee -a "$log_file") 2>&1
319336
320-
set -eu
337+
set -eux
321338
# set defaults
322339
#amesPort="34343"
323340
#httpPort="80"

goseg/defaults/version.go

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ var (
1717
"groundseg": {
1818
"canary": {
1919
"groundseg": {
20-
"amd64_sha256": "b42881004c37a7b4d5f33c13e6b53dd8eba10965f7aa868faf8699b986c7f5c0",
21-
"amd64_url": "https://files.native.computer/bin/groundseg_amd64_v2.3.0_latest",
22-
"arm64_sha256": "429068aa067c5ccf9cac8f3221292e9c636baa57d9e99609b18b2b5889dfd533",
23-
"arm64_url": "https://files.native.computer/bin/groundseg_arm64_v2.3.0_latest",
20+
"amd64_sha256": "653863b4db936794c15b9eff7ba0310458859c84ec6de11d68c0fc13cbf34e9e",
21+
"amd64_url": "https://files.native.computer/bin/groundseg_amd64_edge_v2.4.9-rc2",
22+
"arm64_sha256": "6b05281d5ce7a4ff7c0a0a4069ce1004825a2dcd88b4ffe19986c5d6825aefcc",
23+
"arm64_url": "https://files.native.computer/bin/groundseg_arm64_edge_v2.4.9-rc2",
24+
"slsa_url": "https://files.native.computer/bin/groundseg_edge_v2.4.9-rc2.jsonl",
2425
"major": 2,
25-
"minor": 3,
26-
"patch": 0
26+
"minor": 4,
27+
"patch": 9
2728
},
2829
"manual": {
2930
"amd64_sha256": "e59d3e83cffb7be6c56b58624caa095cb8ec4075ecff7962db510d891696ca86",
@@ -50,7 +51,7 @@ var (
5051
"tag": "latest"
5152
},
5253
"vere": {
53-
"amd64_sha256": "a288be1742505b7dd0eadefbe8c379a4696031418384aa522c50f224bfdc497c",
54+
"amd64_sha256": "bfe8f2da02e9bcf16fb12146b5787438c7102185bbdd80b79da1baba46f2074e",
5455
"arm64_sha256": "None",
5556
"repo": "registry.hub.docker.com/nativeplanet/urbit",
5657
"tag": "canary"
@@ -70,13 +71,14 @@ var (
7071
},
7172
"edge": {
7273
"groundseg": {
73-
"amd64_sha256": "1fe2c3a0cced99b911253ed8f96ba674e811f8ac6c515ae64a5b07dece2d345a",
74-
"amd64_url": "https://files.native.computer/bin/groundseg_amd64_v2.4.0-rc4_edge",
75-
"arm64_sha256": "0c4ea0940cf4be1bb348bdce4dbfb546ac7b5170210eb641fc9b946eda9455c3",
76-
"arm64_url": "https://files.native.computer/bin/groundseg_arm64_v2.4.0-rc4_edge",
74+
"amd64_sha256": "653863b4db936794c15b9eff7ba0310458859c84ec6de11d68c0fc13cbf34e9e",
75+
"amd64_url": "https://files.native.computer/bin/groundseg_amd64_edge_v2.4.9-rc2",
76+
"arm64_sha256": "6b05281d5ce7a4ff7c0a0a4069ce1004825a2dcd88b4ffe19986c5d6825aefcc",
77+
"arm64_url": "https://files.native.computer/bin/groundseg_arm64_edge_v2.4.9-rc2",
78+
"slsa_url": "https://files.native.computer/bin/groundseg_edge_v2.4.9-rc2.jsonl",
7779
"major": 2,
7880
"minor": 4,
79-
"patch": 0
81+
"patch": 9
8082
},
8183
"manual": {
8284
"amd64_sha256": "318a4a8922197493eefb73bfbd568728b5278f4146d2ba712929a032fd495092",
@@ -103,10 +105,10 @@ var (
103105
"tag": "latest"
104106
},
105107
"vere": {
106-
"amd64_sha256": "3da9d1419abbb0cd42f9c8f53a38a5b91baa00f7b4fc4dfb7fa65a3ade47d611",
107-
"arm64_sha256": "7e2eb9c2a8472a6c396a82f5fc7d629546a8f5d469e7e40bf1d87a8a05ba59d8",
108+
"amd64_sha256": "a0ec8cdf7018dbaa2e5598cedb5fd8b8a56e6e2386e7da60e2d930658ea0378f",
109+
"arm64_sha256": "ca4e8537bc8198dc8a97f23180b2ab5d0e40e2315b12fbfe80ad4d8f5119278b",
108110
"repo": "registry.hub.docker.com/nativeplanet/urbit",
109-
"tag": "v3.1"
111+
"tag": "v4.0"
110112
},
111113
"webui": {
112114
"amd64_sha256": "cc6ea93a53dcd50bef7be7077c41dc475943baee83343cece13884cb2a351308",
@@ -123,13 +125,14 @@ var (
123125
},
124126
"latest": {
125127
"groundseg": {
126-
"amd64_sha256": "b42881004c37a7b4d5f33c13e6b53dd8eba10965f7aa868faf8699b986c7f5c0",
127-
"amd64_url": "https://files.native.computer/bin/groundseg_amd64_v2.3.0_latest",
128-
"arm64_sha256": "429068aa067c5ccf9cac8f3221292e9c636baa57d9e99609b18b2b5889dfd533",
129-
"arm64_url": "https://files.native.computer/bin/groundseg_arm64_v2.3.0_latest",
128+
"amd64_sha256": "b9f246bfab0968af1aeec70c13ca1ac5e565e1937b759cc7da41f1256fa8b46d",
129+
"amd64_url": "https://files.native.computer/bin/groundseg_amd64_latest_v2.4.8",
130+
"arm64_sha256": "9553529b2047494b8baf1e315fd5e5ae2066388b647b2529469456f6acbef271",
131+
"arm64_url": "https://files.native.computer/bin/groundseg_arm64_latest_v2.4.8",
132+
"slsa_url": "https://files.native.computer/bin/groundseg_latest_v2.4.8.jsonl",
130133
"major": 2,
131-
"minor": 3,
132-
"patch": 0
134+
"minor": 4,
135+
"patch": 8
133136
},
134137
"manual": {
135138
"amd64_sha256": "e59d3e83cffb7be6c56b58624caa095cb8ec4075ecff7962db510d891696ca86",
@@ -156,10 +159,10 @@ var (
156159
"tag": "latest"
157160
},
158161
"vere": {
159-
"amd64_sha256": "164137948e7e6af3d7b7da9e0008adf1331f2f1e9de3c3384f5921a9b57a0c7c",
160-
"arm64_sha256": "727d43a00ace1612962abe2ea9c0462eb539a191bd3c7093b4567b8b9b163c92",
162+
"amd64_sha256": "a1f924e949e2fd55c65f546edcd3b0f709d24032ae7d67784fcd352cfab21a26",
163+
"arm64_sha256": "a6d025ce755631e77264395d68f79b9369f1d69502fee72a659d165ab0d28371",
161164
"repo": "registry.hub.docker.com/nativeplanet/urbit",
162-
"tag": "v3.1"
165+
"tag": "v4.0"
163166
},
164167
"webui": {
165168
"amd64_sha256": "cc6ea93a53dcd50bef7be7077c41dc475943baee83343cece13884cb2a351308",

goseg/handler/urbit.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ func AreSubdomainsAliases(domain1, domain2 string) (bool, error) {
155155
return cname1 == cname2, nil
156156
}
157157

158-
func waitComplete(patp string) {
158+
func WaitComplete(patp string) {
159159
ticker := time.NewTicker(500 * time.Millisecond)
160160
for {
161161
select {
@@ -513,7 +513,7 @@ func packMeldPier(patp string, shipConf structs.UrbitDocker) error {
513513
zap.L().Error(fmt.Sprintf("Failed to stop ship for pack & meld %s: %v", patp, err))
514514
}
515515
}
516-
waitComplete(patp)
516+
WaitComplete(patp)
517517
}
518518
// stop ship
519519
// start ship as pack
@@ -532,7 +532,7 @@ func packMeldPier(patp string, shipConf structs.UrbitDocker) error {
532532
}
533533

534534
zap.L().Info(fmt.Sprintf("Waiting for urth pack to complete for %s", patp))
535-
waitComplete(patp)
535+
WaitComplete(patp)
536536

537537
// start ship as meld
538538
zap.L().Info(fmt.Sprintf("Attempting to urth meld %s", patp))
@@ -550,7 +550,7 @@ func packMeldPier(patp string, shipConf structs.UrbitDocker) error {
550550
}
551551

552552
zap.L().Info(fmt.Sprintf("Waiting for urth meld to complete for %s", patp))
553-
waitComplete(patp)
553+
WaitComplete(patp)
554554

555555
// start ship if "boot"
556556
if isRunning {
@@ -689,7 +689,7 @@ func ChopPier(patp string, shipConf structs.UrbitDocker) error {
689689
return fmt.Errorf("Failed to stop ship for chop %s: %v", patp, err)
690690
}
691691
}
692-
waitComplete(patp)
692+
WaitComplete(patp)
693693
}
694694
// start ship as chop
695695
docker.UTransBus <- structs.UrbitTransition{Patp: patp, Type: "chop", Event: "chopping"}
@@ -707,7 +707,7 @@ func ChopPier(patp string, shipConf structs.UrbitDocker) error {
707707
}
708708

709709
zap.L().Info(fmt.Sprintf("Waiting for chop to complete for %s", patp))
710-
waitComplete(patp)
710+
WaitComplete(patp)
711711

712712
// start ship if "boot"
713713
if isRunning {
@@ -1219,7 +1219,7 @@ func rollChopPier(patp string, shipConf structs.UrbitDocker) error {
12191219
zap.L().Error(fmt.Sprintf("Failed to stop ship for roll & chop %s: %v", patp, err))
12201220
}
12211221
}
1222-
waitComplete(patp)
1222+
WaitComplete(patp)
12231223
}
12241224
// start ship as roll
12251225
docker.UTransBus <- structs.UrbitTransition{Patp: patp, Type: "rollChop", Event: "rolling"}
@@ -1237,7 +1237,7 @@ func rollChopPier(patp string, shipConf structs.UrbitDocker) error {
12371237
}
12381238

12391239
zap.L().Info(fmt.Sprintf("Waiting for roll to complete for %s", patp))
1240-
waitComplete(patp)
1240+
WaitComplete(patp)
12411241

12421242
// start ship as chop
12431243
zap.L().Info(fmt.Sprintf("Attempting to chop %s", patp))
@@ -1255,7 +1255,7 @@ func rollChopPier(patp string, shipConf structs.UrbitDocker) error {
12551255
}
12561256

12571257
zap.L().Info(fmt.Sprintf("Waiting for chop to complete for %s", patp))
1258-
waitComplete(patp)
1258+
WaitComplete(patp)
12591259

12601260
// start ship if "boot"
12611261
if isRunning {

goseg/routines/version.go

Lines changed: 115 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ func callUpdater(releaseChannel string) {
5252
latestChannelVersion := latestVersion
5353
// check docker updates
5454
if latestChannelVersion != currentChannelVersion {
55-
config.VersionInfo = latestVersion
5655
updateDocker(releaseChannel, currentChannelVersion, latestChannelVersion)
56+
config.VersionInfo = latestVersion
5757
}
5858
// Check for gs binary updates based on hash
5959
binPath := filepath.Join(config.BasePath, "groundseg")
@@ -293,17 +293,67 @@ func updateDocker(release string, currentVersion structs.Channel, latestVersion
293293
} else if sw == "vere" {
294294
for pier, status := range statuses {
295295
isRunning := (status == "Up" || strings.HasPrefix(status, "Up "))
296+
urbConf := config.UrbitConf(pier)
297+
298+
// Stop ship if running
296299
if isRunning {
297-
_, err := docker.StartContainer(pier, "vere")
298-
if err != nil {
299-
zap.L().Error(fmt.Sprintf("Failed to start %s after vere update: %v", err))
300+
zap.L().Info(fmt.Sprintf("Stopping %s for vere upgrade", pier))
301+
if err := docker.StopContainerByName(pier); err != nil {
302+
zap.L().Error(fmt.Sprintf("Failed to stop %s: %v", pier, err))
303+
continue
300304
}
305+
}
306+
307+
// Run urbit prep with old image (always, regardless of running status)
308+
zap.L().Info(fmt.Sprintf("Running urbit prep for %s with old vere image before upgrade", pier))
309+
urbConf.BootStatus = "prep"
310+
update := make(map[string]structs.UrbitDocker)
311+
update[pier] = urbConf
312+
if err := config.UpdateUrbitConfig(update); err != nil {
313+
zap.L().Error(fmt.Sprintf("Failed to update %s config for prep: %v", pier, err))
301314
continue
302315
}
303-
// after starting (or not starting) the container,
304-
// check if it wants a chop
305-
urbConf := config.UrbitConf(pier)
306-
if urbConf.ChopOnUpgrade == true {
316+
317+
// Start container to run prep
318+
_, err := docker.StartContainer(pier, "vere")
319+
if err != nil {
320+
zap.L().Error(fmt.Sprintf("Failed to run prep for %s: %v", pier, err))
321+
continue
322+
}
323+
324+
// Wait for prep to complete
325+
zap.L().Info(fmt.Sprintf("Waiting for prep to complete for %s", pier))
326+
handler.WaitComplete(pier)
327+
328+
// Set boot status appropriately after prep
329+
if isRunning {
330+
// Ship was running before, boot it with new image
331+
zap.L().Info(fmt.Sprintf("Starting %s with new vere image", pier))
332+
urbConf.BootStatus = "boot"
333+
update = make(map[string]structs.UrbitDocker)
334+
update[pier] = urbConf
335+
if err := config.UpdateUrbitConfig(update); err != nil {
336+
zap.L().Error(fmt.Sprintf("Failed to update %s config for boot: %v", pier, err))
337+
continue
338+
}
339+
_, err = docker.StartContainer(pier, "vere")
340+
if err != nil {
341+
zap.L().Error(fmt.Sprintf("Failed to start %s after vere update: %v", pier, err))
342+
continue
343+
}
344+
} else {
345+
// Ship was not running, keep it stopped but update config
346+
zap.L().Info(fmt.Sprintf("%s prep complete, keeping ship stopped", pier))
347+
urbConf.BootStatus = "noboot"
348+
update = make(map[string]structs.UrbitDocker)
349+
update[pier] = urbConf
350+
if err := config.UpdateUrbitConfig(update); err != nil {
351+
zap.L().Error(fmt.Sprintf("Failed to update %s config after prep: %v", pier, err))
352+
}
353+
}
354+
355+
// Check if it wants a chop after upgrade (only if running)
356+
if isRunning && urbConf.ChopOnUpgrade == true {
307357
go handler.ChopPier(pier, urbConf)
308358
}
309359
}
@@ -323,17 +373,67 @@ func updateDocker(release string, currentVersion structs.Channel, latestVersion
323373
} else if sw == "vere" {
324374
for pier, status := range statuses {
325375
isRunning := (status == "Up" || strings.HasPrefix(status, "Up "))
376+
urbConf := config.UrbitConf(pier)
377+
378+
// Stop ship if running
326379
if isRunning {
327-
_, err := docker.StartContainer(pier, "vere")
328-
if err != nil {
329-
zap.L().Error(fmt.Sprintf("Failed to start %s after vere update: %v", err))
380+
zap.L().Info(fmt.Sprintf("Stopping %s for vere upgrade", pier))
381+
if err := docker.StopContainerByName(pier); err != nil {
382+
zap.L().Error(fmt.Sprintf("Failed to stop %s: %v", pier, err))
383+
continue
330384
}
385+
}
386+
387+
// Run urbit prep with old image (always, regardless of running status)
388+
zap.L().Info(fmt.Sprintf("Running urbit prep for %s with old vere image before upgrade", pier))
389+
urbConf.BootStatus = "prep"
390+
update := make(map[string]structs.UrbitDocker)
391+
update[pier] = urbConf
392+
if err := config.UpdateUrbitConfig(update); err != nil {
393+
zap.L().Error(fmt.Sprintf("Failed to update %s config for prep: %v", pier, err))
331394
continue
332395
}
333-
// after starting (or not starting) the container,
334-
// check if it wants a chop
335-
urbConf := config.UrbitConf(pier)
336-
if urbConf.ChopOnUpgrade == true {
396+
397+
// Start container to run prep
398+
_, err := docker.StartContainer(pier, "vere")
399+
if err != nil {
400+
zap.L().Error(fmt.Sprintf("Failed to run prep for %s: %v", pier, err))
401+
continue
402+
}
403+
404+
// Wait for prep to complete
405+
zap.L().Info(fmt.Sprintf("Waiting for prep to complete for %s", pier))
406+
handler.WaitComplete(pier)
407+
408+
// Set boot status appropriately after prep
409+
if isRunning {
410+
// Ship was running before, boot it with new image
411+
zap.L().Info(fmt.Sprintf("Starting %s with new vere image", pier))
412+
urbConf.BootStatus = "boot"
413+
update = make(map[string]structs.UrbitDocker)
414+
update[pier] = urbConf
415+
if err := config.UpdateUrbitConfig(update); err != nil {
416+
zap.L().Error(fmt.Sprintf("Failed to update %s config for boot: %v", pier, err))
417+
continue
418+
}
419+
_, err = docker.StartContainer(pier, "vere")
420+
if err != nil {
421+
zap.L().Error(fmt.Sprintf("Failed to start %s after vere update: %v", pier, err))
422+
continue
423+
}
424+
} else {
425+
// Ship was not running, keep it stopped but update config
426+
zap.L().Info(fmt.Sprintf("%s prep complete, keeping ship stopped", pier))
427+
urbConf.BootStatus = "noboot"
428+
update = make(map[string]structs.UrbitDocker)
429+
update[pier] = urbConf
430+
if err := config.UpdateUrbitConfig(update); err != nil {
431+
zap.L().Error(fmt.Sprintf("Failed to update %s config after prep: %v", pier, err))
432+
}
433+
}
434+
435+
// Check if it wants a chop after upgrade (only if running)
436+
if isRunning && urbConf.ChopOnUpgrade == true {
337437
go handler.ChopPier(pier, urbConf)
338438
}
339439
}

ui/src/routes/[patp]/Section/Slider.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
99
export let patp
1010
export let min = 28
11-
export let max = 33
11+
export let max = 34
1212
export let loomSize
1313
1414
let slide

0 commit comments

Comments
 (0)