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

Add DeleteSnapshot handler for VolumeSnapshot support #33

Merged
merged 7 commits into from
Nov 27, 2024
Merged
Changes from 6 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
28 changes: 27 additions & 1 deletion pkg/driver/controller_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ func (d *Driver) ControllerGetCapabilities(context.Context, *csi.ControllerGetCa
csi.ControllerServiceCapability_RPC_LIST_VOLUMES,
csi.ControllerServiceCapability_RPC_GET_CAPACITY,
csi.ControllerServiceCapability_RPC_EXPAND_VOLUME,
// csi.ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT, TODO: Uncomment after client implementation is complete.
}

var csc []*csi.ControllerServiceCapability
Expand Down Expand Up @@ -590,7 +591,32 @@ func (d *Driver) CreateSnapshot(context.Context, *csi.CreateSnapshotRequest) (*c
}

// DeleteSnapshot is part of implementing Snapshot & Restore functionality, but we don't support that
Copy link
Contributor

Choose a reason for hiding this comment

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

Should "but we don't support that" be removed from the comment now?

Copy link
Member Author

Choose a reason for hiding this comment

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

@Praveen005

Thank you for your comment 🙏
I agree; this should be revised! However, removing it entirely might suggest that this feature is already supported, so I believe it would be better to adjust the phrasing.
How about the following comment? 🤔

DeleteSnapshot is part of implementing Snapshot & Restore functionality, and it will be supported in the future.

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good, but will have to be updated later.

something like, "// DeleteSnapshot is implemented to support Snapshot & Restore functionality, allowing snapshots to be deleted as needed." can work too. As this code will be merged only when all pieces are in place I guess. what do you say?

Copy link
Member Author

@hlts2 hlts2 Nov 26, 2024

Choose a reason for hiding this comment

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

Yes, it looks good to me! Thank you 🙏

As this code will be merged only when all pieces are in place I guess. what do you say?

I was talking with Ryota about this point. Since this implementation does not particularly affect the existing behavior, we can merge this PR!

func (d *Driver) DeleteSnapshot(context.Context, *csi.DeleteSnapshotRequest) (*csi.DeleteSnapshotResponse, error) {
func (d *Driver) DeleteSnapshot(ctx context.Context, req *csi.DeleteSnapshotRequest) (*csi.DeleteSnapshotResponse, error) {
log.Info().
Str("snapshot_id", req.GetSnapshotId()).
Msg("Request: DeleteSnapshot")

snapshotID := req.GetSnapshotId()
if snapshotID == "" {
return nil, status.Error(codes.InvalidArgument, "must provide SnapshotId to DeleteSnapshot")
}

log.Debug().
Str("snapshot_id", snapshotID).
Msg("Deleting snapshot in Civo API")

// TODO: Uncomment after client implementation is complete.
// _, err := d.CivoClient.DeleteVolumeSnapshot(snapshotID)
// if err != nil {
// if strings.Contains(err.Error(), "DatabaseVolumeSnapshotNotFoundError") {
// log.Info().
// Str("volume_id", snapshotID).
// Msg("Snapshot already deleted from Civo API")
// return &csi.DeleteSnapshotResponse{}, nil
// }
// return nil, status.Errorf(codes.Internal, "failed to delete snapshot %q, err: %s", snapshotID, err)
// }
// return &csi.DeleteSnapshotResponse{}, nil
return nil, status.Error(codes.Unimplemented, "")
}

Expand Down
Loading