From e788e6a7429df566844f2674e8a6460f7f0e6d2a Mon Sep 17 00:00:00 2001 From: Thomas Schweiger Date: Fri, 18 Sep 2026 17:05:35 +0200 Subject: [PATCH] fix(search): skip disabled spaces when reindexing all spaces Reindexing all spaces aborted on the first disabled space. The storage provider answers with "not found" for the root of a disabled space, so the tree walk failed and the error took the whole run down, leaving the remaining spaces unindexed. Skip disabled spaces and log them instead, they have to be indexed again once they have been enabled. Co-Authored-By: Claude Opus 5 --- .../unreleased/fix-reindex-disabled-spaces.md | 12 ++++++++++ .../search/pkg/service/grpc/v0/service.go | 22 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 changelog/unreleased/fix-reindex-disabled-spaces.md diff --git a/changelog/unreleased/fix-reindex-disabled-spaces.md b/changelog/unreleased/fix-reindex-disabled-spaces.md new file mode 100644 index 0000000000..f8572a60a1 --- /dev/null +++ b/changelog/unreleased/fix-reindex-disabled-spaces.md @@ -0,0 +1,12 @@ +Bugfix: Do not fail reindexing all spaces on disabled spaces + +Reindexing all spaces via `opencloud search index --all-spaces` aborted as soon +as it ran into a disabled space. The storage provider answers with "not found" +for the root of a disabled space, so the tree walk failed and took the whole run +down with it. Every space that had not been processed yet was left unindexed, +which also made the post upgrade reindex job of the helm charts fail. + +Disabled spaces are now skipped and logged, so they can be indexed again once +they have been enabled. + +https://github.com/opencloud-eu/opencloud/issues/3559 diff --git a/services/search/pkg/service/grpc/v0/service.go b/services/search/pkg/service/grpc/v0/service.go index dddb64d4b6..33a35ccf35 100644 --- a/services/search/pkg/service/grpc/v0/service.go +++ b/services/search/pkg/service/grpc/v0/service.go @@ -28,6 +28,10 @@ import ( "github.com/opencloud-eu/opencloud/services/search/pkg/search" ) +// _spaceStateTrashed is the value of the "trashed" opaque entry that the storage +// provider sets on disabled spaces. +const _spaceStateTrashed = "trashed" + // NewHandler returns a service implementation for Service. func NewHandler(opts ...Option) (searchsvc.SearchProviderHandler, error) { options := newOptions(opts...) @@ -144,12 +148,30 @@ func (s Service) IndexSpace(_ context.Context, in *searchsvc.IndexSpaceRequest, return errors.New(resp.GetStatus().GetMessage()) } + var skipped int for _, space := range resp.GetStorageSpaces() { + if utils.ReadPlainFromOpaque(space.GetOpaque(), _spaceStateTrashed) == _spaceStateTrashed { + // A disabled space cannot be traversed, the storage provider answers with + // "not found" for its root. Skip it instead of failing the whole run, it + // has to be indexed again once it has been enabled. + skipped++ + s.log.Warn(). + Str("space_id", space.GetId().GetOpaqueId()). + Msg("skipping disabled space, run the index command again after enabling it") + continue + } + if err := s.searcher.IndexSpace(space.GetId(), in.GetForceReindex()); err != nil { return err } } + if skipped > 0 { + s.log.Warn(). + Int("skipped_spaces", skipped). + Msg("skipped disabled spaces, they have to be indexed again after they have been enabled") + } + return nil }