Skip to content

feat: 4076: a revision cleanup strategy per type of space - #1042

Merged
pbleser-oc merged 5 commits into
opencloud-eu:mainfrom
pbleser-oc:feat/4076-strategy-per-space-type
Nov 23, 2026
Merged

pbleser-oc merged 5 commits into
opencloud-eu:mainfrom
pbleser-oc:feat/4076-strategy-per-space-type

Conversation

@pbleser-oc

Copy link
Copy Markdown
Member

Part of opencloud-eu/opencloud#4076: a revision cleanup strategy per type of space.

The revision cleanup (#895) has a single strategy for all spaces. With this PR, personal and project spaces can have strategies of their own:

Option Meaning
revisions_cleanup_strategy the default, as before
revisions_cleanup_strategy_personal the strategy of the personal spaces; empty: the default applies, disabled: keep all their revisions
revisions_cleanup_strategy_project the same for the project spaces

Spaces of any other type get the default.

How

  • revisioncleanup.Policy holds the strategies, and CleanerFor picks the one of a file, by layers, the most specific first: a forced strategy (an on-demand run's Request.Strategy), the strategy of the type of the file's space, the default. It decides by the file, so that the per-space strategies of Per-space revision cleanup strategies opencloud#3733 (an attribute on the space root), and possibly rules by file type or size, can be added as more layers later.
  • The Service and Run hold a Policy instead of a single Cleaner. The space type is only read when there are strategies per type, and costs no extra read: ReadNode has the space root's attributes cached already.
  • The Service is enabled when any strategy is. Files in a space whose type has disabled are still queued, and skipped by the worker, which reads the node anyway.
  • Result says which strategy applied and where it came from (forced, space type, default), for the output of the command.
  • An on-demand Request can replace the strategy of a type for its run (StrategyPersonal, StrategyProject). Combined with Strategy, which forces one strategy on all spaces, it is rejected.
  • The counters of deleted revisions, deleted bytes and failed deletions get a space_type label: personal, project, or other. They are not in a release yet, so no existing series change.
  • storagespace.TypePersonal and TypeProject are exported, for this and for opencloud's configuration. The private copies of these names in other packages are left for a separate change.

Commits

  1. storagespace: export the space types
  2. the Policy and the two options
  3. the Service and Run use the Policy
  4. on-demand runs can replace the strategy of a type
  5. the space_type label of the counters

Each commit builds and passes the tests of pkg/storagespace, pkg/storage/pkg/decomposedfs/... and pkg/storage/fs/posix/....

The opencloud side (the environment variables STORAGE_USERS_REVISIONS_CLEANUP_STRATEGY_PERSONAL / _PROJECT, the command's --strategy-personal / --strategy-project, acceptance tests) follows once this is merged and opencloud-eu/opencloud#3778 is in.

AI assistance: Claude Code (claude-opus-5-5) wrote the code, the tests and this description, after the design was agreed with me.

The space types "personal" and "project" are spelled out in many places,
as literals or as private constants of each package. The revision cleanup
is about to choose a strategy by the type of a space, and opencloud needs
the same names for its configuration, so storagespace exports them now.

The existing private copies are left alone here, switching them over is a
change of its own.

Assisted-by: Claude Code:claude-opus-5-5
The revision cleanup has a single strategy for all spaces, while personal
and project spaces often need different ones: few versions of personal
files, more of the files a team works on together.

The new options revisions_cleanup_strategy_personal and
revisions_cleanup_strategy_project set the strategy of one type of space.
Empty leaves that type to revisions_cleanup_strategy, "disabled" keeps
all revisions of its spaces, and any other type of space gets
revisions_cleanup_strategy.

A Policy holds these strategies, and CleanerFor picks the one of a file: a
forced strategy, e.g. given to a command for a single run, otherwise the
strategy of the type of the file's space, otherwise the default. It reads
the type of the space only when there are strategies per type. As it
decides by the file, which knows its space root, more layers can be added
later: the settings of a space itself, from an attribute of its root, and
rules by the type or the size of the file.

Nothing uses the Policy yet.

Assisted-by: Claude Code:claude-opus-5-5
… space

The revision cleanup Service, and an on-demand Run, now hold a Policy
instead of a single Cleaner, and choose the strategy of each file from its
space when they clean it up. So revisions_cleanup_strategy_personal and
revisions_cleanup_strategy_project take effect, for uploads, restores and
changes on disk as well as for the cleanup on demand.

The Service is enabled as soon as any of the strategies is. Files in a
space whose type has the strategy "disabled" are still queued, as the
strategy is only chosen when a worker reads the file anyway, and are then
skipped. A file whose strategy can't be chosen, as the type of its space
can't be read, is not cleaned up: its Result has the error.

The Result says which strategy applied, and which setting it came from, so
that the output of a command can tell. The instances of a storage in a
process must agree on all strategies now, not only the default one.

The strategy given to an on-demand cleanup is forced on all spaces of the
run, as it was before, when there was only one.

Assisted-by: Claude Code:claude-opus-5-5
… a space type

A Request can now give the strategy of the personal and of the project
spaces for its run (StrategyPersonal, StrategyProject), in place of the
configured ones, e.g. to try a stricter strategy for project spaces in a
dry run. The other types keep their configured strategy.

Strategy still forces one strategy on all spaces, and would override the
ones per type, so a request that gives both is rejected.

Assisted-by: Claude Code:claude-opus-5-5
With a strategy per type of space, an admin wants to see what each of them
deletes. The counters of deleted revisions, deleted bytes and failed
deletions now have a space_type label: personal, project, or other for any
other type of space, and when the type can't be read, so that each counter
has at most three series, whatever types of spaces exist.

The counters are not in a release yet, so no existing series change.

Assisted-by: Claude Code:claude-opus-5-5
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 59 complexity · 1 duplication

Metric Results
Complexity 59
Duplication 1

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants