mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-01-18 02:39:30 +00:00
Merge pull request #189 from Madhu-1/close-2165941
BUG 2165941: rbd: discard not found error from GetMetadata
This commit is contained in:
commit
ac04e66293
@ -513,6 +513,7 @@ func (rs *ReplicationServer) DemoteVolume(ctx context.Context,
|
|||||||
// store the image creation time for resync
|
// store the image creation time for resync
|
||||||
_, err = rbdVol.GetMetadata(imageCreationTimeKey)
|
_, err = rbdVol.GetMetadata(imageCreationTimeKey)
|
||||||
if err != nil && errors.Is(err, librbd.ErrNotFound) {
|
if err != nil && errors.Is(err, librbd.ErrNotFound) {
|
||||||
|
log.DebugLog(ctx, "setting image creation time %s for %s", creationTime, rbdVol)
|
||||||
err = rbdVol.SetMetadata(imageCreationTimeKey, timestampToString(creationTime))
|
err = rbdVol.SetMetadata(imageCreationTimeKey, timestampToString(creationTime))
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -670,8 +671,11 @@ func (rs *ReplicationServer) ResyncVolume(ctx context.Context,
|
|||||||
|
|
||||||
// image creation time is stored in the image metadata. it looks like
|
// image creation time is stored in the image metadata. it looks like
|
||||||
// `"seconds:1692879841 nanos:631526669"`
|
// `"seconds:1692879841 nanos:631526669"`
|
||||||
|
// If the image gets resynced the local image creation time will be
|
||||||
|
// lost, if the keys is not present in the image metadata then we can
|
||||||
|
// assume that the image is already resynced.
|
||||||
savedImageTime, err := rbdVol.GetMetadata(imageCreationTimeKey)
|
savedImageTime, err := rbdVol.GetMetadata(imageCreationTimeKey)
|
||||||
if err != nil {
|
if err != nil && !errors.Is(err, librbd.ErrNotFound) {
|
||||||
return nil, status.Errorf(codes.Internal,
|
return nil, status.Errorf(codes.Internal,
|
||||||
"failed to get %s key from image metadata for %s: %s",
|
"failed to get %s key from image metadata for %s: %s",
|
||||||
imageCreationTimeKey,
|
imageCreationTimeKey,
|
||||||
@ -679,18 +683,19 @@ func (rs *ReplicationServer) ResyncVolume(ctx context.Context,
|
|||||||
err.Error())
|
err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
st, err := timestampFromString(savedImageTime)
|
if savedImageTime != "" {
|
||||||
if err != nil {
|
st, sErr := timestampFromString(savedImageTime)
|
||||||
return nil, status.Errorf(codes.Internal, "failed to parse image creation time: %s", err.Error())
|
if sErr != nil {
|
||||||
|
return nil, status.Errorf(codes.Internal, "failed to parse image creation time: %s", sErr.Error())
|
||||||
}
|
}
|
||||||
log.DebugLog(ctx, "image %s, savedImageTime=%v, currentImageTime=%v", rbdVol, st, creationTime.AsTime())
|
log.DebugLog(ctx, "image %s, savedImageTime=%v, currentImageTime=%v", rbdVol, st, creationTime.AsTime())
|
||||||
|
|
||||||
if req.Force && st.Equal(creationTime.AsTime()) {
|
if req.Force && st.Equal(creationTime.AsTime()) {
|
||||||
err = rbdVol.ResyncVol(localStatus)
|
err = rbdVol.ResyncVol(localStatus)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, getGRPCError(err)
|
return nil, getGRPCError(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if !ready {
|
if !ready {
|
||||||
err = checkVolumeResyncStatus(localStatus)
|
err = checkVolumeResyncStatus(localStatus)
|
||||||
|
Loading…
Reference in New Issue
Block a user