Skip to content

Commit 71d0996

Browse files
authored
fix: ensure we say we failed if we fail to create a vol (#44)
Addresses a bug where tasks were not correctly marked as failed when a volume creation operation failed.
1 parent 831e224 commit 71d0996

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

internal/engine/clients/broker/rabbit/broker.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ func (b *rabbitBroker) Subscribe(ctx context.Context, callback func(ctx context.
118118
}
119119
}
120120

121+
// span
121122
slog.ErrorContext(ctx, "subscriber failed to connect after max attempts", "queue", options.Queue, "maxAttempts", maxAttempts)
122123
}()
123124

internal/engine/services/worker/service.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,22 @@ func (s *Service) runTask(ctx context.Context, t *task.Task) error {
113113
runner.CreateVolumeWithName(volName),
114114
}
115115
if err := s.runner.CreateVolume(ctx, opts...); err != nil {
116-
return err
116+
finished := time.Now()
117+
t.Error = err.Error()
118+
t.State = task.Failed
119+
t.FailedAt = &finished
120+
121+
failedBs, _ := json.Marshal(t)
122+
123+
failedOpts := []broker.PublishOption{
124+
broker.PublishWithQueue(broker.FAILED),
125+
}
126+
127+
if err := s.broker.Publish(ctx, failedBs, failedOpts...); err != nil {
128+
return err
129+
}
130+
131+
return nil
117132
}
118133
defer func(volName string) {
119134
opts := []runner.DeleteVolumeOption{

0 commit comments

Comments
 (0)