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
15 changes: 10 additions & 5 deletions lxd/storage/drivers/driver_ceph_volumes.go
Copy link
Member

Choose a reason for hiding this comment

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

Hrm I'd be hesitant to start forcefully killing ongoing storage commands that are mutating the local or remote storage layers during a clean shutdown. This feels like its asking for trouble to me.

Was there a reason you didn't go with context.Background() here to ensure the commands safely completed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just failed to consider the risks of stopping these commands midway. Considering that doing so would simply leave the storage layers unharmed is far too optimistic.

Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ import (
func (d *ceph) CreateVolume(vol Volume, filler *VolumeFiller, op *operations.Operation) error {
// Function to rename an RBD volume.
renameVolume := func(oldName string, newName string) error {
_, err := shared.RunCommand(
_, err := shared.RunCommandContext(
d.state.ShutdownCtx,
"rbd",
"--id", d.config["ceph.user.name"],
"--cluster", d.config["ceph.cluster_name"],
Expand Down Expand Up @@ -390,7 +391,8 @@ func (d *ceph) CreateVolumeFromCopy(vol VolumeCopy, srcVol VolumeCopy, allowInco
if len(vol.Snapshots) == 0 || len(snapshots) == 0 {
// If lightweight clone mode isn't enabled, perform a full copy of the volume.
if shared.IsFalse(d.config["ceph.rbd.clone_copy"]) {
_, err = shared.RunCommand(
_, err = shared.RunCommandContext(
d.state.ShutdownCtx,
"rbd",
"--id", d.config["ceph.user.name"],
"--cluster", d.config["ceph.cluster_name"],
Expand Down Expand Up @@ -1022,7 +1024,8 @@ func (d *ceph) DeleteVolume(vol Volume, op *operations.Operation) error {
}

// Delete snapshots.
_, err := shared.RunCommand(
_, err := shared.RunCommandContext(
d.state.ShutdownCtx,
"rbd",
"--id", d.config["ceph.user.name"],
"--cluster", d.config["ceph.cluster_name"],
Expand Down Expand Up @@ -1921,7 +1924,8 @@ func (d *ceph) CreateVolumeSnapshot(snapVol Volume, op *operations.Operation) er
// DeleteVolumeSnapshot removes a snapshot from the storage device.
func (d *ceph) DeleteVolumeSnapshot(snapVol Volume, op *operations.Operation) error {
// Check if snapshot exists, and return if not.
_, err := shared.RunCommand(
_, err := shared.RunCommandContext(
d.state.ShutdownCtx,
"rbd",
"--id", d.config["ceph.user.name"],
"--cluster", d.config["ceph.cluster_name"],
Expand Down Expand Up @@ -2191,7 +2195,8 @@ func (d *ceph) restoreVolume(vol Volume, snapVol Volume, op *operations.Operatio

_, snapshotName, _ := api.GetParentAndSnapshotName(snapVol.name)

_, err = shared.RunCommand(
_, err = shared.RunCommandContext(
d.state.ShutdownCtx,
"rbd",
"--id", d.config["ceph.user.name"],
"--cluster", d.config["ceph.cluster_name"],
Expand Down
Loading