-
Notifications
You must be signed in to change notification settings - Fork 598
RBD: add snap delete function #5000
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1471,27 +1471,9 @@ func (cs *ControllerServer) DeleteSnapshot( | |
| // Deleting snapshot and cloned volume | ||
| log.DebugLog(ctx, "deleting cloned rbd volume %s", rbdSnap.RbdSnapName) | ||
|
|
||
| rbdVol := rbdSnap.toVolume() | ||
|
|
||
| err = rbdVol.Connect(cr) | ||
| if err != nil { | ||
| return nil, status.Error(codes.Internal, err.Error()) | ||
| } | ||
| defer rbdVol.Destroy(ctx) | ||
|
|
||
| rbdVol.ImageID = rbdSnap.ImageID | ||
| // update parent name to delete the snapshot | ||
| rbdSnap.RbdImageName = rbdVol.RbdImageName | ||
| err = cleanUpSnapshot(ctx, rbdVol, rbdSnap, rbdVol) | ||
| if err != nil { | ||
| log.ErrorLog(ctx, "failed to delete image: %v", err) | ||
|
|
||
| return nil, status.Error(codes.Internal, err.Error()) | ||
| } | ||
| err = undoSnapReservation(ctx, rbdSnap, cr) | ||
| err = rbdSnap.Delete(ctx) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the commit message refers to a cherry-picked commit. Please remove that line, or make sure this PR depends on the PR that adds that commit. |
||
| if err != nil { | ||
| log.ErrorLog(ctx, "failed to remove reservation for snapname (%s) with backing snap (%s) on image (%s) (%s)", | ||
| rbdSnap.RequestName, rbdSnap.RbdSnapName, rbdSnap.RbdImageName, err) | ||
| log.ErrorLog(ctx, "failed to delete rbd snapshot: %s with error: %v", rbdSnap, err) | ||
|
|
||
| return nil, status.Error(codes.Internal, err.Error()) | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -189,6 +189,15 @@ func (cvg *commonVolumeGroup) GetName(ctx context.Context) (string, error) { | |||||||||||||||||
| return cvg.name, nil | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| // GetRequestName returns the requestName of the VolumeGroup. | ||||||||||||||||||
| func (cvg *commonVolumeGroup) GetRequestName(ctx context.Context) (string, error) { | ||||||||||||||||||
| if cvg.requestName == "" { | ||||||||||||||||||
| return "", errors.New("BUG: requestName is not set") | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| return cvg.requestName, nil | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| // GetPool returns the name of the pool that holds the VolumeGroup. | ||||||||||||||||||
| func (cvg *commonVolumeGroup) GetPool(ctx context.Context) (string, error) { | ||||||||||||||||||
| if cvg.pool == "" { | ||||||||||||||||||
|
|
@@ -291,9 +300,9 @@ func (cvg *commonVolumeGroup) Delete(ctx context.Context) error { | |||||||||||||||||
| return fmt.Errorf("failed to get name for volume group %q: %w", cvg, err) | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| csiID, err := cvg.GetID(ctx) | ||||||||||||||||||
| reqName, err := cvg.GetRequestName(ctx) | ||||||||||||||||||
| if err != nil { | ||||||||||||||||||
| return fmt.Errorf("failed to get id for volume group %q: %w", cvg, err) | ||||||||||||||||||
| return fmt.Errorf("failed to get request name for volume group %q: %w", cvg, err) | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| pool, err := cvg.GetPool(ctx) | ||||||||||||||||||
|
|
@@ -306,7 +315,7 @@ func (cvg *commonVolumeGroup) Delete(ctx context.Context) error { | |||||||||||||||||
| return err | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| err = j.UndoReservation(ctx, pool, name, csiID) | ||||||||||||||||||
| err = j.UndoReservation(ctx, pool, name, reqName) | ||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah, looks like
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are ignoring the ceph-csi/internal/journal/voljournal.go Lines 467 to 474 in 83b5454
Let's address this in different PR? @Madhu-1 |
||||||||||||||||||
| if err != nil /* TODO? !errors.Is(..., err) */ { | ||||||||||||||||||
| return fmt.Errorf("failed to undo the reservation for volume group %q: %w", cvg, err) | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a validation of no images in the pool itself.
validateRBDImageCount