Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storage: Avoid filling volume config on VolumeDBCreate` #14923

Draft
wants to merge 20 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
6e4bca9
lxd/storage/drivers/btrfs: Remove unused parameters
hamistao Jan 16, 2025
c02f46a
lxd/storage/drivers/common: Remove stale return value from `[F|f]illV…
hamistao Feb 4, 2025
fe4bcdb
lxd/storage/drivers: Remove stale return value from `FillVolumeConfig`
hamistao Feb 4, 2025
c08ac7f
lxd/storage/backend_lxd: Update `FillVolumeConfig` usage
hamistao Feb 4, 2025
90e36f2
lxd/storage/utils: Update `FillVolumeConfig` usage
hamistao Feb 4, 2025
5ee733d
lxd/storage/drivers/ceph: Remove stale return value from `FillVolumeC…
hamistao Feb 4, 2025
300ddd4
lxd/storage/drivers/dir: Remove stale return value from `FillVolumeCo…
hamistao Feb 4, 2025
f5fa02c
lxd/storage/drivers/lvm: Remove stale return value from `FillVolumeCo…
hamistao Feb 4, 2025
6a5c520
lxd/storage/drivers/powerflex: Remove stale return value from `FillVo…
hamistao Feb 4, 2025
a780860
lxd/storage/drivers/zfs: Remove stale return value from `FillVolumeCo…
hamistao Feb 4, 2025
adc44a5
lxd/storage/drivers/pure: Remove stale return value from `FillVolumeC…
hamistao Feb 5, 2025
3c368f1
lxd/storage/utils: Don't fill up config on `VolumeDBCreate`
hamistao Feb 4, 2025
64afc6d
lxd/storage/backend_lxd: Fill volume configuration on `GetNewVolume`
hamistao Feb 4, 2025
9ff8f15
lxd/storage/backend_lxd: Add needed `FillVolumeConfig`
hamistao Feb 5, 2025
6e9d608
lxd/storage/backend_lxd: Update comments
hamistao Feb 5, 2025
c7ceccb
lxd/storage/drivers/ceph: Pre-allocate `ret` slice (prealloc)
hamistao Feb 5, 2025
1033993
lxd/storage/drivers/ceph: Avoid deprecated `RunCommand` (staticcheck)
hamistao Feb 5, 2025
e7c01f1
lxd/storage/drivers/common: Avoid deprecated `RunCommand` (staticcheck)
hamistao Feb 5, 2025
827bf2a
lxd/storage/drivers/zfs: Avoid deprecated `RunCommand` (staticcheck)
hamistao Feb 5, 2025
1497ea0
WIP
hamistao Feb 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions lxd/storage/backend_lxd.go
tomponline marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6447,8 +6447,7 @@ func (b *lxdBackend) ImportCustomVolume(projectName string, poolVol *backupConfi
for _, poolVolSnap := range poolVol.VolumeSnapshots {
fullSnapName := drivers.GetSnapshotVolumeName(poolVol.Volume.Name, poolVolSnap.Name)

// Copy volume config from backup file if present
// (so VolumeDBCreate can safely modify the copy if needed).
// Create new volume object to get a proper configuration for the driver in use.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Ensure driver specific default config is filled in new volume.

snapVol := b.GetNewVolume(drivers.VolumeTypeCustom, drivers.ContentType(poolVolSnap.ContentType), fullSnapName, poolVolSnap.Config)

// Validate config and create database entry for restored storage volume.
Expand Down Expand Up @@ -6556,7 +6555,6 @@ func (b *lxdBackend) CreateCustomVolumeSnapshot(projectName, volName string, new
}

// Validate config and create database entry for new storage volume.
// Copy volume config from parent.
err = VolumeDBCreate(b, projectName, fullSnapshotName, description, drivers.VolumeTypeCustom, true, vol.Config(), time.Now().UTC(), newExpiryDate, drivers.ContentType(parentVol.ContentType), false, true)
if err != nil {
return err
Expand Down Expand Up @@ -7455,7 +7453,6 @@ func (b *lxdBackend) ImportInstance(inst instance.Instance, poolVol *backupConfi
// Generate the effective root device volume for instance.
volStorageName := project.Instance(inst.Project().Name, inst.Name())

// Copy the volume's config so VolumeDBCreate can safely modify the copy if needed.
vol := b.GetNewVolume(volType, contentType, volStorageName, volumeConfig)

// Create storage volume database records if in recover mode.
Expand All @@ -7481,8 +7478,7 @@ func (b *lxdBackend) ImportInstance(inst instance.Instance, poolVol *backupConfi
for _, poolVolSnap := range poolVol.VolumeSnapshots {
fullSnapName := drivers.GetSnapshotVolumeName(inst.Name(), poolVolSnap.Name)

// Copy volume config from backup file if present,
// so VolumeDBCreate can safely modify the copy if needed.
// Create new volume object to get a proper configuration for the driver in use.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Ensure driver specific default config is filled in new volume.

snapVol := b.GetNewVolume(volType, contentType, fullSnapName, poolVolSnap.Config)

// Validate config and create database entry for recovered storage volume.
Expand All @@ -7503,8 +7499,7 @@ func (b *lxdBackend) ImportInstance(inst instance.Instance, poolVol *backupConfi
for _, i := range snapshots {
fullSnapName := i // Local var for revert.

// Copy the parent volume's config,
// so VolumeDBCreate can safely modify the copy if needed.
// Create new volume object to get a proper configuration for the driver in use.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Ensure driver specific default config is filled in new volume.

snapVol := b.GetNewVolume(volType, contentType, fullSnapName, volumeConfig)

// Validate config and create database entry for new storage volume.
Expand Down
Loading