From ec7dada22c0c3b3a39528d67cd0677ef5c2ed6b0 Mon Sep 17 00:00:00 2001 From: Fabrizio Furano Date: Thu, 11 Feb 2021 15:34:15 +0100 Subject: [PATCH 01/38] Added changelog for eosgrpc --- changelog/unreleased/eosgrpc.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changelog/unreleased/eosgrpc.md diff --git a/changelog/unreleased/eosgrpc.md b/changelog/unreleased/eosgrpc.md new file mode 100644 index 0000000000..2a3a35c288 --- /dev/null +++ b/changelog/unreleased/eosgrpc.md @@ -0,0 +1,2 @@ +eosgrpc: More progress. Logging discipline and error handling + From 8c7c894b741d68aa75f30f049a11b18bd77501ac Mon Sep 17 00:00:00 2001 From: Fabrizio Furano Date: Thu, 11 Feb 2021 15:40:00 +0100 Subject: [PATCH 02/38] Added changelog pull req --- changelog/unreleased/eosgrpc.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/changelog/unreleased/eosgrpc.md b/changelog/unreleased/eosgrpc.md index 2a3a35c288..567cf67f57 100644 --- a/changelog/unreleased/eosgrpc.md +++ b/changelog/unreleased/eosgrpc.md @@ -1,2 +1,3 @@ -eosgrpc: More progress. Logging discipline and error handling +Enhancement: EOEGrpc progress. Logging discipline and error handling +https://github.com/cs3org/reva/pull/1471 From c37c7db62beb2d82b9266de868a426f44fe10d9d Mon Sep 17 00:00:00 2001 From: Fabrizio Furano Date: Wed, 24 Feb 2021 09:09:51 +0100 Subject: [PATCH 03/38] First working implementation of HTTP GET/PUT towards EOS --- pkg/eosclient/eosgrpc/eosgrpc.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/eosclient/eosgrpc/eosgrpc.go b/pkg/eosclient/eosgrpc/eosgrpc.go index e23a300026..8bed43fec3 100644 --- a/pkg/eosclient/eosgrpc/eosgrpc.go +++ b/pkg/eosclient/eosgrpc/eosgrpc.go @@ -148,6 +148,10 @@ func (c *Client) GetHTTPCl() *ehttp.Client { return ehttp.New(&c.htopts, c.httptransport) } +func (c *Client) GetHttpCl() *ehttp.EosHttpClient { + return ehttp.New(&c.opt.httpopts) +} + // Create and connect a grpc eos Client func newgrpc(ctx context.Context, opt *Options) (erpc.EosClient, error) { log := appctx.GetLogger(ctx) From 16c57f435407d7e08e0dec3099ebfbdea8c8798b Mon Sep 17 00:00:00 2001 From: Fabrizio Furano Date: Wed, 24 Feb 2021 09:23:03 +0100 Subject: [PATCH 04/38] Add comment --- pkg/eosclient/eosgrpc/eosgrpc.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/eosclient/eosgrpc/eosgrpc.go b/pkg/eosclient/eosgrpc/eosgrpc.go index 8bed43fec3..cfb8fb97d0 100644 --- a/pkg/eosclient/eosgrpc/eosgrpc.go +++ b/pkg/eosclient/eosgrpc/eosgrpc.go @@ -148,6 +148,7 @@ func (c *Client) GetHTTPCl() *ehttp.Client { return ehttp.New(&c.htopts, c.httptransport) } +// Create an http client for immediate usage, using the already instantiated resources func (c *Client) GetHttpCl() *ehttp.EosHttpClient { return ehttp.New(&c.opt.httpopts) } From c6b7c6ab0879674b87d8ff55658ecec90f68e981 Mon Sep 17 00:00:00 2001 From: Fabrizio Furano Date: Wed, 24 Feb 2021 09:45:56 +0100 Subject: [PATCH 05/38] eogrpc: change to full streaming behaviour for reads --- pkg/eosclient/eosgrpc/eosgrpc.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/eosclient/eosgrpc/eosgrpc.go b/pkg/eosclient/eosgrpc/eosgrpc.go index cfb8fb97d0..c1519e83eb 100644 --- a/pkg/eosclient/eosgrpc/eosgrpc.go +++ b/pkg/eosclient/eosgrpc/eosgrpc.go @@ -41,7 +41,6 @@ import ( "github.com/cs3org/reva/pkg/errtypes" "github.com/cs3org/reva/pkg/logger" "github.com/cs3org/reva/pkg/storage/utils/acl" - "github.com/google/uuid" "github.com/pkg/errors" "github.com/rs/zerolog/log" "google.golang.org/grpc" From 63c8b0020eac0acfbc9a07391f5b514269a67904 Mon Sep 17 00:00:00 2001 From: Fabrizio Furano Date: Wed, 24 Feb 2021 11:00:30 +0100 Subject: [PATCH 06/38] Fix comment --- pkg/eosclient/eosgrpc/eosgrpc.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/eosclient/eosgrpc/eosgrpc.go b/pkg/eosclient/eosgrpc/eosgrpc.go index c1519e83eb..cd8c2da756 100644 --- a/pkg/eosclient/eosgrpc/eosgrpc.go +++ b/pkg/eosclient/eosgrpc/eosgrpc.go @@ -147,7 +147,7 @@ func (c *Client) GetHTTPCl() *ehttp.Client { return ehttp.New(&c.htopts, c.httptransport) } -// Create an http client for immediate usage, using the already instantiated resources +// GetHttpCl: Create an http client for immediate usage, using the already instantiated resources func (c *Client) GetHttpCl() *ehttp.EosHttpClient { return ehttp.New(&c.opt.httpopts) } From c14a3ca1d5ce40617b0b79e2f4af1b1c688781ed Mon Sep 17 00:00:00 2001 From: Fabrizio Furano Date: Wed, 24 Feb 2021 11:01:56 +0100 Subject: [PATCH 07/38] Fix comment --- pkg/eosclient/eosgrpc/eosgrpc.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/eosclient/eosgrpc/eosgrpc.go b/pkg/eosclient/eosgrpc/eosgrpc.go index cd8c2da756..05befef8ae 100644 --- a/pkg/eosclient/eosgrpc/eosgrpc.go +++ b/pkg/eosclient/eosgrpc/eosgrpc.go @@ -147,7 +147,7 @@ func (c *Client) GetHTTPCl() *ehttp.Client { return ehttp.New(&c.htopts, c.httptransport) } -// GetHttpCl: Create an http client for immediate usage, using the already instantiated resources +// GetHttpCl creates an http client for immediate usage, using the already instantiated resources func (c *Client) GetHttpCl() *ehttp.EosHttpClient { return ehttp.New(&c.opt.httpopts) } From 1637eb615ded5775af7743cd02d53c587d418ba5 Mon Sep 17 00:00:00 2001 From: Fabrizio Furano Date: Mon, 8 Mar 2021 19:18:39 +0100 Subject: [PATCH 08/38] Implement Get/SetQuota (pending cleanup) --- pkg/storage/utils/eosfs/eosfs.go | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/pkg/storage/utils/eosfs/eosfs.go b/pkg/storage/utils/eosfs/eosfs.go index 39e0186cea..97e68e728b 100644 --- a/pkg/storage/utils/eosfs/eosfs.go +++ b/pkg/storage/utils/eosfs/eosfs.go @@ -727,6 +727,34 @@ func (fs *eosfs) ListFolder(ctx context.Context, ref *provider.Reference, mdKeys return nil, errors.Wrap(err, "eosfs: no user in ctx") } + // test... remove me + rootuid, rootgid, err := fs.getRootUIDAndGID(ctx) + if err != nil { + return nil, err + } + uid, gid, err := fs.getUserUIDAndGID(ctx, u) + if err != nil { + return nil, errors.Wrap(err, "eos: no uid in ctx") + } + // set quota for user + quotaInfo := &eosclient.SetQuotaInfo{ + Username: u.Username, + Uid: uid, + Gid: gid, + MaxBytes: fs.conf.DefaultQuotaBytes, + MaxFiles: fs.conf.DefaultQuotaFiles, + QuotaNode: fs.conf.QuotaNode, + } + + err = fs.c.SetQuota(ctx, rootuid, rootgid, quotaInfo) + if err != nil { + err := errors.Wrap(err, "eosfs: error setting quota") + return nil, err + } + + fs.GetQuota(ctx) + // end test + p, err := fs.resolve(ctx, u, ref) if err != nil { return nil, errors.Wrap(err, "eosfs: error resolving reference") @@ -882,6 +910,11 @@ func (fs *eosfs) GetQuota(ctx context.Context) (uint64, uint64, error) { return 0, 0, errors.Wrap(err, "eosfs: no uid in ctx") } + uid, _, err := fs.getUserUIDAndGID(ctx, u) + if err != nil { + return 0, 0, errors.Wrap(err, "eos: no uid in ctx") + } + rootUID, rootGID, err := fs.getRootUIDAndGID(ctx) if err != nil { return 0, 0, err From 44661832fd0de026d17887f0c3e69de47a6b6ad1 Mon Sep 17 00:00:00 2001 From: Fabrizio Furano Date: Fri, 12 Mar 2021 12:30:55 +0100 Subject: [PATCH 09/38] Shut up a warning from Hound --- pkg/storage/utils/eosfs/eosfs.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/storage/utils/eosfs/eosfs.go b/pkg/storage/utils/eosfs/eosfs.go index 97e68e728b..e37e61430a 100644 --- a/pkg/storage/utils/eosfs/eosfs.go +++ b/pkg/storage/utils/eosfs/eosfs.go @@ -739,8 +739,8 @@ func (fs *eosfs) ListFolder(ctx context.Context, ref *provider.Reference, mdKeys // set quota for user quotaInfo := &eosclient.SetQuotaInfo{ Username: u.Username, - Uid: uid, - Gid: gid, + UID: uid, + GID: gid, MaxBytes: fs.conf.DefaultQuotaBytes, MaxFiles: fs.conf.DefaultQuotaFiles, QuotaNode: fs.conf.QuotaNode, From cecc20f5d05b9cbbb0dd1920d11c49c1cd4785ee Mon Sep 17 00:00:00 2001 From: Fabrizio Furano Date: Fri, 12 Mar 2021 12:37:15 +0100 Subject: [PATCH 10/38] Shut up another warning from Hound --- pkg/eosclient/eosgrpc/eosgrpc.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/eosclient/eosgrpc/eosgrpc.go b/pkg/eosclient/eosgrpc/eosgrpc.go index 05befef8ae..3d765e7189 100644 --- a/pkg/eosclient/eosgrpc/eosgrpc.go +++ b/pkg/eosclient/eosgrpc/eosgrpc.go @@ -148,7 +148,7 @@ func (c *Client) GetHTTPCl() *ehttp.Client { } // GetHttpCl creates an http client for immediate usage, using the already instantiated resources -func (c *Client) GetHttpCl() *ehttp.EosHttpClient { +func (c *Client) GetHTTPCl() *ehttp.EosHttpClient { return ehttp.New(&c.opt.httpopts) } From 5301f81e6ca354e5e05281c0973756563a1818a8 Mon Sep 17 00:00:00 2001 From: Fabrizio Furano Date: Mon, 15 Mar 2021 14:22:09 +0100 Subject: [PATCH 11/38] eosgrpc: remove some test code, cleanup, introduce the parms ReadUsesLocalTemp/WriteUsesLocalTemp (default false) --- pkg/eosclient/eosgrpc/eosgrpc.go | 10 ++++++++++ pkg/storage/utils/eosfs/eosfs.go | 28 ---------------------------- 2 files changed, 10 insertions(+), 28 deletions(-) diff --git a/pkg/eosclient/eosgrpc/eosgrpc.go b/pkg/eosclient/eosgrpc/eosgrpc.go index 3d765e7189..44fb340c3d 100644 --- a/pkg/eosclient/eosgrpc/eosgrpc.go +++ b/pkg/eosclient/eosgrpc/eosgrpc.go @@ -41,6 +41,8 @@ import ( "github.com/cs3org/reva/pkg/errtypes" "github.com/cs3org/reva/pkg/logger" "github.com/cs3org/reva/pkg/storage/utils/acl" + erpc "github.com/ffurano/grpc-proto/protobuf" + "github.com/google/uuid" "github.com/pkg/errors" "github.com/rs/zerolog/log" "google.golang.org/grpc" @@ -92,6 +94,14 @@ type Options struct { // Defaults to os.TempDir() CacheDirectory string + // Set to true to use the local disk as a buffer for chunk + // reads from EOS. Default is false, i.e. pure streaming + ReadUsesLocalTemp bool + + // Set to true to use the local disk as a buffer for chunk + // writes to EOS. Default is false, i.e. pure streaming + WriteUsesLocalTemp bool + // Keytab is the location of the EOS keytab file. Keytab string diff --git a/pkg/storage/utils/eosfs/eosfs.go b/pkg/storage/utils/eosfs/eosfs.go index e37e61430a..34447802bc 100644 --- a/pkg/storage/utils/eosfs/eosfs.go +++ b/pkg/storage/utils/eosfs/eosfs.go @@ -727,34 +727,6 @@ func (fs *eosfs) ListFolder(ctx context.Context, ref *provider.Reference, mdKeys return nil, errors.Wrap(err, "eosfs: no user in ctx") } - // test... remove me - rootuid, rootgid, err := fs.getRootUIDAndGID(ctx) - if err != nil { - return nil, err - } - uid, gid, err := fs.getUserUIDAndGID(ctx, u) - if err != nil { - return nil, errors.Wrap(err, "eos: no uid in ctx") - } - // set quota for user - quotaInfo := &eosclient.SetQuotaInfo{ - Username: u.Username, - UID: uid, - GID: gid, - MaxBytes: fs.conf.DefaultQuotaBytes, - MaxFiles: fs.conf.DefaultQuotaFiles, - QuotaNode: fs.conf.QuotaNode, - } - - err = fs.c.SetQuota(ctx, rootuid, rootgid, quotaInfo) - if err != nil { - err := errors.Wrap(err, "eosfs: error setting quota") - return nil, err - } - - fs.GetQuota(ctx) - // end test - p, err := fs.resolve(ctx, u, ref) if err != nil { return nil, errors.Wrap(err, "eosfs: error resolving reference") From 1e7d82302fe7e986eec998eb50d510c473a9df88 Mon Sep 17 00:00:00 2001 From: Fabrizio Furano Date: Fri, 19 Mar 2021 12:52:59 +0100 Subject: [PATCH 12/38] eosfs: Fix two minor warnings --- pkg/eosclient/eosgrpc/eosgrpc.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/eosclient/eosgrpc/eosgrpc.go b/pkg/eosclient/eosgrpc/eosgrpc.go index 44fb340c3d..8e7375ed24 100644 --- a/pkg/eosclient/eosgrpc/eosgrpc.go +++ b/pkg/eosclient/eosgrpc/eosgrpc.go @@ -157,7 +157,7 @@ func (c *Client) GetHTTPCl() *ehttp.Client { return ehttp.New(&c.htopts, c.httptransport) } -// GetHttpCl creates an http client for immediate usage, using the already instantiated resources +// GetHTTPCl creates an http client for immediate usage, using the already instantiated resources func (c *Client) GetHTTPCl() *ehttp.EosHttpClient { return ehttp.New(&c.opt.httpopts) } From 3e8d68f3a9cdf56ceb460ff218f30e1264d024a8 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 29 Mar 2021 16:00:54 +0200 Subject: [PATCH 13/38] Fix a few warnings --- pkg/eosclient/eosgrpc/eosgrpc.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/eosclient/eosgrpc/eosgrpc.go b/pkg/eosclient/eosgrpc/eosgrpc.go index 8e7375ed24..3acd9eef88 100644 --- a/pkg/eosclient/eosgrpc/eosgrpc.go +++ b/pkg/eosclient/eosgrpc/eosgrpc.go @@ -158,7 +158,7 @@ func (c *Client) GetHTTPCl() *ehttp.Client { } // GetHTTPCl creates an http client for immediate usage, using the already instantiated resources -func (c *Client) GetHTTPCl() *ehttp.EosHttpClient { +func (c *Client) GetHTTPCl() *ehttp.EosHTTPClient { return ehttp.New(&c.opt.httpopts) } From f3db75b1fe7e0d93f5ad6b69942be17ff7f3afe4 Mon Sep 17 00:00:00 2001 From: Fabrizio Furano Date: Tue, 9 Feb 2021 16:01:49 +0100 Subject: [PATCH 14/38] If EOS complains, extract the real error. More logging discipline and improvements --- pkg/eosclient/eosgrpc/eosgrpc.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pkg/eosclient/eosgrpc/eosgrpc.go b/pkg/eosclient/eosgrpc/eosgrpc.go index 3acd9eef88..bffe729070 100644 --- a/pkg/eosclient/eosgrpc/eosgrpc.go +++ b/pkg/eosclient/eosgrpc/eosgrpc.go @@ -169,7 +169,8 @@ func newgrpc(ctx context.Context, opt *Options) (erpc.EosClient, error) { conn, err := grpc.Dial(opt.GrpcURI, grpc.WithInsecure()) if err != nil { - log.Warn().Str("Error connecting to ", "'"+opt.GrpcURI+"' ").Str("err", err.Error()).Msg("") + log.Debug().Str("Error connecting to ", "'"+opt.GrpcURI+"' ").Str("err", err.Error()).Msg("") + return nil, err } log.Debug().Str("Going to ping ", "'"+opt.GrpcURI+"' ").Msg("") @@ -181,7 +182,8 @@ func newgrpc(ctx context.Context, opt *Options) (erpc.EosClient, error) { prq.Message = []byte("hi this is a ping from reva") prep, err := ecl.Ping(ctx, prq) if err != nil { - log.Warn().Str("Could not ping to ", "'"+opt.GrpcURI+"' ").Str("err", err.Error()).Msg("") + log.Error().Str("Ping to ", "'"+opt.GrpcURI+"' ").Str("err", err.Error()).Msg("") + return nil, err } if prep == nil { @@ -325,6 +327,7 @@ func (c *Client) AddACL(ctx context.Context, uid, gid, rootUID, rootGID, path st return e } + log.Debug().Str("func", "AddACL").Str("path", path).Str("resp:", fmt.Sprintf("%#v", resp)).Msg("") if resp == nil { return errtypes.NotFound(fmt.Sprintf("Path: %s", path)) } @@ -374,6 +377,7 @@ func (c *Client) RemoveACL(ctx context.Context, uid, gid, rootUID, rootGID, path return e } + log.Debug().Str("func", "RemoveACL").Str("path", path).Str("resp:", fmt.Sprintf("%#v", resp)).Msg("") if resp == nil { return errtypes.NotFound(fmt.Sprintf("Path: %s", path)) } @@ -457,7 +461,7 @@ func (c *Client) getACLForPath(ctx context.Context, uid, gid, path string) (*acl return nil, errtypes.InternalError(fmt.Sprintf("nil response for uid: '%s' path: '%s'", uid, path)) } - log.Debug().Str("func", "GetACLForPath").Str("path", path).Str("resp:", fmt.Sprintf("%#v", resp)).Msg("grpc response") + log.Debug().Str("func", "GetACLForPath").Str("path", path).Str("resp:", fmt.Sprintf("%#v", resp)).Msg("") if resp.Acl == nil { return nil, errtypes.InternalError(fmt.Sprintf("nil acl for uid: '%s' path: '%s'", uid, path)) @@ -1257,7 +1261,6 @@ func (c *Client) Write(ctx context.Context, uid, gid, path string, stream io.Rea // WriteFile writes an existing file to the mgm. Old xrdcp utility func (c *Client) WriteFile(ctx context.Context, uid, gid, path, source string) error { - log := appctx.GetLogger(ctx) log.Info().Str("func", "WriteFile").Str("uid,gid", uid+","+gid).Str("path", path).Str("source", source).Msg("") From 55dfffda5f4393052aa77abfafafbe7543451b3c Mon Sep 17 00:00:00 2001 From: Fabrizio Furano Date: Wed, 24 Feb 2021 09:09:51 +0100 Subject: [PATCH 15/38] First working implementation of HTTP GET/PUT towards EOS --- pkg/eosclient/eosgrpc/eosgrpc.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/eosclient/eosgrpc/eosgrpc.go b/pkg/eosclient/eosgrpc/eosgrpc.go index bffe729070..f194bcbd61 100644 --- a/pkg/eosclient/eosgrpc/eosgrpc.go +++ b/pkg/eosclient/eosgrpc/eosgrpc.go @@ -1261,6 +1261,7 @@ func (c *Client) Write(ctx context.Context, uid, gid, path string, stream io.Rea // WriteFile writes an existing file to the mgm. Old xrdcp utility func (c *Client) WriteFile(ctx context.Context, uid, gid, path, source string) error { + log := appctx.GetLogger(ctx) log.Info().Str("func", "WriteFile").Str("uid,gid", uid+","+gid).Str("path", path).Str("source", source).Msg("") From 6b4398ce226c834b0465af10db7c7307a36d1485 Mon Sep 17 00:00:00 2001 From: Fabrizio Furano Date: Mon, 8 Mar 2021 19:18:39 +0100 Subject: [PATCH 16/38] Implement Get/SetQuota (pending cleanup) --- pkg/eosclient/eosgrpc/eosgrpc.go | 1 + pkg/storage/utils/eosfs/eosfs.go | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/pkg/eosclient/eosgrpc/eosgrpc.go b/pkg/eosclient/eosgrpc/eosgrpc.go index f194bcbd61..29a642bba4 100644 --- a/pkg/eosclient/eosgrpc/eosgrpc.go +++ b/pkg/eosclient/eosgrpc/eosgrpc.go @@ -696,6 +696,7 @@ func (c *Client) GetQuota(ctx context.Context, username, rootUID, rootGID, path resp, err := c.cl.Exec(ctx, rq) e := c.getRespError(resp, err) if e != nil { + log.Info().Str("func", "GetQuota").Str("rootuid,rootgid", rootUID+","+rootGID).Str("username", username).Str("info:", fmt.Sprintf("%#v", resp)).Str("err", e.Error()).Msg("") return nil, e } diff --git a/pkg/storage/utils/eosfs/eosfs.go b/pkg/storage/utils/eosfs/eosfs.go index 34447802bc..97e68e728b 100644 --- a/pkg/storage/utils/eosfs/eosfs.go +++ b/pkg/storage/utils/eosfs/eosfs.go @@ -727,6 +727,34 @@ func (fs *eosfs) ListFolder(ctx context.Context, ref *provider.Reference, mdKeys return nil, errors.Wrap(err, "eosfs: no user in ctx") } + // test... remove me + rootuid, rootgid, err := fs.getRootUIDAndGID(ctx) + if err != nil { + return nil, err + } + uid, gid, err := fs.getUserUIDAndGID(ctx, u) + if err != nil { + return nil, errors.Wrap(err, "eos: no uid in ctx") + } + // set quota for user + quotaInfo := &eosclient.SetQuotaInfo{ + Username: u.Username, + Uid: uid, + Gid: gid, + MaxBytes: fs.conf.DefaultQuotaBytes, + MaxFiles: fs.conf.DefaultQuotaFiles, + QuotaNode: fs.conf.QuotaNode, + } + + err = fs.c.SetQuota(ctx, rootuid, rootgid, quotaInfo) + if err != nil { + err := errors.Wrap(err, "eosfs: error setting quota") + return nil, err + } + + fs.GetQuota(ctx) + // end test + p, err := fs.resolve(ctx, u, ref) if err != nil { return nil, errors.Wrap(err, "eosfs: error resolving reference") From 92c76df119d23787f50e0c29ddc1a39978381cdb Mon Sep 17 00:00:00 2001 From: Fabrizio Furano Date: Fri, 12 Mar 2021 12:17:09 +0100 Subject: [PATCH 17/38] Code cleanup, logging, implemet Rename --- pkg/eosclient/eosgrpc/eosgrpc.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pkg/eosclient/eosgrpc/eosgrpc.go b/pkg/eosclient/eosgrpc/eosgrpc.go index 29a642bba4..7972c22013 100644 --- a/pkg/eosclient/eosgrpc/eosgrpc.go +++ b/pkg/eosclient/eosgrpc/eosgrpc.go @@ -327,7 +327,6 @@ func (c *Client) AddACL(ctx context.Context, uid, gid, rootUID, rootGID, path st return e } - log.Debug().Str("func", "AddACL").Str("path", path).Str("resp:", fmt.Sprintf("%#v", resp)).Msg("") if resp == nil { return errtypes.NotFound(fmt.Sprintf("Path: %s", path)) } @@ -377,7 +376,6 @@ func (c *Client) RemoveACL(ctx context.Context, uid, gid, rootUID, rootGID, path return e } - log.Debug().Str("func", "RemoveACL").Str("path", path).Str("resp:", fmt.Sprintf("%#v", resp)).Msg("") if resp == nil { return errtypes.NotFound(fmt.Sprintf("Path: %s", path)) } @@ -461,7 +459,7 @@ func (c *Client) getACLForPath(ctx context.Context, uid, gid, path string) (*acl return nil, errtypes.InternalError(fmt.Sprintf("nil response for uid: '%s' path: '%s'", uid, path)) } - log.Debug().Str("func", "GetACLForPath").Str("path", path).Str("resp:", fmt.Sprintf("%#v", resp)).Msg("") + log.Debug().Str("func", "GetACLForPath").Str("path", path).Str("resp:", fmt.Sprintf("%#v", resp)).Msg("grpc response") if resp.Acl == nil { return nil, errtypes.InternalError(fmt.Sprintf("nil acl for uid: '%s' path: '%s'", uid, path)) @@ -696,7 +694,6 @@ func (c *Client) GetQuota(ctx context.Context, username, rootUID, rootGID, path resp, err := c.cl.Exec(ctx, rq) e := c.getRespError(resp, err) if e != nil { - log.Info().Str("func", "GetQuota").Str("rootuid,rootgid", rootUID+","+rootGID).Str("username", username).Str("info:", fmt.Sprintf("%#v", resp)).Str("err", e.Error()).Msg("") return nil, e } From 70becb0fb489783fee2308d0d4e5ca8b85a5d8f4 Mon Sep 17 00:00:00 2001 From: Fabrizio Furano Date: Fri, 12 Mar 2021 12:30:55 +0100 Subject: [PATCH 18/38] Shut up a warning from Hound --- pkg/storage/utils/eosfs/eosfs.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/storage/utils/eosfs/eosfs.go b/pkg/storage/utils/eosfs/eosfs.go index 97e68e728b..e37e61430a 100644 --- a/pkg/storage/utils/eosfs/eosfs.go +++ b/pkg/storage/utils/eosfs/eosfs.go @@ -739,8 +739,8 @@ func (fs *eosfs) ListFolder(ctx context.Context, ref *provider.Reference, mdKeys // set quota for user quotaInfo := &eosclient.SetQuotaInfo{ Username: u.Username, - Uid: uid, - Gid: gid, + UID: uid, + GID: gid, MaxBytes: fs.conf.DefaultQuotaBytes, MaxFiles: fs.conf.DefaultQuotaFiles, QuotaNode: fs.conf.QuotaNode, From c26f1d7d59b7dde7fa1e40b934691470d329f6bb Mon Sep 17 00:00:00 2001 From: Fabrizio Furano Date: Fri, 12 Mar 2021 12:37:15 +0100 Subject: [PATCH 19/38] Shut up another warning from Hound --- pkg/eosclient/eosgrpc/eosgrpc.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pkg/eosclient/eosgrpc/eosgrpc.go b/pkg/eosclient/eosgrpc/eosgrpc.go index 7972c22013..82d6bc455c 100644 --- a/pkg/eosclient/eosgrpc/eosgrpc.go +++ b/pkg/eosclient/eosgrpc/eosgrpc.go @@ -1250,6 +1250,20 @@ func (c *Client) Write(ctx context.Context, uid, gid, path string, stream io.Rea return c.GetHTTPCl().PUTFile(ctx, c.httptransport, "", uid, gid, path, wfd, length) } +======= + //fd, err := ioutil.TempFile(c.opt.CacheDirectory, "eoswrite-") + //if err != nil { + // return err + // } + // defer fd.Close() + // defer os.RemoveAll(fd.Name()) + // + // // copy stream to local temp file + // _, err = io.Copy(fd, stream) + // if err != nil { + //return err + //} +>>>>>>> Shut up another warning from Hound return c.GetHTTPCl().PUTFile(ctx, c.httptransport, "", uid, gid, path, stream, length) From 39812ca1ac02e4d4ac36508405a31e96a74d0a1b Mon Sep 17 00:00:00 2001 From: Fabrizio Furano Date: Fri, 12 Mar 2021 14:57:33 +0100 Subject: [PATCH 20/38] Use the eos grpc defs from github --- go.mod | 1 + go.sum | 2 ++ pkg/eosclient/eosgrpc/eosgrpc.go | 14 -------------- 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/go.mod b/go.mod index 32a7e44aa4..a6e1744c82 100644 --- a/go.mod +++ b/go.mod @@ -19,6 +19,7 @@ require ( github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/eventials/go-tus v0.0.0-20200718001131-45c7ec8f5d59 github.com/gdexlab/go-render v1.0.1 + github.com/ffurano/grpc-proto v0.0.0-20210312134900-65801a1ca184 github.com/go-ldap/ldap/v3 v3.3.0 github.com/go-sql-driver/mysql v1.6.0 github.com/golang/protobuf v1.5.2 diff --git a/go.sum b/go.sum index 99e4e1d397..d59000e13d 100644 --- a/go.sum +++ b/go.sum @@ -189,6 +189,8 @@ github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/fatih/structs v1.0.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= +github.com/ffurano/grpc-proto v0.0.0-20210312134900-65801a1ca184 h1:8sEVFrVAFCen9fYexSRHOnJgkat6dWpCX9W+WZxxaKE= +github.com/ffurano/grpc-proto v0.0.0-20210312134900-65801a1ca184/go.mod h1:tVK5FalFRrPhludOXg3eSQ/9sMpi/b6mav+UHAm8OWc= github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= diff --git a/pkg/eosclient/eosgrpc/eosgrpc.go b/pkg/eosclient/eosgrpc/eosgrpc.go index 82d6bc455c..7972c22013 100644 --- a/pkg/eosclient/eosgrpc/eosgrpc.go +++ b/pkg/eosclient/eosgrpc/eosgrpc.go @@ -1250,20 +1250,6 @@ func (c *Client) Write(ctx context.Context, uid, gid, path string, stream io.Rea return c.GetHTTPCl().PUTFile(ctx, c.httptransport, "", uid, gid, path, wfd, length) } -======= - //fd, err := ioutil.TempFile(c.opt.CacheDirectory, "eoswrite-") - //if err != nil { - // return err - // } - // defer fd.Close() - // defer os.RemoveAll(fd.Name()) - // - // // copy stream to local temp file - // _, err = io.Copy(fd, stream) - // if err != nil { - //return err - //} ->>>>>>> Shut up another warning from Hound return c.GetHTTPCl().PUTFile(ctx, c.httptransport, "", uid, gid, path, stream, length) From a3534889738772f8b816d0212cfa6310c4e86f51 Mon Sep 17 00:00:00 2001 From: Fabrizio Furano Date: Mon, 15 Mar 2021 14:22:09 +0100 Subject: [PATCH 21/38] eosgrpc: remove some test code, cleanup, introduce the parms ReadUsesLocalTemp/WriteUsesLocalTemp (default false) --- pkg/storage/utils/eosfs/eosfs.go | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/pkg/storage/utils/eosfs/eosfs.go b/pkg/storage/utils/eosfs/eosfs.go index e37e61430a..34447802bc 100644 --- a/pkg/storage/utils/eosfs/eosfs.go +++ b/pkg/storage/utils/eosfs/eosfs.go @@ -727,34 +727,6 @@ func (fs *eosfs) ListFolder(ctx context.Context, ref *provider.Reference, mdKeys return nil, errors.Wrap(err, "eosfs: no user in ctx") } - // test... remove me - rootuid, rootgid, err := fs.getRootUIDAndGID(ctx) - if err != nil { - return nil, err - } - uid, gid, err := fs.getUserUIDAndGID(ctx, u) - if err != nil { - return nil, errors.Wrap(err, "eos: no uid in ctx") - } - // set quota for user - quotaInfo := &eosclient.SetQuotaInfo{ - Username: u.Username, - UID: uid, - GID: gid, - MaxBytes: fs.conf.DefaultQuotaBytes, - MaxFiles: fs.conf.DefaultQuotaFiles, - QuotaNode: fs.conf.QuotaNode, - } - - err = fs.c.SetQuota(ctx, rootuid, rootgid, quotaInfo) - if err != nil { - err := errors.Wrap(err, "eosfs: error setting quota") - return nil, err - } - - fs.GetQuota(ctx) - // end test - p, err := fs.resolve(ctx, u, ref) if err != nil { return nil, errors.Wrap(err, "eosfs: error resolving reference") From ef1e6f986ec76dd162759afce09763e50a2abb1e Mon Sep 17 00:00:00 2001 From: Fabrizio Furano Date: Tue, 23 Mar 2021 11:37:08 +0100 Subject: [PATCH 22/38] Allow the grpc auto connect mechanism to work also when eos is down on startup --- pkg/eosclient/eosgrpc/eosgrpc.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pkg/eosclient/eosgrpc/eosgrpc.go b/pkg/eosclient/eosgrpc/eosgrpc.go index 7972c22013..3acd9eef88 100644 --- a/pkg/eosclient/eosgrpc/eosgrpc.go +++ b/pkg/eosclient/eosgrpc/eosgrpc.go @@ -169,8 +169,7 @@ func newgrpc(ctx context.Context, opt *Options) (erpc.EosClient, error) { conn, err := grpc.Dial(opt.GrpcURI, grpc.WithInsecure()) if err != nil { - log.Debug().Str("Error connecting to ", "'"+opt.GrpcURI+"' ").Str("err", err.Error()).Msg("") - return nil, err + log.Warn().Str("Error connecting to ", "'"+opt.GrpcURI+"' ").Str("err", err.Error()).Msg("") } log.Debug().Str("Going to ping ", "'"+opt.GrpcURI+"' ").Msg("") @@ -182,8 +181,7 @@ func newgrpc(ctx context.Context, opt *Options) (erpc.EosClient, error) { prq.Message = []byte("hi this is a ping from reva") prep, err := ecl.Ping(ctx, prq) if err != nil { - log.Error().Str("Ping to ", "'"+opt.GrpcURI+"' ").Str("err", err.Error()).Msg("") - return nil, err + log.Warn().Str("Could not ping to ", "'"+opt.GrpcURI+"' ").Str("err", err.Error()).Msg("") } if prep == nil { From 9e7867f8848b9b6345879130bd74798946edbde1 Mon Sep 17 00:00:00 2001 From: fbx Date: Tue, 11 May 2021 09:29:29 +0200 Subject: [PATCH 23/38] Lint cosmetics --- pkg/eosclient/eosgrpc/eosgrpc.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/eosclient/eosgrpc/eosgrpc.go b/pkg/eosclient/eosgrpc/eosgrpc.go index 3acd9eef88..972111b035 100644 --- a/pkg/eosclient/eosgrpc/eosgrpc.go +++ b/pkg/eosclient/eosgrpc/eosgrpc.go @@ -158,7 +158,7 @@ func (c *Client) GetHTTPCl() *ehttp.Client { } // GetHTTPCl creates an http client for immediate usage, using the already instantiated resources -func (c *Client) GetHTTPCl() *ehttp.EosHTTPClient { +func (c *Client) GetHTTPCl() *ehttp.Client { return ehttp.New(&c.opt.httpopts) } From b9c9135a75e47ca15a12b8728b28299af50db4fa Mon Sep 17 00:00:00 2001 From: fbx Date: Tue, 11 May 2021 12:53:55 +0200 Subject: [PATCH 24/38] Lint cosmetics (maligned) --- pkg/eosclient/eosgrpc/eosgrpc.go | 8 -------- 1 file changed, 8 deletions(-) diff --git a/pkg/eosclient/eosgrpc/eosgrpc.go b/pkg/eosclient/eosgrpc/eosgrpc.go index 972111b035..ef98fdbdd3 100644 --- a/pkg/eosclient/eosgrpc/eosgrpc.go +++ b/pkg/eosclient/eosgrpc/eosgrpc.go @@ -94,14 +94,6 @@ type Options struct { // Defaults to os.TempDir() CacheDirectory string - // Set to true to use the local disk as a buffer for chunk - // reads from EOS. Default is false, i.e. pure streaming - ReadUsesLocalTemp bool - - // Set to true to use the local disk as a buffer for chunk - // writes to EOS. Default is false, i.e. pure streaming - WriteUsesLocalTemp bool - // Keytab is the location of the EOS keytab file. Keytab string From 40f281ce287e85066757248ef1d32171060513f2 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 27 May 2021 11:32:17 +0200 Subject: [PATCH 25/38] Pass the upload file size to the http layer if WriteUsesLocalTemp is true --- pkg/eosclient/eosgrpc/eos_http/eoshttp.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/eosclient/eosgrpc/eos_http/eoshttp.go b/pkg/eosclient/eosgrpc/eos_http/eoshttp.go index 0ffa07a91c..6ec03d540a 100644 --- a/pkg/eosclient/eosgrpc/eos_http/eoshttp.go +++ b/pkg/eosclient/eosgrpc/eos_http/eoshttp.go @@ -418,6 +418,11 @@ func (c *Client) PUTFile(ctx context.Context, httptransport *http.Transport, rem Transport: httptransport} req, err = http.NewRequestWithContext(ctx, "PUT", loc.String(), stream) + if length >= 0 { + log.Debug().Str("func", "PUTFile").Int64("Content-Length", length).Msg("setting header") + req.Header.Set("Content-Length", strconv.FormatInt(length, 10)) + + } if err != nil { log.Error().Str("func", "PUTFile").Str("url", loc.String()).Str("err", err.Error()).Msg("can't create redirected request") return err From f576b3b7e05fedc1f3fc20ff93a65d18986c76f1 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 2 Jun 2021 09:40:58 +0200 Subject: [PATCH 26/38] Fix minor warning --- pkg/eosclient/eosgrpc/eos_http/eoshttp.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/eosclient/eosgrpc/eos_http/eoshttp.go b/pkg/eosclient/eosgrpc/eos_http/eoshttp.go index 6ec03d540a..7c7448ebae 100644 --- a/pkg/eosclient/eosgrpc/eos_http/eoshttp.go +++ b/pkg/eosclient/eosgrpc/eos_http/eoshttp.go @@ -418,6 +418,10 @@ func (c *Client) PUTFile(ctx context.Context, httptransport *http.Transport, rem Transport: httptransport} req, err = http.NewRequestWithContext(ctx, "PUT", loc.String(), stream) + if err != nil { + log.Error().Str("func", "PUTFile").Str("url", loc.String()).Str("err", err.Error()).Msg("can't create redirected request") + return err + } if length >= 0 { log.Debug().Str("func", "PUTFile").Int64("Content-Length", length).Msg("setting header") req.Header.Set("Content-Length", strconv.FormatInt(length, 10)) From be5990dde30f67277d830f4f91b2508f6b43cf06 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 9 Jun 2021 10:46:25 +0200 Subject: [PATCH 27/38] Use the embedded eos grpc proto --- pkg/eosclient/eosgrpc/eosgrpc.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/eosclient/eosgrpc/eosgrpc.go b/pkg/eosclient/eosgrpc/eosgrpc.go index ef98fdbdd3..d173f57cfa 100644 --- a/pkg/eosclient/eosgrpc/eosgrpc.go +++ b/pkg/eosclient/eosgrpc/eosgrpc.go @@ -41,7 +41,6 @@ import ( "github.com/cs3org/reva/pkg/errtypes" "github.com/cs3org/reva/pkg/logger" "github.com/cs3org/reva/pkg/storage/utils/acl" - erpc "github.com/ffurano/grpc-proto/protobuf" "github.com/google/uuid" "github.com/pkg/errors" "github.com/rs/zerolog/log" From 8294b0e2d6102fb7ae6000c2074860a422fd0ae3 Mon Sep 17 00:00:00 2001 From: Fabrizio Furano Date: Fri, 11 Jun 2021 10:52:42 +0200 Subject: [PATCH 28/38] mod tidy --- go.mod | 1 - go.sum | 2 -- 2 files changed, 3 deletions(-) diff --git a/go.mod b/go.mod index a6e1744c82..32a7e44aa4 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,6 @@ require ( github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/eventials/go-tus v0.0.0-20200718001131-45c7ec8f5d59 github.com/gdexlab/go-render v1.0.1 - github.com/ffurano/grpc-proto v0.0.0-20210312134900-65801a1ca184 github.com/go-ldap/ldap/v3 v3.3.0 github.com/go-sql-driver/mysql v1.6.0 github.com/golang/protobuf v1.5.2 diff --git a/go.sum b/go.sum index d59000e13d..99e4e1d397 100644 --- a/go.sum +++ b/go.sum @@ -189,8 +189,6 @@ github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/fatih/structs v1.0.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= -github.com/ffurano/grpc-proto v0.0.0-20210312134900-65801a1ca184 h1:8sEVFrVAFCen9fYexSRHOnJgkat6dWpCX9W+WZxxaKE= -github.com/ffurano/grpc-proto v0.0.0-20210312134900-65801a1ca184/go.mod h1:tVK5FalFRrPhludOXg3eSQ/9sMpi/b6mav+UHAm8OWc= github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= From e85adadd9c7c14650ac817255e9ca7b5202f4e9a Mon Sep 17 00:00:00 2001 From: Fabrizio Furano Date: Fri, 11 Jun 2021 11:10:21 +0200 Subject: [PATCH 29/38] make the http options local to Client --- pkg/eosclient/eosgrpc/eosgrpc.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/eosclient/eosgrpc/eosgrpc.go b/pkg/eosclient/eosgrpc/eosgrpc.go index d173f57cfa..da68a22c29 100644 --- a/pkg/eosclient/eosgrpc/eosgrpc.go +++ b/pkg/eosclient/eosgrpc/eosgrpc.go @@ -150,7 +150,14 @@ func (c *Client) GetHTTPCl() *ehttp.Client { // GetHTTPCl creates an http client for immediate usage, using the already instantiated resources func (c *Client) GetHTTPCl() *ehttp.Client { - return ehttp.New(&c.opt.httpopts) + var htopts ehttp.Options + + if htopts.Init() != nil { + panic("Cant't init the EOS http client options") + } + htopts.BaseURL = c.opt.URL + + return ehttp.New(&htopts) } // Create and connect a grpc eos Client From 21da2044c24856820727e5c68aeff4272774cb14 Mon Sep 17 00:00:00 2001 From: Fabrizio Furano Date: Mon, 14 Jun 2021 16:48:48 +0200 Subject: [PATCH 30/38] Keep the http transport struct on a per EOS instance base, and make all of its parameters configurable --- pkg/eosclient/eosgrpc/eosgrpc.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/eosclient/eosgrpc/eosgrpc.go b/pkg/eosclient/eosgrpc/eosgrpc.go index da68a22c29..006be99369 100644 --- a/pkg/eosclient/eosgrpc/eosgrpc.go +++ b/pkg/eosclient/eosgrpc/eosgrpc.go @@ -152,12 +152,13 @@ func (c *Client) GetHTTPCl() *ehttp.Client { func (c *Client) GetHTTPCl() *ehttp.Client { var htopts ehttp.Options - if htopts.Init() != nil { + t, err := htopts.Init() + if err != nil { panic("Cant't init the EOS http client options") } htopts.BaseURL = c.opt.URL - return ehttp.New(&htopts) + return ehttp.New(&htopts, t) } // Create and connect a grpc eos Client From beb6c8272a521db6ea686d454bba5762f9fae106 Mon Sep 17 00:00:00 2001 From: Fabrizio Furano Date: Thu, 17 Jun 2021 12:17:15 +0200 Subject: [PATCH 31/38] Don't reinitialize the http options and transport when creating a client. Use the golang url class to parse urls --- pkg/eosclient/eosgrpc/eos_http/eoshttp.go | 1 + pkg/eosclient/eosgrpc/eosgrpc.go | 8 +------- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/pkg/eosclient/eosgrpc/eos_http/eoshttp.go b/pkg/eosclient/eosgrpc/eos_http/eoshttp.go index 7c7448ebae..414827c418 100644 --- a/pkg/eosclient/eosgrpc/eos_http/eoshttp.go +++ b/pkg/eosclient/eosgrpc/eos_http/eoshttp.go @@ -27,6 +27,7 @@ import ( "net/http" "net/url" "os" + "path" "strconv" "strings" "time" diff --git a/pkg/eosclient/eosgrpc/eosgrpc.go b/pkg/eosclient/eosgrpc/eosgrpc.go index 006be99369..d35d6a38bc 100644 --- a/pkg/eosclient/eosgrpc/eosgrpc.go +++ b/pkg/eosclient/eosgrpc/eosgrpc.go @@ -152,13 +152,7 @@ func (c *Client) GetHTTPCl() *ehttp.Client { func (c *Client) GetHTTPCl() *ehttp.Client { var htopts ehttp.Options - t, err := htopts.Init() - if err != nil { - panic("Cant't init the EOS http client options") - } - htopts.BaseURL = c.opt.URL - - return ehttp.New(&htopts, t) + return ehttp.New(&c.htopts, c.httptransport) } // Create and connect a grpc eos Client From a181d4fe414ea22b9dfca65f10261a7f31fa3cef Mon Sep 17 00:00:00 2001 From: Fabrizio Furano Date: Thu, 17 Jun 2021 13:28:18 +0200 Subject: [PATCH 32/38] Http EOS client: more robust url parsing --- pkg/eosclient/eosgrpc/eos_http/eoshttp.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/eosclient/eosgrpc/eos_http/eoshttp.go b/pkg/eosclient/eosgrpc/eos_http/eoshttp.go index 414827c418..7c7448ebae 100644 --- a/pkg/eosclient/eosgrpc/eos_http/eoshttp.go +++ b/pkg/eosclient/eosgrpc/eos_http/eoshttp.go @@ -27,7 +27,6 @@ import ( "net/http" "net/url" "os" - "path" "strconv" "strings" "time" From 76d5283951092a1ad3ee13c4be2d39d9e2c5c5e5 Mon Sep 17 00:00:00 2001 From: Fabrizio Furano Date: Thu, 1 Jul 2021 15:34:19 +0200 Subject: [PATCH 33/38] remove double func --- pkg/eosclient/eosgrpc/eosgrpc.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/pkg/eosclient/eosgrpc/eosgrpc.go b/pkg/eosclient/eosgrpc/eosgrpc.go index d35d6a38bc..e23a300026 100644 --- a/pkg/eosclient/eosgrpc/eosgrpc.go +++ b/pkg/eosclient/eosgrpc/eosgrpc.go @@ -148,13 +148,6 @@ func (c *Client) GetHTTPCl() *ehttp.Client { return ehttp.New(&c.htopts, c.httptransport) } -// GetHTTPCl creates an http client for immediate usage, using the already instantiated resources -func (c *Client) GetHTTPCl() *ehttp.Client { - var htopts ehttp.Options - - return ehttp.New(&c.htopts, c.httptransport) -} - // Create and connect a grpc eos Client func newgrpc(ctx context.Context, opt *Options) (erpc.EosClient, error) { log := appctx.GetLogger(ctx) From f6f63569fe19a2adcf257d4d491f3d465f32abde Mon Sep 17 00:00:00 2001 From: Fabrizio Furano Date: Thu, 1 Jul 2021 15:36:21 +0200 Subject: [PATCH 34/38] remove duplicated lines --- pkg/storage/utils/eosfs/eosfs.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pkg/storage/utils/eosfs/eosfs.go b/pkg/storage/utils/eosfs/eosfs.go index 34447802bc..39e0186cea 100644 --- a/pkg/storage/utils/eosfs/eosfs.go +++ b/pkg/storage/utils/eosfs/eosfs.go @@ -882,11 +882,6 @@ func (fs *eosfs) GetQuota(ctx context.Context) (uint64, uint64, error) { return 0, 0, errors.Wrap(err, "eosfs: no uid in ctx") } - uid, _, err := fs.getUserUIDAndGID(ctx, u) - if err != nil { - return 0, 0, errors.Wrap(err, "eos: no uid in ctx") - } - rootUID, rootGID, err := fs.getRootUIDAndGID(ctx) if err != nil { return 0, 0, err From d57dbe6e3e06743ce20b43c822c8a43bd55e91ef Mon Sep 17 00:00:00 2001 From: Fabrizio Furano Date: Wed, 7 Jul 2021 09:49:34 +0200 Subject: [PATCH 35/38] Populate the FileInfo.XS field with the file checksum --- pkg/eosclient/eosgrpc/eosgrpc.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pkg/eosclient/eosgrpc/eosgrpc.go b/pkg/eosclient/eosgrpc/eosgrpc.go index e23a300026..ea4db75db3 100644 --- a/pkg/eosclient/eosgrpc/eosgrpc.go +++ b/pkg/eosclient/eosgrpc/eosgrpc.go @@ -21,6 +21,7 @@ package eosgrpc import ( "bytes" "context" + "encoding/hex" "fmt" "io" "io/ioutil" @@ -1490,6 +1491,14 @@ func (c *Client) grpcMDResponseToFileInfo(st *erpc.MDResponse, namepfx string) ( fi.Size = st.Fmd.Size + xs := &eosclient.Checksum{ + XSSum: hex.EncodeToString(st.Fmd.Checksum.Value), + XSType: st.Fmd.Checksum.Type, + } + fi.XS = xs + + log.Debug().Str("stat info - path", fi.File).Uint64("inode", fi.Inode).Uint64("uid", fi.UID).Uint64("gid", fi.GID).Str("etag", fi.ETag).Str("checksum", fi.XS.XSType+":"+fi.XS.XSSum).Msg("grpc response") + } else { fi.Inode = st.Cmd.Id fi.UID = st.Cmd.Uid @@ -1513,9 +1522,9 @@ func (c *Client) grpcMDResponseToFileInfo(st *erpc.MDResponse, namepfx string) ( } fi.Size = 0 - } - log.Debug().Str("stat info - path", fi.File).Uint64("inode:", fi.Inode).Uint64("uid:", fi.UID).Uint64("gid:", fi.GID).Str("etag:", fi.ETag).Msg("grpc response") + log.Debug().Str("stat info - path", fi.File).Uint64("inode", fi.Inode).Uint64("uid", fi.UID).Uint64("gid", fi.GID).Str("etag", fi.ETag).Msg("grpc response") + } return fi, nil } From 1008052a4b199ae34a19a988af5ea88d9315805a Mon Sep 17 00:00:00 2001 From: Fabrizio Furano Date: Wed, 7 Jul 2021 12:09:31 +0200 Subject: [PATCH 36/38] http client: Escape the url path being sent to eos --- pkg/eosclient/eosgrpc/eos_http/eoshttp.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/eosclient/eosgrpc/eos_http/eoshttp.go b/pkg/eosclient/eosgrpc/eos_http/eoshttp.go index 7c7448ebae..6b1340e572 100644 --- a/pkg/eosclient/eosgrpc/eos_http/eoshttp.go +++ b/pkg/eosclient/eosgrpc/eos_http/eoshttp.go @@ -239,7 +239,7 @@ func (c *Client) buildFullURL(urlpath, uid, gid string) (string, error) { return "", err } - u, err = u.Parse(urlpath) + u, err = u.Parse(url.PathEscape(urlpath)) if err != nil { return "", err } From 094a603e2c8112c6787ebc2a8388041ddb546b72 Mon Sep 17 00:00:00 2001 From: Fabrizio Furano Date: Wed, 7 Jul 2021 13:17:58 +0200 Subject: [PATCH 37/38] http client: Fix changelog --- changelog/unreleased/eosgrpc.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/changelog/unreleased/eosgrpc.md b/changelog/unreleased/eosgrpc.md index 567cf67f57..215059e3ff 100644 --- a/changelog/unreleased/eosgrpc.md +++ b/changelog/unreleased/eosgrpc.md @@ -1,3 +1,3 @@ -Enhancement: EOEGrpc progress. Logging discipline and error handling +Minor fixes to the grpc/http plugin: checksum, url escaping -https://github.com/cs3org/reva/pull/1471 +https://github.com/cs3org/reva/pull/1868 From f7e5f57fb73c13b587f91cf1c4a511ebf6684b55 Mon Sep 17 00:00:00 2001 From: Fabrizio Furano Date: Wed, 7 Jul 2021 14:05:20 +0200 Subject: [PATCH 38/38] http client: Fix changelog --- changelog/unreleased/eosgrpc.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog/unreleased/eosgrpc.md b/changelog/unreleased/eosgrpc.md index 215059e3ff..e598a5717c 100644 --- a/changelog/unreleased/eosgrpc.md +++ b/changelog/unreleased/eosgrpc.md @@ -1,3 +1,3 @@ -Minor fixes to the grpc/http plugin: checksum, url escaping +Bugfix: Minor fixes to the grpc/http plugin: checksum, url escaping https://github.com/cs3org/reva/pull/1868