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
6 changes: 3 additions & 3 deletions lxd/storage/drivers/driver_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ func (d *common) moveGPTAltHeader(devPath string) error {
return nil
}

_, err = shared.RunCommand(path, "--move-second-header", devPath)
_, err = shared.RunCommandContext(d.state.ShutdownCtx, path, "--move-second-header", devPath)
Copy link
Member

Choose a reason for hiding this comment

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

i dont think we should use d.state.ShutdownCtx for anything mutating the disk, as Go will then forcefully kill the command, leaving it in an inconsistent state.

We've been bitten before by this in the past where we killed an ongoing ceph map command, which then left unrecoverable structures in the kernel and the system had to be rebooted.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We've been bitten before by this in the past where we killed an ongoing ceph map command, which then left unrecoverable structures in the kernel and the system had to be rebooted.

Always useful to know some history, thanks for the insight!
I will make the necessary updates.

Copy link
Member

Choose a reason for hiding this comment

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

In general if a command isnt mutating something we can use d.state.shutdownCtx to exit more quickly, but if we're mutating something it'd be better to let it finish in my view (ofc if thats going to take a long time and some cleanup is going to happen on error, such as writing a large file out and then removing it on error in a defer then that would be different).

if err == nil {
d.logger.Debug("Moved GPT alternative header to end of disk", logger.Ctx{"dev": devPath})
return nil
Expand Down Expand Up @@ -582,15 +582,15 @@ func (d *common) filesystemFreeze(path string) (func() error, error) {
return nil, fmt.Errorf("Failed syncing filesystem %q: %w", path, err)
}

_, err = shared.RunCommand("fsfreeze", "--freeze", path)
_, err = shared.RunCommandContext(d.state.ShutdownCtx, "fsfreeze", "--freeze", path)
if err != nil {
return nil, fmt.Errorf("Failed freezing filesystem %q: %w", path, err)
}

d.logger.Info("Filesystem frozen", logger.Ctx{"path": path})

unfreezeFS := func() error {
_, err := shared.RunCommand("fsfreeze", "--unfreeze", path)
_, err := shared.RunCommandContext(d.state.ShutdownCtx, "fsfreeze", "--unfreeze", path)
if err != nil {
return fmt.Errorf("Failed unfreezing filesystem %q: %w", path, err)
}
Expand Down
Loading