Skip to content

Commit

Permalink
Merge pull request #1408 from stgraber/main
Browse files Browse the repository at this point in the history
incusd/instance: Lock image access
  • Loading branch information
hallyn authored Nov 22, 2024
2 parents d55c315 + 0d02b8f commit 646a571
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cmd/incusd/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,15 @@ func instanceCreateFromImage(ctx context.Context, s *state.State, r *http.Reques
return fmt.Errorf("Failed loading instance storage pool: %w", err)
}

// Lock this operation to ensure that concurrent image operations don't conflict.
// Other operations will wait for this one to finish.
unlock, err := imageOperationLock(ctx, img.Fingerprint)
if err != nil {
return err
}

defer unlock()

err = pool.CreateInstanceFromImage(inst, img.Fingerprint, op)
if err != nil {
return fmt.Errorf("Failed creating instance from image: %w", err)
Expand Down

0 comments on commit 646a571

Please sign in to comment.