Skip to content

Commit

Permalink
lxd/storage/backend_lxd: Set the volume's UUID at the right place for…
Browse files Browse the repository at this point in the history
… instance copy

Signed-off-by: Julian Pelizäus <[email protected]>
  • Loading branch information
roosterfish committed Feb 19, 2024
1 parent bb8894a commit be44fcc
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lxd/storage/backend_lxd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit be44fcc

Please sign in to comment.