Skip to content

Commit 646a571

Browse files
authored
Merge pull request #1408 from stgraber/main
incusd/instance: Lock image access
2 parents d55c315 + 0d02b8f commit 646a571

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

cmd/incusd/instance.go

+9
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,15 @@ func instanceCreateFromImage(ctx context.Context, s *state.State, r *http.Reques
183183
return fmt.Errorf("Failed loading instance storage pool: %w", err)
184184
}
185185

186+
// Lock this operation to ensure that concurrent image operations don't conflict.
187+
// Other operations will wait for this one to finish.
188+
unlock, err := imageOperationLock(ctx, img.Fingerprint)
189+
if err != nil {
190+
return err
191+
}
192+
193+
defer unlock()
194+
186195
err = pool.CreateInstanceFromImage(inst, img.Fingerprint, op)
187196
if err != nil {
188197
return fmt.Errorf("Failed creating instance from image: %w", err)

0 commit comments

Comments
 (0)