diff --git a/lxd/storage/backend_lxd.go b/lxd/storage/backend_lxd.go index c6cb3cecd262..89771525a106 100644 --- a/lxd/storage/backend_lxd.go +++ b/lxd/storage/backend_lxd.go @@ -1025,6 +1025,11 @@ func (b *lxdBackend) CreateInstanceFromCopy(inst instance.Instance, src instance volStorageName := project.Instance(inst.Project().Name, inst.Name()) vol := b.GetVolume(volType, contentType, volStorageName, srcConfig.Volume.Config) + // Override the source volume's UUID. + // Do this before asking the storage driver if it already has the volume. + // Some storage drivers might require the UUID to generate the volume name. + vol.Config()["volatile.uuid"] = uuid.New().String() + volExists, err := b.driver.HasVolume(vol) if err != nil { return err @@ -1061,10 +1066,6 @@ func (b *lxdBackend) CreateInstanceFromCopy(inst instance.Instance, src instance srcVolStorageName := project.Instance(src.Project().Name, src.Name()) srcVol := b.GetVolume(volType, contentType, srcVolStorageName, srcConfig.Volume.Config) - // Delete the source volume's UUID. - // A new one gets set when creating the record in the DB. - delete(vol.Config(), "volatile.uuid") - // Validate config and create database entry for new storage volume. err = VolumeDBCreate(b, inst.Project().Name, inst.Name(), "", vol.Type(), false, vol.Config(), inst.CreationDate(), time.Time{}, contentType, false, true) if err != nil {