satellite/metainfo: wire versioning with commit object operation

Change-Id: Ib19b5bade69dfb3f02256c638cc2f6281befa415
This commit is contained in:
Michal Niewrzal 2023-11-03 16:37:57 +01:00 committed by Michał Niewrzał
parent 539b32d01e
commit c9430c22b5
6 changed files with 111 additions and 41 deletions

View File

@ -1,5 +1,5 @@
// Code generated by protoc-gen-go-drpc. DO NOT EDIT. // Code generated by protoc-gen-go-drpc. DO NOT EDIT.
// protoc-gen-go-drpc version: v0.0.28 // protoc-gen-go-drpc version: v0.0.33
// source: delegated_repair.proto // source: delegated_repair.proto
package internalpb package internalpb

View File

@ -39,6 +39,7 @@ type StreamID struct {
// temporary field to determine if we should go with new pending_objects table or // temporary field to determine if we should go with new pending_objects table or
// fallback to pending object in objects table. // fallback to pending object in objects table.
UsePendingObjectsTable bool `protobuf:"varint,14,opt,name=use_pending_objects_table,json=usePendingObjectsTable,proto3" json:"use_pending_objects_table,omitempty"` UsePendingObjectsTable bool `protobuf:"varint,14,opt,name=use_pending_objects_table,json=usePendingObjectsTable,proto3" json:"use_pending_objects_table,omitempty"`
Versioned bool `protobuf:"varint,15,opt,name=versioned,proto3" json:"versioned,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@ -145,6 +146,13 @@ func (m *StreamID) GetUsePendingObjectsTable() bool {
return false return false
} }
func (m *StreamID) GetVersioned() bool {
if m != nil {
return m.Versioned
}
return false
}
type SegmentID struct { type SegmentID struct {
StreamId *StreamID `protobuf:"bytes,1,opt,name=stream_id,json=streamId,proto3" json:"stream_id,omitempty"` StreamId *StreamID `protobuf:"bytes,1,opt,name=stream_id,json=streamId,proto3" json:"stream_id,omitempty"`
PartNumber int32 `protobuf:"varint,2,opt,name=part_number,json=partNumber,proto3" json:"part_number,omitempty"` PartNumber int32 `protobuf:"varint,2,opt,name=part_number,json=partNumber,proto3" json:"part_number,omitempty"`
@ -232,42 +240,42 @@ func init() {
func init() { proto.RegisterFile("metainfo_sat.proto", fileDescriptor_47c60bd892d94aaf) } func init() { proto.RegisterFile("metainfo_sat.proto", fileDescriptor_47c60bd892d94aaf) }
var fileDescriptor_47c60bd892d94aaf = []byte{ var fileDescriptor_47c60bd892d94aaf = []byte{
// 580 bytes of a gzipped FileDescriptorProto // 589 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x52, 0xcb, 0x6e, 0xd3, 0x40, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x52, 0xcb, 0x6e, 0xd4, 0x30,
0x14, 0xc5, 0x84, 0xa4, 0xc9, 0x24, 0x7d, 0x68, 0xfa, 0xd0, 0x10, 0x8a, 0x62, 0x15, 0x21, 0x99, 0x14, 0x25, 0x0c, 0x33, 0x9d, 0xf1, 0x4c, 0x3b, 0x95, 0xfb, 0x90, 0x29, 0x45, 0x13, 0x15, 0x21,
0x8d, 0x8d, 0xda, 0x55, 0x97, 0x44, 0x61, 0x11, 0xf1, 0x68, 0x70, 0xca, 0x86, 0x8d, 0x35, 0xb6, 0x0d, 0x9b, 0x04, 0xb5, 0xab, 0x2e, 0xa9, 0x86, 0xc5, 0x88, 0x47, 0x4b, 0x5a, 0x36, 0x6c, 0x22,
0x6f, 0xad, 0x69, 0xed, 0x19, 0x6b, 0x66, 0x8c, 0x9a, 0x25, 0x7f, 0xc0, 0xaf, 0xf0, 0x17, 0x7c, 0x27, 0xbe, 0x8d, 0xdc, 0x26, 0x76, 0x64, 0x3b, 0xa8, 0x5d, 0xf2, 0x07, 0x7c, 0x16, 0x3b, 0xf6,
0x03, 0x8b, 0xf2, 0x2b, 0xc8, 0xe3, 0x47, 0x22, 0xd1, 0x2e, 0x60, 0x37, 0xf7, 0xdc, 0x33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4, 0xa7, 0x2f, 0xbf, 0xbc, 0xef, 0x4b, 0x56, 0xb0, 0xd5, 0xdc, 0xed, 0xb0, 0x7b, 0x12, 0xb9, 0xf6, 0xdf, 0x89, 0x7c, 0x20,
0x50, 0x5a, 0xc8, 0x6b, 0x97, 0x09, 0xcf, 0x1c, 0xbc, 0x96, 0xe4, 0x31, 0xae, 0x41, 0x72, 0x9a, 0x17, 0xc3, 0x87, 0x72, 0x71, 0xf2, 0xf2, 0xcb, 0x0b, 0x6d, 0xa4, 0xba, 0xf2, 0xb8, 0xf4, 0xed,
0xe6, 0x61, 0xd8, 0x33, 0x1e, 0xce, 0xfe, 0x04, 0x00, 0x00, 0xff, 0xff, 0xec, 0x7c, 0xdf, 0x4d, 0xc1, 0x6f, 0x49, 0x3e, 0x17, 0x06, 0x94, 0xa0, 0x69, 0x1e, 0x45, 0x03, 0xab, 0xe1, 0xe8, 0x4f,
0x5e, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x81, 0xe3, 0xf1, 0xc8, 0x7c, 0x04, 0x00, 0x00,
} }

View File

@ -32,6 +32,8 @@ message StreamID {
// temporary field to determine if we should go with new pending_objects table or // temporary field to determine if we should go with new pending_objects table or
// fallback to pending object in objects table. // fallback to pending object in objects table.
bool use_pending_objects_table = 14; bool use_pending_objects_table = 14;
bool versioned = 15;
} }
message SegmentID { message SegmentID {

View File

@ -107,7 +107,7 @@ func (endpoint *Endpoint) BeginObject(ctx context.Context, req *pb.ObjectBeginRe
} }
// TODO this needs to be optimized to avoid DB call on each request // TODO this needs to be optimized to avoid DB call on each request
placement, err := endpoint.buckets.GetBucketPlacement(ctx, req.Bucket, keyInfo.ProjectID) bucket, err := endpoint.buckets.GetBucket(ctx, req.Bucket, keyInfo.ProjectID)
if err != nil { if err != nil {
if buckets.ErrBucketNotFound.Has(err) { if buckets.ErrBucketNotFound.Has(err) {
return nil, rpcstatus.Errorf(rpcstatus.NotFound, "bucket not found: %s", req.Bucket) return nil, rpcstatus.Errorf(rpcstatus.NotFound, "bucket not found: %s", req.Bucket)
@ -174,7 +174,8 @@ func (endpoint *Endpoint) BeginObject(ctx context.Context, req *pb.ObjectBeginRe
StreamId: object.StreamID[:], StreamId: object.StreamID[:],
MultipartObject: object.FixedSegmentSize <= 0, MultipartObject: object.FixedSegmentSize <= 0,
EncryptionParameters: req.EncryptionParameters, EncryptionParameters: req.EncryptionParameters,
Placement: int32(placement), Placement: int32(bucket.Placement),
Versioned: bucket.Versioning == buckets.VersioningEnabled,
UsePendingObjectsTable: usePendingObjectsTable, UsePendingObjectsTable: usePendingObjectsTable,
}) })
@ -295,6 +296,8 @@ func (endpoint *Endpoint) CommitObject(ctx context.Context, req *pb.ObjectCommit
DisallowDelete: !allowDelete, DisallowDelete: !allowDelete,
UsePendingObjectsTable: streamID.UsePendingObjectsTable, UsePendingObjectsTable: streamID.UsePendingObjectsTable,
Versioned: streamID.Versioned,
} }
// uplink can send empty metadata with not empty key/nonce // uplink can send empty metadata with not empty key/nonce
// we need to fix it on uplink side but that part will be // we need to fix it on uplink side but that part will be

View File

@ -3111,3 +3111,59 @@ func TestNodeTagPlacement(t *testing.T) {
}, },
) )
} }
func TestEndpoint_Object_No_StorageNodes_Versioning(t *testing.T) {
testplanet.Run(t, testplanet.Config{
SatelliteCount: 1, UplinkCount: 1,
Reconfigure: testplanet.Reconfigure{
Satellite: func(log *zap.Logger, index int, config *satellite.Config) {
config.Metainfo.UseBucketLevelObjectVersioning = true
},
},
}, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) {
satelliteSys := planet.Satellites[0]
apiKey := planet.Uplinks[0].APIKey[planet.Satellites[0].ID()].SerializeRaw()
projectID := planet.Uplinks[0].Projects[0].ID
bucketName := "versioned-bucket"
objectKey := "versioned-object"
createBucket := func(name string) error {
_, err := satelliteSys.API.Metainfo.Endpoint.CreateBucket(ctx, &pb.CreateBucketRequest{
Header: &pb.RequestHeader{ApiKey: apiKey},
Name: []byte(name),
})
if err != nil {
return err
}
return satelliteSys.API.DB.Buckets().EnableBucketVersioning(ctx, []byte(bucketName), projectID)
}
deleteBucket := func(name string) func() error {
return func() error {
_, err := satelliteSys.API.Metainfo.Endpoint.DeleteBucket(ctx, &pb.DeleteBucketRequest{
Header: &pb.RequestHeader{ApiKey: apiKey},
Name: []byte(name),
DeleteAll: true,
})
return err
}
}
t.Run("object with 2 versions", func(t *testing.T) {
defer ctx.Check(deleteBucket(bucketName))
require.NoError(t, createBucket(bucketName))
err := planet.Uplinks[0].Upload(ctx, satelliteSys, bucketName, objectKey, testrand.Bytes(100))
require.NoError(t, err)
err = planet.Uplinks[0].Upload(ctx, satelliteSys, bucketName, objectKey, testrand.Bytes(100))
require.NoError(t, err)
objects, err := satelliteSys.Metabase.DB.TestingAllObjects(ctx)
require.NoError(t, err)
require.Len(t, objects, 2)
})
})
}

View File

@ -355,6 +355,7 @@ func convertDBXtoBucket(dbxBucket *dbx.BucketMetainfo) (bucket buckets.Bucket, e
CipherSuite: storj.CipherSuite(dbxBucket.DefaultEncryptionCipherSuite), CipherSuite: storj.CipherSuite(dbxBucket.DefaultEncryptionCipherSuite),
BlockSize: int32(dbxBucket.DefaultEncryptionBlockSize), BlockSize: int32(dbxBucket.DefaultEncryptionBlockSize),
}, },
Versioning: buckets.Versioning(dbxBucket.Versioning),
} }
if dbxBucket.Placement != nil { if dbxBucket.Placement != nil {