Skip to content

Commit 63b7a71

Browse files
committed
Fix failing createSnapshot and ListSnapshots sanity tests
1 parent 36eb64b commit 63b7a71

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Diff for: pkg/driver/controller_server.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ func (d *Driver) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshotRequ
632632
Str("source_volume_id", sourceVolID).
633633
Msg("Finding current snapshot in Civo API")
634634

635-
snapshots, err := d.CivoClient.ListVolumeSnapshotsByVolumeID(sourceVolID)
635+
snapshots, err := d.CivoClient.ListVolumeSnapshots()
636636
if err != nil {
637637
log.Error().
638638
Str("source_volume_id", sourceVolID).
@@ -769,7 +769,7 @@ func (d *Driver) ListSnapshots(ctx context.Context, req *csi.ListSnapshotsReques
769769

770770
snapshot, err := d.CivoClient.GetVolumeSnapshotByVolumeID(sourceVolumeID, snapshotID)
771771
if err != nil {
772-
if strings.Contains(err.Error(), "DatabaseSnapshotNotFoundError") {
772+
if strings.Contains(err.Error(), "DatabaseSnapshotNotFoundError") || strings.Contains(err.Error(), "ZeroMatchesError"){
773773
log.Info().
774774
Str("snapshot_id", snapshotID).
775775
Str("source_volume_id", sourceVolumeID).
@@ -807,7 +807,7 @@ func (d *Driver) ListSnapshots(ctx context.Context, req *csi.ListSnapshotsReques
807807

808808
snapshot, err := d.CivoClient.GetVolumeSnapshot(snapshotID)
809809
if err != nil {
810-
if strings.Contains(err.Error(), "DatabaseSnapshotNotFoundError") {
810+
if strings.Contains(err.Error(), "DatabaseSnapshotNotFoundError") || strings.Contains(err.Error(), "ZeroMatchesError"){
811811
log.Info().
812812
Str("snapshot_id", snapshotID).
813813
Msg("ListSnapshots: no snapshot found, returning with success")
@@ -940,6 +940,9 @@ func ConvertSnapshot(in *civogo.VolumeSnapshot) (*csi.ListSnapshotsResponse_Entr
940940

941941
// ParseTimeToProtoTimestamp parses a time string in RFC3339 format to *timestamppb.Timestamp.
942942
func ParseTimeToProtoTimestamp(timeStr string) (*timestamppb.Timestamp, error) {
943+
if timeStr == ""{
944+
return nil, nil
945+
}
943946
t, err := time.Parse(time.RFC3339, timeStr)
944947
// Only return an error if timeStr is not empty
945948
if err != nil && timeStr != "" {

0 commit comments

Comments
 (0)