mirror of
https://github.com/mulgadc/spinifex.git
synced 2026-10-15 09:01:31 +00:00
fix: propagate KV read errors when releasing an ECS reservation
releaseReservation returned nil for every kv.Get error, so a NATS timeout or connection drop was reported as a successful release and the stopped task's CPU/memory/GPU capacity leaked on that instance. Narrow the nil return to jetstream.ErrKeyNotFound, matching the pattern already used in service.go and task_stop.go, and return anything else.
This commit is contained in:
@@ -3,6 +3,7 @@ package handlers_ecs
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"log/slog"
|
||||
"slices"
|
||||
"time"
|
||||
@@ -359,8 +360,11 @@ func (s *Service) recordDeploymentFailure(ctx context.Context, kv jetstream.KeyV
|
||||
func (s *Service) releaseReservation(ctx context.Context, kv jetstream.KeyValue, cluster, instanceID, taskID string, cpu, mem, gpu int) error {
|
||||
for range reservePlacementRetries {
|
||||
entry, err := kv.Get(ctx, InstanceKey(cluster, instanceID))
|
||||
if errors.Is(err, jetstream.ErrKeyNotFound) {
|
||||
return nil
|
||||
}
|
||||
if err != nil {
|
||||
return nil //nolint:nilerr // instance gone; nothing to release
|
||||
return err
|
||||
}
|
||||
var rec InstanceRecord
|
||||
if uerr := json.Unmarshal(entry.Value(), &rec); uerr != nil {
|
||||
|
||||
Reference in New Issue
Block a user