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: Delete potentially left snapshot temporary volume #14920

Merged
merged 5 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
3 changes: 1 addition & 2 deletions lxd/storage/connectors/connector_iscsi.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ func (c *connectorISCSI) QualifiedName() (string, error) {

// discoverTargets discovers the available iSCSI targets on a given address.
func (c *connectorISCSI) discoverTargets(ctx context.Context, targetAddr string) error {
// Discover the available iSCSI targets on a given address.
_, _, err := shared.RunCommandSplit(ctx, nil, nil, "iscsiadm", "--mode", "discovery", "--type", "sendtargets", "--portal", targetAddr)
_, err := shared.RunCommandContext(ctx, "iscsiadm", "--mode", "discovery", "--type", "sendtargets", "--portal", targetAddr)
if err != nil {
return fmt.Errorf("Failed to discover available iSCSI targets on %q: %w", targetAddr, err)
}
Expand Down
2 changes: 1 addition & 1 deletion lxd/storage/drivers/driver_pure_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -1488,7 +1488,7 @@ func (d *pure) getMappedDevPath(vol Volume, mapVolume bool) (string, revert.Hook
// - "00" - Padding
// - "8726b5033af243" - First 14 characters of serial number
// - "24a937" - OUI (Organizationally Unique Identifier)
// - "3d00014196" - Last 10 characters of serail number
// - "3d00014196" - Last 10 characters of serial number
diskSuffix = "00" + pureVol.Serial[0:14] + "24a937" + pureVol.Serial[14:]
default:
return "", nil, fmt.Errorf("Unsupported Pure Storage mode %q", connector.Type())
Expand Down
17 changes: 17 additions & 0 deletions lxd/storage/drivers/driver_pure_volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -1221,6 +1221,23 @@ func (d *pure) DeleteVolumeSnapshot(snapVol Volume, op *operations.Operation) er
return err
}

// Snapshots cannot be mounted directly, so when this is needed, the snapshot is copied
// into a temporary volume. In case LXD was abruptly stopped in the moment when
// temporary volume was created, it is possible that the volume was not removed.
tmpVol, err := d.client().getVolume(snapVol.pool, snapVolName)
if err != nil && !api.StatusErrorCheck(err, http.StatusNotFound) {
return fmt.Errorf("Failed retrieving temporary snapshot volume: %w", err)
}

if tmpVol != nil {
// Temporary volume found, delete it.
err = d.client().deleteVolume(snapVol.pool, snapVolName)
if err != nil {
return fmt.Errorf("Failed deleting temporary snapshot volume: %w", err)
}
}

// Delete snapshot.
err = d.client().deleteVolumeSnapshot(snapVol.pool, parentVolName, snapVolName)
if err != nil {
return err
Expand Down
Loading