@@ -561,6 +561,7 @@ func (d *Driver) ControllerGetCapabilities(context.Context, *csi.ControllerGetCa
561
561
csi .ControllerServiceCapability_RPC_LIST_VOLUMES ,
562
562
csi .ControllerServiceCapability_RPC_GET_CAPACITY ,
563
563
csi .ControllerServiceCapability_RPC_EXPAND_VOLUME ,
564
+ // csi.ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT, TODO: Uncomment after client implementation is complete.
564
565
}
565
566
566
567
var csc []* csi.ControllerServiceCapability
@@ -589,8 +590,35 @@ func (d *Driver) CreateSnapshot(context.Context, *csi.CreateSnapshotRequest) (*c
589
590
return nil , status .Error (codes .Unimplemented , "" )
590
591
}
591
592
592
- // DeleteSnapshot is part of implementing Snapshot & Restore functionality, but we don't support that
593
- func (d * Driver ) DeleteSnapshot (context.Context , * csi.DeleteSnapshotRequest ) (* csi.DeleteSnapshotResponse , error ) {
593
+ // DeleteSnapshot is part of implementing Snapshot & Restore functionality, and it will be supported in the future.
594
+ func (d * Driver ) DeleteSnapshot (ctx context.Context , req * csi.DeleteSnapshotRequest ) (* csi.DeleteSnapshotResponse , error ) {
595
+ log .Info ().
596
+ Str ("snapshot_id" , req .GetSnapshotId ()).
597
+ Msg ("Request: DeleteSnapshot" )
598
+
599
+ snapshotID := req .GetSnapshotId ()
600
+ if snapshotID == "" {
601
+ return nil , status .Error (codes .InvalidArgument , "must provide SnapshotId to DeleteSnapshot" )
602
+ }
603
+
604
+ log .Debug ().
605
+ Str ("snapshot_id" , snapshotID ).
606
+ Msg ("Deleting snapshot in Civo API" )
607
+
608
+ // TODO: Uncomment after client implementation is complete.
609
+ // _, err := d.CivoClient.DeleteVolumeSnapshot(snapshotID)
610
+ // if err != nil {
611
+ // if strings.Contains(err.Error(), "DatabaseVolumeSnapshotNotFoundError") {
612
+ // log.Info().
613
+ // Str("volume_id", snapshotID).
614
+ // Msg("Snapshot already deleted from Civo API")
615
+ // return &csi.DeleteSnapshotResponse{}, nil
616
+ // } else if strings.Contains(err.Error(), "DatabaseSnapshotCannotDeleteInUseError") {
617
+ // return nil, status.Errorf(codes.FailedPrecondition, "failed to delete snapshot %q, it is currently in use, err: %s", snapshotID, err)
618
+ // }
619
+ // return nil, status.Errorf(codes.Internal, "failed to delete snapshot %q, err: %s", snapshotID, err)
620
+ // }
621
+ // return &csi.DeleteSnapshotResponse{}, nil
594
622
return nil , status .Error (codes .Unimplemented , "" )
595
623
}
596
624
0 commit comments