mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-17 20:00:23 +00:00
rbd: check for empty lastSyncTime
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>
This commit is contained in:
parent
3cce629b1d
commit
3e1f60244e
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user