satellite/metainfo: allow returning delete marker with GetObject
To be compatible with S3 we need to return 'Method Not Allowed' when delete marker is requested and to do this libuplnk needs to know about delete marker. It will be returned only if object version will be specified. Change-Id: I288da5566c74e1b4951f7cd249dbf34622b92e91
This commit is contained in:
parent
d2083281c9
commit
90ed7ca070
@ -392,9 +392,10 @@ func (endpoint *Endpoint) GetObject(ctx context.Context, req *pb.ObjectGetReques
|
|||||||
return nil, endpoint.convertMetabaseErr(err)
|
return nil, endpoint.convertMetabaseErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if mbObject.Status.IsDeleteMarker() {
|
// TODO(ver): initially we returned 'object not found' error if delete marker is returned but
|
||||||
return nil, rpcstatus.Error(rpcstatus.NotFound, "object not found")
|
// S3 HeadObject request in such case requires 'Method Not Allowed' error so libuplink needs
|
||||||
}
|
// to know that delete marker was retured. We can remove this comment when we will know that
|
||||||
|
// there is no better aproach.
|
||||||
|
|
||||||
{
|
{
|
||||||
tags := []eventkit.Tag{
|
tags := []eventkit.Tag{
|
||||||
|
@ -2828,13 +2828,34 @@ func TestEndpoint_Object_No_StorageNodes_Versioning(t *testing.T) {
|
|||||||
Bucket: []byte(bucketName),
|
Bucket: []byte(bucketName),
|
||||||
EncryptedObjectKey: []byte(objects[0].ObjectKey),
|
EncryptedObjectKey: []byte(objects[0].ObjectKey),
|
||||||
})
|
})
|
||||||
|
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, pb.Object_DELETE_MARKER_VERSIONED, response.Object.Status)
|
require.Equal(t, pb.Object_DELETE_MARKER_VERSIONED, response.Object.Status)
|
||||||
|
|
||||||
objects, err = satelliteSys.Metabase.DB.TestingAllObjects(ctx)
|
objects, err = satelliteSys.Metabase.DB.TestingAllObjects(ctx)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Len(t, objects, 3)
|
require.Len(t, objects, 3)
|
||||||
|
|
||||||
|
// version is not set, object not found error
|
||||||
|
_, err = satelliteSys.API.Metainfo.Endpoint.GetObject(ctx, &pb.GetObjectRequest{
|
||||||
|
Header: &pb.RequestHeader{ApiKey: apiKey},
|
||||||
|
Bucket: []byte(bucketName),
|
||||||
|
EncryptedObjectKey: []byte(objects[0].ObjectKey),
|
||||||
|
})
|
||||||
|
require.Error(t, err)
|
||||||
|
require.True(t, errs2.IsRPC(err, rpcstatus.NotFound))
|
||||||
|
|
||||||
|
// with version set we should get object delete marker
|
||||||
|
getResponse, err := satelliteSys.API.Metainfo.Endpoint.GetObject(ctx, &pb.GetObjectRequest{
|
||||||
|
Header: &pb.RequestHeader{ApiKey: apiKey},
|
||||||
|
Bucket: []byte(bucketName),
|
||||||
|
EncryptedObjectKey: []byte(objects[0].ObjectKey),
|
||||||
|
ObjectVersion: response.Object.ObjectVersion,
|
||||||
|
})
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Zero(t, getResponse.Object.PlainSize)
|
||||||
|
require.Zero(t, getResponse.Object.TotalSize)
|
||||||
|
require.Nil(t, getResponse.Object.RedundancyScheme)
|
||||||
|
require.Equal(t, pb.Object_DELETE_MARKER_VERSIONED, getResponse.Object.Status)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user