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 <noreply@anthropic.com>
This commit is contained in:
Thomas SchweigerandClaude Opus 5 committed 2026-09-18 17:05:35 +02:00
1 parent 1770793f26
commit e788e6a742
2 files changed
+34

No files matched your search

@@ -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
@@ -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
}