Skip to content

Commit

Permalink
fixed the response code when DELETE and MOVE requests to the file tha…
Browse files Browse the repository at this point in the history
…t is still in post-processing
  • Loading branch information
2403905 committed Jul 25, 2024
1 parent 53e5aaf commit 650b056
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 6 deletions.
15 changes: 11 additions & 4 deletions Dockerfile.revad-ceph
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
6 changes: 6 additions & 0 deletions changelog/unreleased/fix-postprocessing-responce.md
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
2 changes: 1 addition & 1 deletion internal/grpc/services/storageprovider/storageprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
20 changes: 20 additions & 0 deletions pkg/errtypes/errtypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions pkg/rgrpc/status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 650b056

Please sign in to comment.