From 2ec4e8098d8a3a25390e4967a5e1bd9ce0c730c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Duffeck?= Date: Wed, 20 Nov 2024 08:58:28 +0100 Subject: [PATCH] Add debug output --- internal/http/services/appprovider/appprovider.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/internal/http/services/appprovider/appprovider.go b/internal/http/services/appprovider/appprovider.go index 9d93b18621..9eb067f72a 100644 --- a/internal/http/services/appprovider/appprovider.go +++ b/internal/http/services/appprovider/appprovider.go @@ -31,6 +31,7 @@ import ( gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1" rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1" provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" + "github.com/cs3org/reva/v2/pkg/appctx" ctxpkg "github.com/cs3org/reva/v2/pkg/ctx" "github.com/cs3org/reva/v2/pkg/rgrpc/status" "github.com/cs3org/reva/v2/pkg/rgrpc/todo/pool" @@ -141,8 +142,11 @@ func (s *svc) Handler() http.Handler { func (s *svc) handleNew(w http.ResponseWriter, r *http.Request) { ctx := r.Context() + log := appctx.GetLogger(ctx) + client, err := pool.GetGatewayServiceClient(s.conf.GatewaySvc) if err != nil { + log.Error().Err(err).Msg("error getting grpc gateway client") writeError(w, r, appErrorServerError, "error getting grpc gateway client", err) return } @@ -189,6 +193,7 @@ func (s *svc) handleNew(w http.ResponseWriter, r *http.Request) { } parentContainer, err := client.Stat(ctx, statParentContainerReq) if err != nil { + log.Error().Err(err).Msg("error statting the parent container") writeError(w, r, appErrorServerError, "error sending a grpc stat request", err) return } @@ -213,6 +218,7 @@ func (s *svc) handleNew(w http.ResponseWriter, r *http.Request) { } statFileRes, err := client.Stat(ctx, statFileReq) if err != nil { + log.Error().Err(err).Msg("error statting the file") writeError(w, r, appErrorServerError, "failed to stat the file", err) return } @@ -222,6 +228,7 @@ func (s *svc) handleNew(w http.ResponseWriter, r *http.Request) { writeError(w, r, appErrorAlreadyExists, "the file already exists", nil) return } + log.Error().Interface("statFileRes", statFileRes).Msg("statting the file returned unexpected status code") writeError(w, r, appErrorServerError, "statting the file returned unexpected status code", err) return } @@ -232,6 +239,7 @@ func (s *svc) handleNew(w http.ResponseWriter, r *http.Request) { touchRes, err := client.TouchFile(ctx, touchFileReq) if err != nil { + log.Error().Err(err).Msg("error touching the file") writeError(w, r, appErrorServerError, "error sending a grpc touchfile request", err) return } @@ -244,11 +252,13 @@ func (s *svc) handleNew(w http.ResponseWriter, r *http.Request) { // Stat the newly created file statRes, err := client.Stat(ctx, statFileReq) if err != nil { + log.Error().Err(err).Msg("error statting the created file") writeError(w, r, appErrorServerError, "statting the created file failed", err) return } if statRes.Status.Code != rpc.Code_CODE_OK { + log.Error().Interface("statRes", statRes).Msg("statting the created file returned unexpected status code") writeError(w, r, appErrorServerError, "statting the created file failed", nil) return } @@ -265,12 +275,14 @@ func (s *svc) handleNew(w http.ResponseWriter, r *http.Request) { }, ) if err != nil { + log.Error().Err(err).Msg("error marshalling JSON response") writeError(w, r, appErrorServerError, "error marshalling JSON response", err) return } w.Header().Set("Content-Type", "application/json") if _, err = w.Write(js); err != nil { + log.Error().Err(err).Msg("error writing JSON response") writeError(w, r, appErrorServerError, "error writing JSON response", err) return }