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 committed Nov 2, 2022
1 parent 9f58c0a commit 642daa6
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("empty local snapshot timestamp: %w", ErrLastSyncTimeNotFound)
}

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

Expand Down

0 comments on commit 642daa6

Please sign in to comment.