Skip to content

Commit b88da4a

Browse files
committed
Merge remote-tracking branch 'origin/master' into spaces
2 parents c94721b + 9d2533e commit b88da4a

File tree

8 files changed

+34
-21
lines changed

8 files changed

+34
-21
lines changed

changelog/unreleased/app-notify.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Enhancement: extend app /notify endpoint to allow reporting errors
2+
3+
https://github.com/cs3org/reva/pull/5085

changelog/unreleased/broken-quota.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Bugfix: wrong quota total reported
2+
3+
The EOS `QuotaInfo` struct had fields for `AvailableBytes` and `AvailableInodes`, but these were used to mean the total. This is fixed now.
4+
5+
https://github.com/cs3org/reva/pull/5082

changelog/unreleased/quota-logical.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Bugfix: use logicalbytes instead of bytes
2+
3+
EOS gRPC used `usedbytes` instead of `usedlogicalbytes` for calculating quota, resulting in a wrong view
4+
5+
https://github.com/cs3org/reva/pull/5084

internal/http/services/appprovider/appprovider.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"context"
2323
"crypto/tls"
2424
"encoding/json"
25+
"io"
2526
"net/http"
2627
"path"
2728

@@ -468,10 +469,17 @@ func (s *svc) handleNotify(w http.ResponseWriter, r *http.Request) {
468469
fileRef.ResourceId = resourceID
469470
}
470471

472+
// the body of the request may contain any error the client got when attempting to open the app
473+
failure, _ := io.ReadAll(r.Body)
474+
471475
// log the fileid for later correlation / monitoring
472476
ctx := r.Context()
473477
log := appctx.GetLogger(ctx)
474-
log.Info().Interface("resource", &fileRef).Msg("file successfully opened in app")
478+
if len(failure) == 0 {
479+
log.Info().Interface("resource", fileRef).Msg("file successfully opened in app")
480+
} else {
481+
log.Info().Interface("resource", fileRef).Str("failure", string(failure)).Msg("failed to open file in app")
482+
}
475483

476484
w.WriteHeader(http.StatusOK)
477485
}

pkg/eosclient/eosbinary/eosbinary.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -1073,10 +1073,10 @@ func (c *Client) parseQuota(path, raw string) (*eosclient.QuotaInfo, error) {
10731073
usedInodes, _ := strconv.ParseUint(usedInodesString, 10, 64)
10741074

10751075
qi := &eosclient.QuotaInfo{
1076-
AvailableBytes: maxBytes,
1077-
UsedBytes: usedBytes,
1078-
AvailableInodes: maxInodes,
1079-
UsedInodes: usedInodes,
1076+
TotalBytes: maxBytes,
1077+
UsedBytes: usedBytes,
1078+
TotalInodes: maxInodes,
1079+
UsedInodes: usedInodes,
10801080
}
10811081
return qi, nil
10821082
}

pkg/eosclient/eosclient.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,11 @@ type Checksum struct {
110110
XSType string
111111
}
112112

113-
// QuotaInfo reports the available bytes and inodes for a particular user.
113+
// QuotaInfo reports the total and used bytes and inodes for a particular user.
114114
// eos reports all quota values are unsigned long, see https://github.com/cern-eos/eos/blob/93515df8c0d5a858982853d960bec98f983c1285/mgm/Quota.hh#L135
115115
type QuotaInfo struct {
116-
AvailableBytes, UsedBytes uint64
117-
AvailableInodes, UsedInodes uint64
116+
TotalBytes, UsedBytes uint64
117+
TotalInodes, UsedInodes uint64
118118
}
119119

120120
// SetQuotaInfo encapsulates the information needed to

pkg/eosclient/eosgrpc/eosgrpc.go

+3-11
Original file line numberDiff line numberDiff line change
@@ -852,18 +852,10 @@ func (c *Client) GetQuota(ctx context.Context, username string, rootAuth eosclie
852852
for i := 0; i < len(resp.Quota.Quotanode); i++ {
853853
log.Debug().Str("func", "GetQuota").Str("quotanode:", fmt.Sprintf("%d: %#v", i, resp.Quota.Quotanode[i])).Msg("")
854854

855-
mx := int64(resp.Quota.Quotanode[i].Maxlogicalbytes) - int64(resp.Quota.Quotanode[i].Usedbytes)
856-
if mx < 0 {
857-
mx = 0
858-
}
859-
qi.AvailableBytes += uint64(mx)
860-
qi.UsedBytes += resp.Quota.Quotanode[i].Usedbytes
855+
qi.TotalBytes += max(uint64(resp.Quota.Quotanode[i].Maxlogicalbytes), 0)
856+
qi.UsedBytes += resp.Quota.Quotanode[i].Usedlogicalbytes
861857

862-
mx = int64(resp.Quota.Quotanode[i].Maxfiles) - int64(resp.Quota.Quotanode[i].Usedfiles)
863-
if mx < 0 {
864-
mx = 0
865-
}
866-
qi.AvailableInodes += uint64(mx)
858+
qi.TotalInodes += max(uint64(resp.Quota.Quotanode[i].Maxfiles), 0)
867859
qi.UsedInodes += resp.Quota.Quotanode[i].Usedfiles
868860
}
869861

pkg/storage/utils/eosfs/eosfs.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1202,7 +1202,7 @@ func (fs *eosfs) CreateStorageSpace(ctx context.Context, req *provider.CreateSto
12021202
return nil, fmt.Errorf("unimplemented: CreateStorageSpace")
12031203
}
12041204

1205-
func (fs *eosfs) GetQuota(ctx context.Context, ref *provider.Reference) (uint64, uint64, error) {
1205+
func (fs *eosfs) GetQuota(ctx context.Context, ref *provider.Reference) (totalbytes, usedbytes uint64, err error) {
12061206
u, err := utils.GetUser(ctx)
12071207
if err != nil {
12081208
return 0, 0, errors.Wrap(err, "eosfs: no user in ctx")
@@ -1221,7 +1221,7 @@ func (fs *eosfs) GetQuota(ctx context.Context, ref *provider.Reference) (uint64,
12211221
return 0, 0, err
12221222
}
12231223

1224-
return qi.AvailableBytes, qi.UsedBytes, nil
1224+
return qi.TotalBytes, qi.UsedBytes, nil
12251225
}
12261226

12271227
func (fs *eosfs) GetHome(ctx context.Context) (string, error) {

0 commit comments

Comments
 (0)