Skip to content

Commit

Permalink
rbd: check for empty lastSyncTime
Browse files Browse the repository at this point in the history
Sometime the json unmarshal might
get success and return empty time
stamp. add a check to make sure the
time is not zero always.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
  • Loading branch information
Madhu-1 authored and mergify[bot] committed Nov 1, 2022
1 parent 1360e0c commit 7c1cbef
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/rbd/replicationcontrollerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,12 @@ func getLastSyncTime(description string) (*timestamppb.Timestamp, error) {
return nil, fmt.Errorf("failed to unmarshal description: %w", err)
}

// If the json unmarsal is successful but the local snapshot time is 0, we
// need to consider it as an error as the LastSyncTime is required.
if localSnapTime.LocalSnapshotTime == 0 {
return nil, fmt.Errorf("%w empty local snapshot timestamp", ErrLastSyncTimeNotFound)
}

lastUpdateTime := time.Unix(localSnapTime.LocalSnapshotTime, 0)
lastSyncTime := timestamppb.New(lastUpdateTime)

Expand Down

0 comments on commit 7c1cbef

Please sign in to comment.