Skip to content

Commit

Permalink
incusd/instances_post: Account for profiles when overriding pool in DB
Browse files Browse the repository at this point in the history
Signed-off-by: Stéphane Graber <[email protected]>
  • Loading branch information
stgraber committed Nov 26, 2024
1 parent e478004 commit c1b0782
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cmd/incusd/instances_post.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,10 +400,10 @@ func createFromMigration(ctx context.Context, s *state.State, r *http.Request, p
instOp.Done(nil) // Complete operation that was created earlier, to release lock.

if migrationArgs.StoragePool != "" {
// Update root device for instance.
// Update root device for the instance.
err = s.DB.Cluster.Transaction(context.Background(), func(ctx context.Context, tx *db.ClusterTx) error {
devs := inst.LocalDevices().CloneNative()
rootDevKey, _, err := internalInstance.GetRootDiskDevice(devs)
rootDevKey, _, err := internalInstance.GetRootDiskDevice(inst.ExpandedDevices().CloneNative())
if err != nil {
if !errors.Is(err, internalInstance.ErrNoRootDisk) {
return err
Expand All @@ -416,6 +416,12 @@ func createFromMigration(ctx context.Context, s *state.State, r *http.Request, p

devs["root"] = rootDev
} else {
// Copy the device if not a local device.
_, ok := devs[rootDevKey]
if !ok {
devs[rootDevKey] = inst.ExpandedDevices().CloneNative()[rootDevKey]
}

// Apply the override.
devs[rootDevKey]["pool"] = storagePool
}
Expand Down

0 comments on commit c1b0782

Please sign in to comment.