Skip to content

Commit

Permalink
Merge pull request #622 from versity/ben/glacier_mode_fix
Browse files Browse the repository at this point in the history
fix: restore object request handler and scoutfs glacier enable
  • Loading branch information
benmcclelland authored Jun 11, 2024
2 parents 034feb7 + 8fa2b58 commit d98ca9b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 34 deletions.
13 changes: 7 additions & 6 deletions backend/scoutfs/scoutfs_compat.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@ func New(rootdir string, opts ScoutfsOpts) (*ScoutFS, error) {
}

return &ScoutFS{
Posix: p,
rootfd: f,
rootdir: rootdir,
meta: metastore,
chownuid: opts.ChownUID,
chowngid: opts.ChownGID,
Posix: p,
rootfd: f,
rootdir: rootdir,
meta: metastore,
chownuid: opts.ChownUID,
chowngid: opts.ChownGID,
glaciermode: opts.GlacierMode,
}, nil
}

Expand Down
34 changes: 16 additions & 18 deletions s3api/controllers/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -2548,23 +2548,20 @@ func (c S3ApiController) CreateActions(ctx *fiber.Ctx) error {
key = key + "/"
}

var restoreRequest s3.RestoreObjectInput
if ctx.Request().URI().QueryArgs().Has("restore") {
err := xml.Unmarshal(ctx.Body(), &restoreRequest)
if err != nil {
if c.debug {
log.Printf("error unmarshalling restore object: %v", err)
var restoreRequest types.RestoreRequest
if err := xml.Unmarshal(ctx.Body(), &restoreRequest); err != nil {
if !errors.Is(io.EOF, err) {
return SendResponse(ctx, s3err.GetAPIError(s3err.ErrMalformedXML),
&MetaOpts{
Logger: c.logger,
MetricsMng: c.mm,
Action: metrics.ActionRestoreObject,
BucketOwner: parsedAcl.Owner,
})
}
return SendResponse(ctx, err,
&MetaOpts{
Logger: c.logger,
MetricsMng: c.mm,
Action: metrics.ActionRestoreObject,
BucketOwner: parsedAcl.Owner,
})
}

err = auth.VerifyAccess(ctx.Context(), c.be,
err := auth.VerifyAccess(ctx.Context(), c.be,
auth.AccessOptions{
Readonly: c.readonly,
Acl: parsedAcl,
Expand All @@ -2585,10 +2582,11 @@ func (c S3ApiController) CreateActions(ctx *fiber.Ctx) error {
})
}

restoreRequest.Bucket = &bucket
restoreRequest.Key = &key

err = c.be.RestoreObject(ctx.Context(), &restoreRequest)
err = c.be.RestoreObject(ctx.Context(), &s3.RestoreObjectInput{
Bucket: &bucket,
Key: &key,
RestoreRequest: &restoreRequest,
})
return SendResponse(ctx, err,
&MetaOpts{
Logger: c.logger,
Expand Down
11 changes: 1 addition & 10 deletions s3api/controllers/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1646,20 +1646,11 @@ func TestS3ApiController_CreateActions(t *testing.T) {
{
name: "Restore-object-success",
app: app,
args: args{
req: httptest.NewRequest(http.MethodPost, "/my-bucket/my-key?restore", strings.NewReader(`<root><key>body</key></root>`)),
},
wantErr: false,
statusCode: 200,
},
{
name: "Restore-object-error",
app: app,
args: args{
req: httptest.NewRequest(http.MethodPost, "/my-bucket/my-key?restore", nil),
},
wantErr: false,
statusCode: 500,
statusCode: 200,
},
{
name: "Select-object-content-invalid-body",
Expand Down

0 comments on commit d98ca9b

Please sign in to comment.