From 9856ef4f8316fa4642c53749ffd033b5dc6d0b10 Mon Sep 17 00:00:00 2001 From: Florian Schade Date: Thu, 10 Oct 2024 10:06:08 +0200 Subject: [PATCH] fix: reduce logs when auto accepting shares fails because the share was already unshared before accepting it --- changelog/unreleased/fix-group-sharing-panic.md | 7 +++++++ services/frontend/pkg/command/events.go | 14 ++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 changelog/unreleased/fix-group-sharing-panic.md diff --git a/changelog/unreleased/fix-group-sharing-panic.md b/changelog/unreleased/fix-group-sharing-panic.md new file mode 100644 index 00000000000..5032b2362cd --- /dev/null +++ b/changelog/unreleased/fix-group-sharing-panic.md @@ -0,0 +1,7 @@ +Bugfix: Fix panic when sharing with groups + +We fixed a bug which caused a panic when sharing with groups, this only happened under a heavy load. +Besides the bugfix, we also reduced the number of share auto accept log messages to avoid flooding the logs. + +https://github.com/owncloud/ocis/pull/10279 +https://github.com/owncloud/ocis/issues/10258 diff --git a/services/frontend/pkg/command/events.go b/services/frontend/pkg/command/events.go index 2487165533a..83ca24c7cac 100644 --- a/services/frontend/pkg/command/events.go +++ b/services/frontend/pkg/command/events.go @@ -8,6 +8,7 @@ import ( "github.com/cs3org/reva/v2/pkg/events/stream" "github.com/cs3org/reva/v2/pkg/rgrpc/todo/pool" "github.com/cs3org/reva/v2/pkg/utils" + "github.com/rs/zerolog" "go-micro.dev/v4/metadata" "google.golang.org/protobuf/types/known/fieldmaskpb" @@ -133,8 +134,17 @@ func AutoAcceptShares(ev events.ShareCreated, autoAcceptDefault bool, l log.Logg continue } - if resp.GetStatus().GetCode() != rpc.Code_CODE_OK { - l.Error().Interface("status", resp.GetStatus()).Str("userid", uid.GetOpaqueId()).Msg("unexpected status code while accepting share") + if code := resp.GetStatus().GetCode(); code != rpc.Code_CODE_OK { + // log unexpected status codes if a share cannot be accepted... + func() *zerolog.Event { + switch code { + // ... not found is not an error in the context of auto-accepting shares + case rpc.Code_CODE_NOT_FOUND: + return l.Debug() + default: + return l.Error() + } + }().Interface("status", resp.GetStatus()).Str("userid", uid.GetOpaqueId()).Msg("unexpected status code while accepting share") } }