Skip to content

Commit

Permalink
rbd: fix snapshot deletion by resolving image names correctly
Browse files Browse the repository at this point in the history
When creating a Snapshot with the new NewSnapshotByID() function, the
name of the RBD-image that is created is the same as the name of the
Snapshot. The `RbdImageName` points to the name of parent image, which
causes deleting the Snapshot to delete the parent image instead.

Correcting the `RbdImageName` and setting it to the `RbdSnapName` makes
sure that upon deletion, the Snapshot RBD-image is removed, and not the
parent image.

Signed-off-by: Niels de Vos <[email protected]>
  • Loading branch information
nixpanic committed Nov 6, 2024
1 parent 925593b commit 7ab7478
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions internal/rbd/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@ func (mgr *rbdManager) GetSnapshotByID(ctx context.Context, id string) (types.Sn
}
}

// FIXME: The snapshot will have RbdImageName set to the image that was
// used as source. This is not correct for group snapshots images, and
// need to be fixed. See rbdVolume.NewSnapshotByID() for more details.
snapshot.RbdImageName = snapshot.RbdSnapName

return snapshot, nil
}

Expand Down
7 changes: 6 additions & 1 deletion internal/rbd/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,12 @@ func (rv *rbdVolume) NewSnapshotByID(
}
}()

// a new snapshot image will be created, needs to have a unique name
// A new snapshot image will be created, and needs to have a unique
// name.
// FIXME: the journal contains rv.RbdImageName as SourceName. When
// resolving the snapshot image, snap.RbdImageName will be set to the
// original RbdImageName/SourceName (incorrect). This is fixed-up in
// rbdManager.GetSnapshotByID(), this needs to be done cleaner.
snap.RbdImageName = snap.RbdSnapName

err = rv.Connect(cr)
Expand Down

0 comments on commit 7ab7478

Please sign in to comment.