@@ -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 }
0 commit comments