Skip to content

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

Open
pbleser-oc wants to merge 4 commits into
opencloud-eu:mainfrom
pbleser-oc:feat/4076-strategy-per-space-type
Open

pbleser-oc wants to merge 4 commits into
opencloud-eu:mainfrom
pbleser-oc:feat/4076-strategy-per-space-type

Conversation

@pbleser-oc

Copy link
Copy Markdown
Member

Description

A revision cleanup strategy per type of space. Until now, STORAGE_USERS_REVISIONS_CLEANUP_STRATEGY applied to all spaces. Personal and project spaces can now have strategies of their own, e.g. to keep fewer versions in the personal spaces than in the project spaces.

The cleanup in reva got this in opencloud-eu/reva#1042. This PR bumps reva and configures it.

Configuration

environment variable default meaning
STORAGE_USERS_REVISIONS_CLEANUP_STRATEGY disabled the default strategy, as before
STORAGE_USERS_REVISIONS_CLEANUP_STRATEGY_PERSONAL empty the strategy of the personal spaces; empty: the default applies; disabled: keep all their revisions, whatever the default is
STORAGE_USERS_REVISIONS_CLEANUP_STRATEGY_PROJECT empty the same for the project spaces

Spaces of any other type get the default. Like the default, both apply to all storage drivers that support the cleanup (decomposed, decomposeds3, posix), and an invalid one makes the storage-users service fail at startup.

For example, keep 10 versions or 30 days by default, but only 7 days and at most 5 versions in the personal spaces:

STORAGE_USERS_REVISIONS_CLEANUP_STRATEGY="10, 30d"
STORAGE_USERS_REVISIONS_CLEANUP_STRATEGY_PERSONAL="5, 7d"

opencloud storage-users revisions cleanup

  • --strategy-personal and --strategy-project replace the configured strategy of that space type for the run, e.g. to try a stricter strategy for the project spaces in a dry run, while the other spaces keep theirs.
  • --strategy keeps its meaning: one strategy for all spaces of the run, whatever their type. It can't be combined with the two new flags.
  • Without --strategy, the command no longer passes the configured default to the driver as the strategy of the run, as that would override the strategies of the space types. The driver applies the configured strategies by the type of each space.
  • The command checks every strategy before it opens the storage, naming the flag or the setting of an invalid one, and fails when none of them deletes anything.
  • --verbose shows the strategy of each file and where it came from (--strategy, the space type or the default); the JSON objects have strategy and strategy_source.
  • The files of a space whose strategy is disabled are only listed with --verbose, and not counted as skipped. Otherwise a run over all spaces would list every file of every space whose type keeps all revisions.

Commits

  1. chore: bump reva: brings feat: 4076: a revision cleanup strategy per type of space reva#1042 and docs: 1419: describe the age of a revision as the time it was created reva#1041 (the corrected description of the age of a revision), nothing else
  2. the configuration, and the README with examples
  3. the command's flags and output
  4. acceptance tests (cliCommands/cleanupFileVersions.feature)

Each commit builds, and the storage-users tests pass.

Related Issue

Motivation and Context

Personal and project spaces are used differently: project spaces are shared by teams, and often need their history for longer, while personal spaces are where most of the storage goes.

How Has This Been Tested?

  • unit tests: services/storage-users/...
  • acceptance tests, locally, on posix and decomposed: cliCommands/cleanupFileVersions.feature (posix: 18 scenarios, decomposed: 17), covering a configured project strategy that leaves the personal space alone, --strategy-project in a run over all spaces, and the error for --strategy with --strategy-personal.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

AI assistance: Claude Code (claude-opus-5-5) wrote most of the code, the tests and the texts; I reviewed every change before pushing it.

Brings the revision cleanup strategy per type of space
(opencloud-eu/reva#1042) and the corrected description of the age of a
revision in the strategy option (opencloud-eu/reva#1041).

Assisted-by: Claude Code:claude-opus-5-5
STORAGE_USERS_REVISIONS_CLEANUP_STRATEGY_PERSONAL and
STORAGE_USERS_REVISIONS_CLEANUP_STRATEGY_PROJECT set the revision cleanup
strategy of the personal and of the project spaces, for all storage
drivers that support the cleanup. Empty, the default, leaves the spaces of
that type to STORAGE_USERS_REVISIONS_CLEANUP_STRATEGY, "disabled" keeps
all their revisions. Spaces of any other type get
STORAGE_USERS_REVISIONS_CLEANUP_STRATEGY.

The revisions cleanup command no longer hands the configured default to
the storage driver as the strategy of the run: that one now applies to
all spaces, whatever their type, so the driver would ignore the strategies
of the space types. Without --strategy, the driver applies the configured
strategies itself, by the type of each space. --strategy still applies one
strategy to all spaces. The command checks every strategy before it opens
the storage, naming the flag or the setting of an invalid one, and fails
when none of them deletes anything.

The README explains the settings, with examples.

Assisted-by: Claude Code:claude-opus-5-5
…isions cleanup

The revisions cleanup command gets --strategy-personal and
--strategy-project, which replace the configured strategy of the personal
or the project spaces for the run, e.g. to try a stricter strategy for the
project spaces in a dry run, while the other spaces keep theirs.
--strategy applies one strategy to all spaces, so it can't be combined
with them.

--verbose shows the strategy of every file and where it came from
(--strategy, the space type or the default), and the JSON objects of the
files have it in strategy and strategy_source.

The files of a space whose strategy is "disabled" are skipped on purpose:
like the files with nothing to delete, they are only listed with
--verbose, and not counted as skipped. Otherwise a run over all spaces
would list every file of every space whose type keeps all revisions.

Assisted-by: Claude Code:claude-opus-5-5
…ace type

- A configured strategy of the project spaces cleans up a file in a
  project space when it gets a new version, and leaves the personal space
  alone.
- --strategy-project cleans up the project spaces in a run over all
  spaces, and the personal space keeps its versions.
- --strategy can't be combined with --strategy-personal.

Passes with posix (18 scenarios) and decomposed (17).

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

codacy-production Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 24 complexity

Metric Results
Complexity 24

View in Codacy

🟢 Coverage 92.63% diff coverage · +0.06% coverage variation

Metric Results
Coverage variation ✅ +0.06% coverage variation (-1.00%)
Diff coverage ✅ 92.63% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (0b73e9e) 95037 29280 30.81%
Head commit (c553112) 95114 (+77) 29358 (+78) 30.87% (+0.06%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#4111) 95 88 92.63%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

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.

revision cleanup: a strategy per type of space

1 participant