From 650b05698d471cada1aefb1007392819a8c83c69 Mon Sep 17 00:00:00 2001 From: Roman Perekhod Date: Wed, 24 Jul 2024 15:28:05 +0200 Subject: [PATCH] fixed the response code when DELETE and MOVE requests to the file that is still in post-processing --- Dockerfile.revad-ceph | 15 ++++++++++---- .../unreleased/fix-postprocessing-responce.md | 6 ++++++ go.mod | 2 +- go.sum | 2 ++ .../storageprovider/storageprovider.go | 2 +- pkg/errtypes/errtypes.go | 20 +++++++++++++++++++ pkg/rgrpc/status/status.go | 1 + 7 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 changelog/unreleased/fix-postprocessing-responce.md diff --git a/Dockerfile.revad-ceph b/Dockerfile.revad-ceph index 007f564c48..482f5e1a33 100644 --- a/Dockerfile.revad-ceph +++ b/Dockerfile.revad-ceph @@ -20,11 +20,18 @@ FROM quay.io/ceph/ceph:v18 # replace repo url with one that allows downloading the repo metadata # if http://download.ceph.com/rpm-reef/el8/x86_64/repodata/repomd.xml works again this can be dropped -RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* -RUN sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-* -RUN mkdir -p /etc/selinux/config +# RUN sed -i 's/download.ceph.com/de.ceph.com/' /etc/yum.repos.d/ceph.repo +# RUN mkdir -p /etc/selinux/config +# +# RUN dnf update --exclude=ceph-iscsi,chrony -y && dnf install -y \ +# git \ +# gcc \ +# make \ +# libcephfs-devel \ +# librbd-devel \ +# librados-devel -RUN dnf update --exclude=ceph-iscsi,chrony -y && dnf install -y \ +RUN dnf update --exclude=ceph-iscsi -y && dnf install -y \ git \ gcc \ make \ diff --git a/changelog/unreleased/fix-postprocessing-responce.md b/changelog/unreleased/fix-postprocessing-responce.md new file mode 100644 index 0000000000..b4995f5dce --- /dev/null +++ b/changelog/unreleased/fix-postprocessing-responce.md @@ -0,0 +1,6 @@ +Bugfix: Fix response code for DEL file that in postprocessing + +We fixed the response code when DELETE and MOVE requests to the file that is still in post-processing. + +https://github.com/cs3org/reva/pull/4776 +https://github.com/owncloud/ocis/issues/9432 diff --git a/go.mod b/go.mod index 16361ad003..7c2fd5eb06 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/cheggaaa/pb v1.0.29 github.com/coreos/go-oidc/v3 v3.4.0 github.com/cs3org/cato v0.0.0-20200828125504-e418fc54dd5e - github.com/cs3org/go-cs3apis v0.0.0-20240425114016-d2cb31692b4e + github.com/cs3org/go-cs3apis v0.0.0-20240724121416-062c4e3046cb github.com/dgraph-io/ristretto v0.1.1 github.com/emvi/iso-639-1 v1.1.0 github.com/eventials/go-tus v0.0.0-20220610120217-05d0564bb571 diff --git a/go.sum b/go.sum index 28f7afbdce..149730aaa9 100644 --- a/go.sum +++ b/go.sum @@ -918,6 +918,8 @@ github.com/cs3org/cato v0.0.0-20200828125504-e418fc54dd5e h1:tqSPWQeueWTKnJVMJff github.com/cs3org/cato v0.0.0-20200828125504-e418fc54dd5e/go.mod h1:XJEZ3/EQuI3BXTp/6DUzFr850vlxq11I6satRtz0YQ4= github.com/cs3org/go-cs3apis v0.0.0-20240425114016-d2cb31692b4e h1:Cm2l8m2riLa79eh7V2wHd1Ra7wR3TbngmeLZBJ9MxTU= github.com/cs3org/go-cs3apis v0.0.0-20240425114016-d2cb31692b4e/go.mod h1:yyP8PRo0EZou3nSH7H4qjlzQwaydPeIRNgX50npQHpE= +github.com/cs3org/go-cs3apis v0.0.0-20240724121416-062c4e3046cb h1:KmYZDReplv/yfwc1LNYpDcVhVujC3Pasv6WjXx1haSU= +github.com/cs3org/go-cs3apis v0.0.0-20240724121416-062c4e3046cb/go.mod h1:yyP8PRo0EZou3nSH7H4qjlzQwaydPeIRNgX50npQHpE= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/internal/grpc/services/storageprovider/storageprovider.go b/internal/grpc/services/storageprovider/storageprovider.go index 7c548db53c..763148e8e7 100644 --- a/internal/grpc/services/storageprovider/storageprovider.go +++ b/internal/grpc/services/storageprovider/storageprovider.go @@ -731,7 +731,7 @@ func (s *Service) Delete(ctx context.Context, req *provider.DeleteRequest) (*pro if utils.ReadPlainFromOpaque(md.GetOpaque(), "status") == "processing" { return &provider.DeleteResponse{ Status: &rpc.Status{ - Code: rpc.Code_CODE_UNAVAILABLE, + Code: rpc.Code_CODE_TOO_EARLY, Message: "file is processing", }, Opaque: &typesv1beta1.Opaque{ diff --git a/pkg/errtypes/errtypes.go b/pkg/errtypes/errtypes.go index 363211ac5a..a02399e406 100644 --- a/pkg/errtypes/errtypes.go +++ b/pkg/errtypes/errtypes.go @@ -195,6 +195,14 @@ func (e InsufficientStorage) Body() []byte { // https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/507 const StatusInsufficientStorage = 507 +// TooEarly is the error to use when some are not finished job over resource is still in process. +type TooEarly string + +func (e TooEarly) Error() string { return "error: too early: " + string(e) } + +// IsTooEarly implements the IsTooEarly interface. +func (e TooEarly) IsTooEarly() {} + // IsNotFound is the interface to implement // to specify that a resource is not found. type IsNotFound interface { @@ -279,6 +287,12 @@ type IsInsufficientStorage interface { IsInsufficientStorage() } +// IsTooEarly is the interface to implement +// to specify that there is some not finished job over resource is still in process. +type IsTooEarly interface { + IsTooEarly() +} + // NewErrtypeFromStatus maps a rpc status to an errtype func NewErrtypeFromStatus(status *rpc.Status) error { switch status.Code { @@ -313,6 +327,8 @@ func NewErrtypeFromStatus(status *rpc.Status) error { return InsufficientStorage(status.Message) case rpc.Code_CODE_INVALID_ARGUMENT, rpc.Code_CODE_OUT_OF_RANGE: return BadRequest(status.Message) + case rpc.Code_CODE_TOO_EARLY: + return TooEarly(status.Message) default: return InternalError(status.Message) } @@ -345,6 +361,8 @@ func NewErrtypeFromHTTPStatusCode(code int, message string) error { return BadRequest(message) case http.StatusPartialContent: return PartialContent(message) + case http.StatusTooEarly: + return TooEarly(message) case StatusChecksumMismatch: return ChecksumMismatch(message) default: @@ -379,6 +397,8 @@ func NewHTTPStatusCodeFromErrtype(err error) int { return http.StatusBadRequest case PartialContent: return http.StatusPartialContent + case TooEarly: + return http.StatusTooEarly case ChecksumMismatch: return StatusChecksumMismatch default: diff --git a/pkg/rgrpc/status/status.go b/pkg/rgrpc/status/status.go index 4055cff4d9..f10c6df3e7 100644 --- a/pkg/rgrpc/status/status.go +++ b/pkg/rgrpc/status/status.go @@ -253,6 +253,7 @@ var httpStatusCode = map[rpc.Code]int{ rpc.Code_CODE_UNIMPLEMENTED: http.StatusNotImplemented, rpc.Code_CODE_UNKNOWN: http.StatusInternalServerError, rpc.Code_CODE_LOCKED: http.StatusLocked, + rpc.Code_CODE_TOO_EARLY: http.StatusTooEarly, } // HTTPStatusFromCode returns an HTTP status code for the rpc code. It returns