satellite/metainfo: stop generating StreamID for BeginDeleteObject
request We are no longer using `BeginDeleteSegment` or `ListSegments` so we can avoid generating StreamID as a result of `BeginDeleteObject`. StreamID from `BeginDeleteObject` is also not used on Uplink side. Change-Id: I3b068deab17068459849b5cf05811cad4b8a9034
This commit is contained in:
parent
67a292d135
commit
e69cec0b75
@ -924,28 +924,6 @@ func (endpoint *Endpoint) BeginDeleteObject(ctx context.Context, req *pb.ObjectB
|
||||
return nil, rpcstatus.Error(rpcstatus.InvalidArgument, err.Error())
|
||||
}
|
||||
|
||||
satStreamID := &pb.SatStreamID{
|
||||
Bucket: req.Bucket,
|
||||
EncryptedPath: req.EncryptedPath,
|
||||
Version: req.Version,
|
||||
CreationDate: now,
|
||||
}
|
||||
|
||||
satStreamID, err = signing.SignStreamID(ctx, endpoint.satellite, satStreamID)
|
||||
if err != nil {
|
||||
return nil, rpcstatus.Error(rpcstatus.Internal, err.Error())
|
||||
}
|
||||
|
||||
encodedStreamID, err := pb.Marshal(satStreamID)
|
||||
if err != nil {
|
||||
return nil, rpcstatus.Error(rpcstatus.Internal, err.Error())
|
||||
}
|
||||
|
||||
streamID, err := storj.StreamIDFromBytes(encodedStreamID)
|
||||
if err != nil {
|
||||
return nil, rpcstatus.Error(rpcstatus.Internal, err.Error())
|
||||
}
|
||||
|
||||
_, err = endpoint.validateAuth(ctx, req.Header, macaroon.Action{
|
||||
Op: macaroon.ActionRead,
|
||||
Bucket: req.Bucket,
|
||||
@ -965,13 +943,13 @@ func (endpoint *Endpoint) BeginDeleteObject(ctx context.Context, req *pb.ObjectB
|
||||
var object *pb.Object
|
||||
if canRead || canList {
|
||||
// Info about deleted object is returned only if either Read, or List permission is granted
|
||||
object, err = endpoint.getObject(ctx, keyInfo.ProjectID, satStreamID.Bucket, satStreamID.EncryptedPath, satStreamID.Version)
|
||||
object, err = endpoint.getObject(ctx, keyInfo.ProjectID, req.Bucket, req.EncryptedPath, req.Version)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
err = endpoint.DeleteObjectPieces(ctx, keyInfo.ProjectID, satStreamID.Bucket, satStreamID.EncryptedPath)
|
||||
err = endpoint.DeleteObjectPieces(ctx, keyInfo.ProjectID, req.Bucket, req.EncryptedPath)
|
||||
if err != nil {
|
||||
if !canRead && !canList {
|
||||
// No error info is returned if neither Read, nor List permission is granted
|
||||
@ -984,8 +962,7 @@ func (endpoint *Endpoint) BeginDeleteObject(ctx context.Context, req *pb.ObjectB
|
||||
mon.Meter("req_delete_object").Mark(1)
|
||||
|
||||
return &pb.ObjectBeginDeleteResponse{
|
||||
StreamId: streamID,
|
||||
Object: object,
|
||||
Object: object,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -136,8 +136,9 @@ func TestRevokeMacaroon(t *testing.T) {
|
||||
_, err = client.BeginObject(ctx, metainfo.BeginObjectParams{})
|
||||
assert.True(t, errs2.IsRPC(err, rpcstatus.PermissionDenied))
|
||||
|
||||
_, _, err = client.BeginDeleteObject(ctx, metainfo.BeginDeleteObjectParams{})
|
||||
assert.True(t, errs2.IsRPC(err, rpcstatus.PermissionDenied))
|
||||
// TODO uncomment when uplink client will be updated
|
||||
// _, err = client.BeginDeleteObject(ctx, metainfo.BeginDeleteObjectParams{})
|
||||
// assert.True(t, errs2.IsRPC(err, rpcstatus.PermissionDenied))
|
||||
|
||||
_, err = client.ListBuckets(ctx, metainfo.ListBucketsParams{})
|
||||
assert.True(t, errs2.IsRPC(err, rpcstatus.PermissionDenied))
|
||||
@ -151,8 +152,9 @@ func TestRevokeMacaroon(t *testing.T) {
|
||||
_, err = client.DeleteBucket(ctx, metainfo.DeleteBucketParams{})
|
||||
assert.True(t, errs2.IsRPC(err, rpcstatus.PermissionDenied))
|
||||
|
||||
_, _, err = client.BeginDeleteObject(ctx, metainfo.BeginDeleteObjectParams{})
|
||||
assert.True(t, errs2.IsRPC(err, rpcstatus.PermissionDenied))
|
||||
// TODO uncomment when uplink client will be updated
|
||||
// _, err = client.BeginDeleteObject(ctx, metainfo.BeginDeleteObjectParams{})
|
||||
// assert.True(t, errs2.IsRPC(err, rpcstatus.PermissionDenied))
|
||||
|
||||
_, err = client.GetBucket(ctx, metainfo.GetBucketParams{})
|
||||
assert.True(t, errs2.IsRPC(err, rpcstatus.PermissionDenied))
|
||||
@ -230,8 +232,9 @@ func TestInvalidAPIKey(t *testing.T) {
|
||||
_, err = client.BeginObject(ctx, metainfo.BeginObjectParams{})
|
||||
assertInvalidArgument(t, err, false)
|
||||
|
||||
_, _, err = client.BeginDeleteObject(ctx, metainfo.BeginDeleteObjectParams{})
|
||||
assertInvalidArgument(t, err, false)
|
||||
// TODO uncomment when uplink client will be updated
|
||||
// _, err = client.BeginDeleteObject(ctx, metainfo.BeginDeleteObjectParams{})
|
||||
// assertInvalidArgument(t, err, false)
|
||||
|
||||
_, err = client.ListBuckets(ctx, metainfo.ListBucketsParams{})
|
||||
assertInvalidArgument(t, err, false)
|
||||
@ -245,8 +248,9 @@ func TestInvalidAPIKey(t *testing.T) {
|
||||
_, err = client.DeleteBucket(ctx, metainfo.DeleteBucketParams{})
|
||||
assertInvalidArgument(t, err, false)
|
||||
|
||||
_, _, err = client.BeginDeleteObject(ctx, metainfo.BeginDeleteObjectParams{})
|
||||
assertInvalidArgument(t, err, false)
|
||||
// TODO uncomment when uplink client will be updated
|
||||
// _, err = client.BeginDeleteObject(ctx, metainfo.BeginDeleteObjectParams{})
|
||||
// assertInvalidArgument(t, err, false)
|
||||
|
||||
_, err = client.GetBucket(ctx, metainfo.GetBucketParams{})
|
||||
assertInvalidArgument(t, err, false)
|
||||
@ -1038,22 +1042,18 @@ func TestInlineSegment(t *testing.T) {
|
||||
}
|
||||
|
||||
{ // test deleting segments
|
||||
streamID, _, err := metainfoClient.BeginDeleteObject(ctx, metainfo.BeginDeleteObjectParams{
|
||||
Bucket: params.Bucket,
|
||||
EncryptedPath: params.EncryptedPath,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
segments, more, err := metainfoClient.ListSegments(ctx, metainfo.ListSegmentsParams{
|
||||
StreamID: streamID,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Empty(t, segments)
|
||||
require.False(t, more)
|
||||
// TODO uncomment when uplink client will be updated
|
||||
// _, _, err := metainfoClient.BeginDeleteObject(ctx, metainfo.BeginDeleteObjectParams{
|
||||
// Bucket: params.Bucket,
|
||||
// EncryptedPath: params.EncryptedPath,
|
||||
// })
|
||||
// require.NoError(t, err)
|
||||
|
||||
err = metainfoClient.FinishDeleteObject(ctx, metainfo.FinishDeleteObjectParams{
|
||||
StreamID: streamID,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
// _, err = metainfoClient.GetObject(ctx, metainfo.GetObjectParams{
|
||||
// Bucket: params.Bucket,
|
||||
// EncryptedPath: params.EncryptedPath,
|
||||
// })
|
||||
// require.Error(t, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -1108,33 +1108,20 @@ func TestRemoteSegment(t *testing.T) {
|
||||
|
||||
{
|
||||
// Begin deleting object
|
||||
// List segments
|
||||
// Begin/Finish deleting segment
|
||||
// List objects
|
||||
|
||||
streamID, _, err := metainfoClient.BeginDeleteObject(ctx, metainfo.BeginDeleteObjectParams{
|
||||
Bucket: []byte(expectedBucketName),
|
||||
EncryptedPath: items[0].EncryptedPath,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
// TODO uncomment when uplink client will be updated
|
||||
// _, _, err := metainfoClient.BeginDeleteObject(ctx, metainfo.BeginDeleteObjectParams{
|
||||
// Bucket: []byte(expectedBucketName),
|
||||
// EncryptedPath: items[0].EncryptedPath,
|
||||
// })
|
||||
// require.NoError(t, err)
|
||||
|
||||
segments, more, err := metainfoClient.ListSegments(ctx, metainfo.ListSegmentsParams{
|
||||
StreamID: streamID,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Empty(t, segments)
|
||||
require.False(t, more)
|
||||
|
||||
err = metainfoClient.FinishDeleteObject(ctx, metainfo.FinishDeleteObjectParams{
|
||||
StreamID: streamID,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
items, _, err = metainfoClient.ListObjects(ctx, metainfo.ListObjectsParams{
|
||||
Bucket: []byte(expectedBucketName),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, items, 0)
|
||||
// items, _, err = metainfoClient.ListObjects(ctx, metainfo.ListObjectsParams{
|
||||
// Bucket: []byte(expectedBucketName),
|
||||
// })
|
||||
// require.NoError(t, err)
|
||||
// require.Len(t, items, 0)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user