satellite/metainfo: use default_placement of project during bucket creation
https://github.com/storj/storj/issues/5879 Change-Id: I100e834b3b625b3e0ff00cdcb7675ec6bb570992
This commit is contained in:
parent
2ea6ca9c18
commit
e4b8febda7
@ -110,6 +110,7 @@ func (endpoint *Endpoint) CreateBucket(ctx context.Context, req *pb.BucketCreate
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, rpcstatus.Error(rpcstatus.InvalidArgument, err.Error())
|
return nil, rpcstatus.Error(rpcstatus.InvalidArgument, err.Error())
|
||||||
}
|
}
|
||||||
|
bucketReq.Placement = project.DefaultPlacement
|
||||||
|
|
||||||
bucket, err := endpoint.buckets.CreateBucket(ctx, bucketReq)
|
bucket, err := endpoint.buckets.CreateBucket(ctx, bucketReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -258,3 +258,31 @@ func TestListBucketsWithAttribution(t *testing.T) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestBucketCreationWithDefaultPlacement(t *testing.T) {
|
||||||
|
testplanet.Run(t, testplanet.Config{
|
||||||
|
SatelliteCount: 1, UplinkCount: 1,
|
||||||
|
}, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) {
|
||||||
|
projectID := planet.Uplinks[0].Projects[0].ID
|
||||||
|
|
||||||
|
// change the default_placement of the project
|
||||||
|
project, err := planet.Satellites[0].API.DB.Console().Projects().Get(ctx, projectID)
|
||||||
|
project.DefaultPlacement = storj.EU
|
||||||
|
require.NoError(t, err)
|
||||||
|
err = planet.Satellites[0].API.DB.Console().Projects().Update(ctx, project)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
// create a new bucket
|
||||||
|
up, err := planet.Uplinks[0].GetProject(ctx, planet.Satellites[0])
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
_, err = up.CreateBucket(ctx, "eu1")
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
// check if placement is set
|
||||||
|
placement, err := planet.Satellites[0].API.DB.Buckets().GetBucketPlacement(ctx, []byte("eu1"), projectID)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, storj.EU, placement)
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
@ -206,6 +206,9 @@ func (projects *projects) Update(ctx context.Context, project *console.Project)
|
|||||||
updateFields.SegmentLimit = dbx.Project_SegmentLimit(*project.SegmentLimit)
|
updateFields.SegmentLimit = dbx.Project_SegmentLimit(*project.SegmentLimit)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if project.DefaultPlacement > 0 {
|
||||||
|
updateFields.DefaultPlacement = dbx.Project_DefaultPlacement(int(project.DefaultPlacement))
|
||||||
|
}
|
||||||
_, err = projects.db.Update_Project_By_Id(ctx,
|
_, err = projects.db.Update_Project_By_Id(ctx,
|
||||||
dbx.Project_Id(project.ID[:]),
|
dbx.Project_Id(project.ID[:]),
|
||||||
updateFields)
|
updateFields)
|
||||||
|
Loading…
Reference in New Issue
Block a user