@@ -191,9 +191,7 @@ func (s *AteomService) RunWorkload(ctx context.Context, req *ateompb.RunWorkload
191191 }
192192 defer func () {
193193 if retErr != nil {
194- if cleanupErr := s .cleanupActorNetwork (ctx ); cleanupErr != nil {
195- slog .WarnContext (ctx , "Failed to clean up actor network after Run failure" , "err" , cleanupErr )
196- }
194+ s .cleanupActorNetworkOrExit (ctx , "Failed to clean up actor network after Run failure" )
197195 }
198196 }()
199197
@@ -273,9 +271,7 @@ func (s *AteomService) CheckpointWorkload(ctx context.Context, req *ateompb.Chec
273271 "err" , err )
274272 }
275273
276- if err := s .cleanupActorNetwork (ctx ); err != nil {
277- return nil , fmt .Errorf ("while cleaning up actor network: %w" , err )
278- }
274+ s .cleanupActorNetworkOrExit (ctx , "Failed to clean up actor network after checkpoint" )
279275
280276 s .actorLogger .EmitLifecycleLog ("Actor checkpointed" , req .GetActorId (), req .GetActorTemplateName (), req .GetActorTemplateNamespace ())
281277
@@ -325,9 +321,7 @@ func (s *AteomService) RestoreWorkload(ctx context.Context, req *ateompb.Restore
325321 }
326322 defer func () {
327323 if retErr != nil {
328- if cleanupErr := s .cleanupActorNetwork (ctx ); cleanupErr != nil {
329- slog .WarnContext (ctx , "Failed to clean up actor network after Restore failure" , "err" , cleanupErr )
330- }
324+ s .cleanupActorNetworkOrExit (ctx , "Failed to clean up actor network after Restore failure" )
331325 }
332326 }()
333327
@@ -384,14 +378,10 @@ func (s *AteomService) setupActorNetwork(ctx context.Context) (retErr error) {
384378 //
385379 // Clean up stale state from a failed prior activation before creating the
386380 // next actor-side network. The worker currently runs one actor at a time.
387- if err := s .cleanupActorNetwork (ctx ); err != nil {
388- return fmt .Errorf ("while removing stale actor network: %w" , err )
389- }
381+ s .cleanupActorNetworkOrExit (ctx , "Failed to clean up stale actor network before setup" )
390382 defer func () {
391383 if retErr != nil {
392- if cleanupErr := s .cleanupActorNetwork (ctx ); cleanupErr != nil {
393- slog .WarnContext (ctx , "Failed to clean up partially configured actor network" , "err" , cleanupErr )
394- }
384+ s .cleanupActorNetworkOrExit (ctx , "Failed to clean up partially configured actor network" )
395385 }
396386 }()
397387
@@ -558,6 +548,12 @@ func (s *AteomService) cleanupActorNetwork(ctx context.Context) error {
558548 return cleanupErr
559549}
560550
551+ func (s * AteomService ) cleanupActorNetworkOrExit (ctx context.Context , msg string ) {
552+ if err := s .cleanupActorNetwork (ctx ); err != nil {
553+ serverboot .Fatal (ctx , msg , err )
554+ }
555+ }
556+
561557func podIPv4 () (net.IP , error ) {
562558 // Resolve the worker pod IPv4 address from the pod namespace's real eth0.
563559 // Because eth0 now stays in the pod namespace, this IP remains available for
0 commit comments