From c1b078241144996665ac028bb56ea1311200c7ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Tue, 26 Nov 2024 16:53:18 -0500 Subject: [PATCH] incusd/instances_post: Account for profiles when overriding pool in DB MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber --- cmd/incusd/instances_post.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmd/incusd/instances_post.go b/cmd/incusd/instances_post.go index 9c71ef52f9..2834cde154 100644 --- a/cmd/incusd/instances_post.go +++ b/cmd/incusd/instances_post.go @@ -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 @@ -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 }