From 20638aee49d33f227c908eca0cfd5aec7dc40289 Mon Sep 17 00:00:00 2001 From: Ben McClelland Date: Wed, 14 Jun 2023 08:42:37 -0700 Subject: [PATCH 1/2] fix: linux otmp object and part uploads We were missing the object and directory name in the O_TMPFILE uploads, so were incorrectly trying to link these into the top level directory. --- backend/posix/posix_linux.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/posix/posix_linux.go b/backend/posix/posix_linux.go index abc41ce2..accf4ad8 100644 --- a/backend/posix/posix_linux.go +++ b/backend/posix/posix_linux.go @@ -68,7 +68,7 @@ func openTmpFile(dir, bucket, obj string, size int64) (*tmpfile, error) { // later to link file into namespace f := os.NewFile(uintptr(fd), filepath.Join(procfddir, strconv.Itoa(fd))) - tmp := &tmpfile{f: f, isOTmp: true, size: size} + tmp := &tmpfile{f: f, bucket: bucket, objname: obj, isOTmp: true, size: size} // falloc is best effort, its fine if this fails if size > 0 { tmp.falloc() @@ -117,7 +117,8 @@ func (tmp *tmpfile) link() error { err = unix.Linkat(int(procdir.Fd()), filepath.Base(tmp.f.Name()), int(dir.Fd()), filepath.Base(objPath), unix.AT_SYMLINK_FOLLOW) if err != nil { - return fmt.Errorf("link tmpfile: %w", err) + return fmt.Errorf("link tmpfile (%q in %q): %w", + filepath.Dir(objPath), filepath.Base(tmp.f.Name()), err) } err = tmp.f.Close() From ae1f5cda2f7d104c202f6de68ec10e1361113da9 Mon Sep 17 00:00:00 2001 From: Ben McClelland Date: Wed, 14 Jun 2023 09:12:20 -0700 Subject: [PATCH 2/2] fix: only print request headers on error --- s3api/controllers/base.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/s3api/controllers/base.go b/s3api/controllers/base.go index 11f237d6..f488b5b0 100644 --- a/s3api/controllers/base.go +++ b/s3api/controllers/base.go @@ -425,8 +425,8 @@ func SendResponse(ctx *fiber.Ctx, err error) error { return ctx.Send(s3err.GetAPIErrorResponse(serr, "", "", "")) } - fmt.Fprintf(os.Stderr, "Internal Error, req:\n%v\nerr:\n%v\n", - ctx.Request(), err) + fmt.Fprintf(os.Stderr, "Internal Error, req:\n%v\nerr: %v\n", + ctx.Request().Header.String(), err) return ctx.Send(s3err.GetAPIErrorResponse( s3err.GetAPIError(s3err.ErrInternalError), "", "", "")) @@ -446,8 +446,8 @@ func SendXMLResponse(ctx *fiber.Ctx, resp any, err error) error { return ctx.Send(s3err.GetAPIErrorResponse(serr, "", "", "")) } - fmt.Fprintf(os.Stderr, "Internal Error, req:\n%v\nerr:\n%v\n", - ctx.Request(), err) + fmt.Fprintf(os.Stderr, "Internal Error, req:\n%v\nerr: %v\n", + ctx.Request().Header.String(), err) return ctx.Send(s3err.GetAPIErrorResponse( s3err.GetAPIError(s3err.ErrInternalError), "", "", ""))