Repository navigation
feat: clean up old revisions according to a cleanup strategy - #3778
Conversation
dda7e3d to
c863153
Compare
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 181 |
🟢 Coverage 79.15% diff coverage · +0.28% coverage variation
Metric Results Coverage variation ✅ +0.28% coverage variation (-1.00%) Diff coverage ✅ 79.15% diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (dc749a3) 94500 28684 30.35% Head commit (5e8a88a) 95042 (+542) 29111 (+427) 30.63% (+0.28%) 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 (#3778) 542 429 79.15% 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.
5026cda to
1103975
Compare
OpenCloud can now delete old file versions according to a cleanup strategy (opencloud-eu/opencloud#1419, opencloud-eu/opencloud#3778). - a new page, Cleaning Up Old Versions, in the storage configuration: what the cleanup does and when it runs, how to turn it on with OpenCloud Compose and other installations, the strategies explained with one example file throughout, how the age of a version is measured, how to try a strategy out, the background workers and the logs - the command to clean up versions on demand, in the maintenance commands: a dry run first, selecting the files, choosing the strategy, the output, a nightly cron job with a timeout, the exit codes - features and FAQ: versions are kept by default, administrators can have old ones deleted
1103975 to
463d83b
Compare
463d83b to
13b56eb
Compare
5ba90c2 to
411b6b4
Compare
OpenCloud can now delete old file versions according to a cleanup strategy (opencloud-eu/opencloud#1419, opencloud-eu/opencloud#3778). - a new page, Cleaning Up Old Versions, in the storage configuration: what the cleanup does and when it runs, how to turn it on with OpenCloud Compose and other installations, the strategies explained with one example file throughout, how the age of a version is measured, how to try a strategy out, the background workers and the logs - the command to clean up versions on demand, in the maintenance commands: a dry run first, selecting the files, choosing the strategy, the output, a nightly cron job with a timeout, the exit codes, and what to know when it runs while OpenCloud is running (versions in an open Versions panel, NATS for PosixFS) - features and FAQ: versions are kept by default, administrators can have old ones deleted
411b6b4 to
0f568a5
Compare
OpenCloud can now delete old file versions according to a cleanup strategy (opencloud-eu/opencloud#1419, opencloud-eu/opencloud#3778). - a new page, Cleaning Up Old Versions, in the storage configuration: what the cleanup does and when it runs, how to turn it on with OpenCloud Compose and other installations, the strategies explained with one example file throughout, how the age of a version is measured, how to try a strategy out, the background workers and the logs - the command to clean up versions on demand, in the maintenance commands: a dry run first, selecting the files, choosing the strategy, the output, a nightly cron job with a timeout, the exit codes, and what to know when it runs while OpenCloud is running (versions in an open Versions panel, NATS for PosixFS) - features and FAQ: versions are kept by default, administrators can have old ones deleted
0f568a5 to
9577974
Compare
9577974 to
b61e8b1
Compare
OpenCloud can now delete old file versions according to a cleanup strategy (opencloud-eu/opencloud#1419, opencloud-eu/opencloud#3778). - a new page, Cleaning Up Old Versions, in the storage configuration: what the cleanup does and when it runs, how to turn it on with OpenCloud Compose and other installations, the strategies explained with one example file throughout, how the age of a version is measured, how to try a strategy out, the background workers and the logs - the command to clean up versions on demand, in the maintenance commands: a dry run first, selecting the files, choosing the strategy, the output, a nightly cron job with a timeout, the exit codes, and what to know when it runs while OpenCloud is running (versions in an open Versions panel, NATS for PosixFS) - features and FAQ: versions are kept by default, administrators can have old ones deleted
e559fae to
677dd87
Compare
OpenCloud can now delete old file versions according to a cleanup strategy (opencloud-eu/opencloud#1419, opencloud-eu/opencloud#3778). - a new page, Cleaning Up Old Versions, in the storage configuration: what the cleanup does and when it runs, how to turn it on with OpenCloud Compose and other installations, the strategies explained with one example file throughout, how the age of a version is measured, how to try a strategy out, the background workers and the logs - the command to clean up versions on demand, in the maintenance commands: a dry run first, selecting the files, choosing the strategy, the output, a nightly cron job with a timeout, the exit codes, and what to know when it runs while OpenCloud is running (the user to run it as, versions in an open Versions panel, NATS for PosixFS) - features and FAQ: versions are kept by default, administrators can have old ones deleted
3f8e70f to
3cab2ad
Compare
|
Rebased onto main, which uses reva Two changes to the command since the last version:
The README also says now that a restore keeps the revision of the content it replaced, as long as the file has the restored content, regardless of the strategy. The description is updated. Every commit builds from |
3cab2ad to
d47f996
Compare
|
A correction to my note above: with a cache local to each process, the server doesn't keep listing the deleted versions. It lists the versions of a file from disk, so a new list is right. What it doesn't learn about is that they were deleted: a list of versions that is already open, e.g. in the Versions panel, keeps showing them, and downloading or restoring one of them fails. The command still refuses to run with such a cache, unless |
OpenCloud can now delete old file versions according to a cleanup strategy (opencloud-eu/opencloud#1419, opencloud-eu/opencloud#3778). - a new page, Cleaning Up Old Versions, in the storage configuration: what the cleanup does and when it runs, how to turn it on with OpenCloud Compose and other installations, the strategies explained with one example file throughout, how the age of a version is measured, how to try a strategy out, the background workers and the logs - the command to clean up versions on demand, in the maintenance commands: a dry run first, selecting the files, choosing the strategy, the output, a nightly cron job with a timeout, the exit codes, and what to know when it runs while OpenCloud is running (the user to run it as, versions in an open Versions panel, NATS for PosixFS) - features and FAQ: versions are kept by default, administrators can have old ones deleted
80091c1 to
65722e3
Compare
|
|
||
| // RevisionsCleanup configures the deletion of old revisions, for the 'decomposed', 'decomposeds3' and 'posix' storage drivers | ||
| type RevisionsCleanup struct { | ||
| Strategy string `yaml:"strategy" env:"OC_REVISIONS_CLEANUP_STRATEGY" desc:"Which old revisions (versions) of a file to delete whenever the file gets a new revision. 'disabled' keeps all revisions. A strategy is a comma-separated list of up to three parts: a number of revisions, which counts from the newest one (e.g. '10'), a duration with one of the units 'w', 'd', 'h', 'm' or 's' (e.g. '30d'; with the uppercase units 'D' and 'W', days and weeks count from midnight, e.g. '1D'), and 'auto', which thins out revisions the older they get. 'X' deletes everything beyond X, e.g. '10', '30d', or '0' to delete all revisions. 'X, auto' keeps everything within X and thins out the older revisions, e.g. '14d, auto'. 'auto, X' deletes everything beyond X and thins out the rest, e.g. 'auto, 90d'. 'X1, X2' keeps everything within X1 and deletes everything beyond X2, e.g. '5, 30d'. 'X1, auto, X2' also thins out in between, e.g. '7d, auto, 90d'. The age of a revision is the time its content was written, i.e. the modification time the file had before it was changed, not the time of that change. Only files that get a new revision are cleaned up, including revisions created from changes on disk with posix. An invalid value makes the storage driver fail at startup." introductionVersion:"%%NEXT%%"` |
There was a problem hiding this comment.
Is there a particular reason for naming those variables OC_* instead of STORAGE_USERS_*? Until now we prefixed the names with the service they affect and only add OC_ variants if there are multiple services using them to configure all at once.
There was a problem hiding this comment.
No good reason, I wasn't aware of that convention. Only storage-users reads them, so they are STORAGE_USERS_REVISIONS_CLEANUP_* now, in all commits, and in the admin docs of opencloud-eu/docs#1222 too.
|
|
||
| // RevisionsCleanup configures the deletion of old revisions, for the 'decomposed', 'decomposeds3' and 'posix' storage drivers | ||
| type RevisionsCleanup struct { | ||
| Strategy string `yaml:"strategy" env:"OC_REVISIONS_CLEANUP_STRATEGY" desc:"Which old revisions (versions) of a file to delete whenever the file gets a new revision. 'disabled' keeps all revisions. A strategy is a comma-separated list of up to three parts: a number of revisions, which counts from the newest one (e.g. '10'), a duration with one of the units 'w', 'd', 'h', 'm' or 's' (e.g. '30d'; with the uppercase units 'D' and 'W', days and weeks count from midnight, e.g. '1D'), and 'auto', which thins out revisions the older they get. 'X' deletes everything beyond X, e.g. '10', '30d', or '0' to delete all revisions. 'X, auto' keeps everything within X and thins out the older revisions, e.g. '14d, auto'. 'auto, X' deletes everything beyond X and thins out the rest, e.g. 'auto, 90d'. 'X1, X2' keeps everything within X1 and deletes everything beyond X2, e.g. '5, 30d'. 'X1, auto, X2' also thins out in between, e.g. '7d, auto, 90d'. The age of a revision is the time its content was written, i.e. the modification time the file had before it was changed, not the time of that change. Only files that get a new revision are cleaned up, including revisions created from changes on disk with posix. An invalid value makes the storage driver fail at startup." introductionVersion:"%%NEXT%%"` |
There was a problem hiding this comment.
The age of a revision is the time its content was written, i.e. the modification time the file had before it was changed, not the time of that change. <- this is no longer correct with the latest changes in the reva PR.
There was a problem hiding this comment.
Right, I missed that one when the cleanup switched to the creation time. It now says: "The age of a revision is the time it was created, i.e. when the file was changed and its previous content became the revision, not the modification time of that content, which the version list shows." The same outdated text in the description of reva's option is fixed in opencloud-eu/reva#1041 (merged).
65722e3 to
31eb2fb
Compare
Wire reva's revision cleanup options into the 'decomposed', 'decomposeds3' and 'posix' drivers, in the storage provider and in the data provider. The options are a single 'revisions_cleanup' section of the storage-users configuration, next to 'filemetadata_cache' and 'id_cache', as only one driver is used at a time. Its environment variables: - STORAGE_USERS_REVISIONS_CLEANUP_STRATEGY: which old revisions to delete whenever a file gets a new revision, e.g. 'auto', '30d' or '7d, auto, 90d' - STORAGE_USERS_REVISIONS_CLEANUP_ASYNC: run the cleanup in background workers - STORAGE_USERS_REVISIONS_CLEANUP_ASYNC_WORKERS: number of background workers - STORAGE_USERS_REVISIONS_CLEANUP_ASYNC_QUEUE_SIZE: number of files that can wait - STORAGE_USERS_REVISIONS_CLEANUP_ASYNC_QUEUE_FULL: 'drop' or 'block' - STORAGE_USERS_REVISIONS_CLEANUP_ASYNC_QUEUE_FULL_TIMEOUT: how long 'block' waits for room at most, 0 for as long as it takes The strategy defaults to 'disabled', which keeps all revisions as before. The other defaults are reva's: background workers, with the number of workers and the queue size determined automatically, dropping the cleanup of a file when the queue is full (it is cleaned up with its next revision), and a timeout of 5s for 'block'. Other commands that create a driver, 'posixfs scan' and 'uploads sessions', clean up revisions without background workers: they could exit before the workers are done, and stop the cleanup of a file midway. Assisted-by: Claude Code:claude-opus-5-5
'opencloud storage-users revisions cleanup' deletes old revisions, according to a cleanup strategy, of: - the files of spaces (--space, repeatable), - or of a file or folder within a space (--space with --path), - or of all spaces (--all), - or of a file or folder given by its path on disk (--fs-path, posix only). The id of a file or folder is rejected as the id of a space, as the command would otherwise clean up its whole space. So is an id without a space id, e.g. 'storage$'. The storage-users service only cleans up the revisions of a file when it gets a new one. The command also covers the files that are not changed anymore, and applies a different strategy once. The strategy and the settings of the background workers default to the configured ones (STORAGE_USERS_REVISIONS_CLEANUP_*), and can be overridden with --strategy, --async, --workers and --queue-size. Only --queue-full defaults to 'block' without a timeout, whatever is configured: the command finds files faster than the workers clean them up, so dropping the files that find the queue full, or giving up after the timeout meant for uploads, would skip most of them. --queue-full-timeout sets one for the run. The command uses the storage driver directly, in its own process, like 'uploads sessions': posix neither scans nor watches the file system, and no driver joins the postprocessing consumer group of the service. For posix, the driver needs NATS for its event stream. The command waits for it 10 seconds at most, instead of the 15 minutes the stream retries for, and ctrl-c also stops that wait: with the single binary, NATS only runs within the server (opencloud-eu#3805). The driver gets the logger of the command: posix passes it on to the NATS connections of its id cache, whose handlers would panic on a lost connection without one. Ctrl-C also stops waiting for the driver, e.g. for the id cache, which retries for up to 15 minutes as well. Unless it is a dry run, which changes nothing on disk, the command warns when the storage belongs to another user than the one it runs as, e.g. root: the lock files it creates belong to that user, and the server may not be able to lock these files anymore. Output: a line for every file whose revisions were deleted, that failed or that was skipped, with its path within its space, and a summary; --verbose adds every file and every revision with the decision and its reason; --json prints the same as JSON objects, one per line, with a final summary object. --dry-run deletes nothing. --timeout stops the cleanup gracefully, as does ctrl-c, and a second ctrl-c ends the command right away, which can leave the blob of a deleted revision behind; the help says so. Whether the timeout or ctrl-c stopped the cleanup is told by the contexts of the command, not by the error: the storage can return context errors of its own. --shuffle walks the spaces and folders in a random order, so that repeated runs that are stopped by the timeout, e.g. from a cron job, eventually reach all files. The help explains that a file waiting for a lock can't be interrupted, and that a dry run changes nothing on disk, but decides on a snapshot, as it doesn't keep the files locked while it decides. The common flags have short forms: -a (--all), -p (--fs-path), -s (--strategy), -n (--dry-run), -v (--verbose), -j (--json) and -t (--timeout). Exit codes: - 0 when done, - 1 if the cleanup or any file failed, or if it was interrupted, - 2 if the timeout stopped the cleanup before all files were cleaned up. The storage-users README documents the command, along with the cleanup strategies and how they relate to the configured cleanup. Assisted-by: Claude Code:claude-opus-5-5
A new cliCommands feature, cleanupFileVersions.feature, tests the
"storage-users revisions cleanup" command against a running server,
checking the remaining versions through the WebDAV versions API:
- keeping the newest version of every file in all spaces
- a dry run, which deletes nothing
- only a folder within the personal space (--space with --path)
- only a project space (--space)
- the JSON output (--json)
- no strategy while the configured one is disabled: exit code 1
- a timeout: exit code 2, nothing deleted
- a strategy without spaces after its commas ("auto,1"), as the CLI
wrapper splits commands on spaces
- a folder by its path on disk (--fs-path), posix only
- the configured strategy (STORAGE_USERS_REVISIONS_CLEANUP_STRATEGY),
which cleans up a file whenever it gets a new version: without
background workers, and with them, the default
- the configured strategy for uploads with TUS, as the web UI and the
clients upload
- the age of a version, which is the time its content was written:
uploads with an older modification time (X-OC-Mtime) make versions
that "30d" deletes right away, while "1,30d" keeps the newest one
- restoring a version with the strategy "0": the content from before
the restore is kept, so that the restore can be undone
A second feature, collaborativePosix/cleanupFileVersions.feature, tests
the versions that changes on the POSIX filesystem create, with
STORAGE_USERS_POSIX_ENABLE_FS_REVISIONS: the configured strategy cleans
up a file whenever a change on disk creates a version, with and without
background workers, and the command deletes such versions. The
collaborativePosix suite doesn't run in the CI for now
(opencloud-eu#2036), so these
scenarios are ready for when it does again; they pass locally. The
suite gets the FilesVersionsContext, whose steps its existing version
scenarios already use.
New steps: in CliContext, running the command for all spaces, a space,
a path within a space, a path on the POSIX filesystem, or with flags
only; checking the exact exit code; and checking the objects of a JSON
output, which "the command output should contain" can't match as it
contains quotes. In FilesVersionsContext, a number of versions that is
checked until it matches, for the cleanup that runs in the background
after postprocessing. In WebDav, the Given form of an upload with
content and a modification time.
Assisted-by: Claude Code:claude-opus-5-5
…ocal to each process
The revisions cleanup command runs in a process of its own. With a file
metadata cache that each process keeps in its own memory ('memory', the
default, or 'ocmem'), the server doesn't learn about the revisions the
command deletes: a list of versions that is already open, e.g. in the
Versions panel, keeps showing them, and downloading or restoring one of
them fails. A new list is right, as the server lists them from disk.
The command now refuses to run with such a cache. The error says how to
share the cache (STORAGE_USERS_FILEMETADATA_CACHE_STORE=nats-js-kv, not
OC_CACHE_STORE, which sets the cache store of all services) and that
--allow-local-cache runs it anyway. A dry run deletes nothing and runs
with any cache.
The acceptance tests pass --allow-local-cache: their server runs with the
default cache, and they check the versions through the API, which lists
them from disk.
Assisted-by: Claude Code:claude-opus-5-5
The revision cleanup doesn't apply the strategy to the revision a restore created of the content it replaced, not even an age limit, as long as the file has the restored content. Say so next to the strategies, as it is an exception admins wouldn't expect. Assisted-by: Claude Code:claude-opus-5-5
…s own A dry run reads the metadata of every file it looks at. With a file metadata cache shared with the server, e.g. 'nats-js-kv', it filled that cache with entries for all of them, for a run that changes nothing. A dry run now always keeps its file metadata cache in its own memory, whatever is configured. It doesn't need the shared cache: it deletes nothing the server would have to see, and a cache of its own starts empty, so it reads the metadata from disk. A real run still uses the configured cache, which must be shared. Assisted-by: Claude Code:claude-opus-5-5
…does The revisions cleanup command, its help and the README said that, with a cache local to each process, the server would keep listing the revisions the command deleted until their cache entries expire or it restarts. It doesn't: the server lists the revisions of a file from disk. What it doesn't learn about is that they were deleted, so a list of versions that is already open, e.g. in the Versions panel, keeps showing them, and downloading or restoring one of them fails. The command still refuses to run with such a cache, unless --allow-local-cache is given: a shared cache is the right setup for a command that changes the storage next to the server. Assisted-by: Claude Code:claude-opus-5-5
Follows opencloud-eu/reva#895, which makes the revision cleanup go by the time a revision was created, recorded by the server, instead of the modification time of its content, which clients choose with X-OC-Mtime. "auto" keeps the oldest revision of each slot (opencloud-eu#3735). - The storage-users README explains the new age of a revision. - The acceptance scenario outline that checked the age as the time the content was written is replaced by two scenarios: versions whose content is dated 60 and 50 days ago are kept by "30d", and a version with content dated 10 years ahead doesn't push out the newest one under "1". Assisted-by: Claude Code:claude-opus-5-5
31eb2fb to
5e8a88a
Compare
OpenCloud can now delete old file versions according to a cleanup strategy (opencloud-eu/opencloud#1419, opencloud-eu/opencloud#3778). - a new page, Cleaning Up Old Versions, in the storage configuration: what the cleanup does and when it runs, how to turn it on with OpenCloud Compose and other installations, the strategies explained with one example file throughout, how the age of a version is measured, how to try a strategy out, the background workers and the logs - the command to clean up versions on demand, in the maintenance commands: a dry run first, selecting the files, choosing the strategy, the output, a nightly cron job with a timeout, the exit codes, and what to know when it runs while OpenCloud is running (the user to run it as, versions in an open Versions panel, NATS for PosixFS) - features and FAQ: versions are kept by default, administrators can have old ones deleted
OpenCloud can now delete old file versions according to a cleanup strategy (opencloud-eu/opencloud#1419, opencloud-eu/opencloud#3778). - a new page, Cleaning Up Old Versions, in the storage configuration: what the cleanup does and when it runs, how to turn it on with OpenCloud Compose and other installations, the strategies explained with one example file throughout, how the age of a version is measured, how to try a strategy out, the background workers and the logs - the command to clean up versions on demand, in the maintenance commands: a dry run first, selecting the files, choosing the strategy, the output, a nightly cron job with a timeout, the exit codes, and what to know when it runs while OpenCloud is running (the user to run it as, versions in an open Versions panel, NATS for PosixFS) - features and FAQ: versions are kept by default, administrators can have old ones deleted
Description
The OpenCloud side of the revision cleanup: old revisions (versions) of files are deleted according to a configurable cleanup strategy, for the
decomposed,decomposeds3andposixstorage drivers. The cleanup itself is in reva, opencloud-eu/reva#895; this PR configures it and adds a command to run it on demand.opencloud-eu/reva#895 is merged, and
mainalready has a reva version with it (bumped in #4065), so this PR needs no reva bump of its own.Configuration
A
revisions_cleanupsection of the storage-users configuration, passed to all three drivers, in the storage provider and the data provider:STORAGE_USERS_REVISIONS_CLEANUP_STRATEGYdisabledauto,30d,10,5, 30dor7d, auto, 90dSTORAGE_USERS_REVISIONS_CLEANUP_ASYNCtrueSTORAGE_USERS_REVISIONS_CLEANUP_ASYNC_WORKERS0(half the CPUs, at least 2)STORAGE_USERS_REVISIONS_CLEANUP_ASYNC_QUEUE_SIZE0(64 per worker)STORAGE_USERS_REVISIONS_CLEANUP_ASYNC_QUEUE_FULLdropdropskips the cleanup of that file until its next revision,blockwaits for room, up to the timeoutSTORAGE_USERS_REVISIONS_CLEANUP_ASYNC_QUEUE_FULL_TIMEOUT5sblockwaits for room at most, after which the cleanup is skipped as withdrop;0waits as long as it takesThe default keeps all revisions, as before. An invalid strategy makes the storage-users service fail at startup. The storage provider and the data provider share one cleanup, with one set of background workers, per storage (see opencloud-eu/reva#895). Other commands that create a storage driver,
posixfs scananduploads sessions, clean up without background workers, as they could exit before the workers are done.opencloud storage-users revisions cleanupThe service only cleans up a file when it gets a new revision. The command covers the files that aren't changed anymore, and applies a different strategy once, e.g. after the strategy was changed or to free storage:
--space(repeatable, with--pathfor a file or folder within the space),--all, or--fs-path(a file or folder by its path on disk, posix only); the id of a file or folder (<storage>$<space>!<node>) is rejected as a space, instead of cleaning up its whole space, and so is an id without a space id (<storage>$);--strategyand the settings of the background workers (--async,--workers,--queue-size) default to the configured ones; only--queue-fulldefaults toblockwithout a timeout (--queue-full-timeout 0), whatever is configured, as the command finds files faster than the workers clean them up, and dropping the ones that find the queue full would skip most of them;--verboseadds every revision with the decision and its reason;--jsonprints JSON objects, one per line;--dry-rundeletes nothing and changes nothing on disk, not even lock files: it doesn't keep the files locked while it decides, so its decisions are a snapshot. It always keeps its file metadata cache in its own memory, whatever is configured, so that it doesn't fill a shared cache with the metadata of every file it looks at;--timeoutstops gracefully, as does ctrl-c (orSIGTERM), which counts as a failure, though; a second ctrl-c ends the command right away, which can leave the blob of a deleted revision behind;--shufflewalks the spaces and folders in a random order, so that repeated runs, e.g. a nightly cron job, eventually reach all files;SIGTERM), 2 if the timeout stopped it before all files were cleaned up.Short flags:
-a,-p,-s,-n,-v,-j,-t. The command uses the storage driver directly, in its own process, likeuploads sessions: posix neither scans nor watches the file system, and no driver joins the postprocessing consumer group.The file metadata cache must be shared. The command runs in a process of its own: with a cache that each process keeps in its own memory (
memory, the default, orocmem), the server doesn't learn about the revisions the command deletes. It lists the versions of a file from disk all the same, so a new list is right, but a list that is already open, e.g. in the Versions panel, keeps showing the deleted versions, and downloading or restoring one of them fails. Unless it is a dry run, the command therefore refuses to run with such a cache. The error names the fix,STORAGE_USERS_FILEMETADATA_CACHE_STORE=nats-js-kv(OC_CACHE_STOREwould switch the cache of all services), and--allow-local-cacheruns it anyway. As long asmemoryis the default, this is what admins see on a default setup; #4064 proposesnats-js-kvas the default. The acceptance tests pass--allow-local-cache, as their server runs with the default cache.It has to run as the user OpenCloud runs as: the lock files it creates belong to the user that runs it, and OpenCloud may not be able to open them otherwise. Unless it is a dry run, it warns when the storage belongs to another user. A shared check for all commands that write to the storage is proposed in #4042.
The storage-users README documents the configuration, the strategies, the command and its output, with examples. The admin documentation in opencloud-eu/docs follows separately.
Commits
feat: 1419: configure the revision cleanup of the storage-users driversfeat: 1419: add a command to clean up old revisions on demandtest: 1419: acceptance tests for the revision cleanupfeat: 1419: refuse to clean up revisions with a file metadata cache local to each processdocs: 1419: a restore keeps the revision of the replaced contentfeat: 1419: let a dry run of the revisions cleanup keep a cache of its ownfix: 1419: describe what a file metadata cache local to each process doesfeat: 1419: clean up revisions by the time they were createdEvery commit builds from
vendor/and passes the storage-users tests.Related Issue
Motivation and Context
Every change to a file keeps the previous content as a revision, forever. Without a cleanup, revisions accumulate and use up storage, and the only way to get rid of them was to delete the files or to disable versioning, which keeps the revisions that exist. #1419 asks for a configurable cleanup that runs automatically, without slowing down writes, and that can also be run on demand for spaces, folders or files.
How Has This Been Tested?
revaconfig), and the command: flag validation, the strategy and worker defaults, the refusal with a cache local to each process and--allow-local-cache, the own cache of a dry run, text and JSON output, the exit codes (command)tests/acceptance/features/cliCommands/cleanupFileVersions.feature, with 15 scenarios against a running server (14 without posix), checking the remaining versions through the WebDAV versions API: all spaces, a dry run, a folder within the personal space, a project space, the JSON output, no strategy while the configured one is disabled (exit code 1), a timeout (exit code 2), a strategy without spaces after its commas, a folder by its path on disk (posix only), the configured strategy cleaning up on every new version, without and with background workers (the default), also for uploads with TUS, the age of a version as the time it was created (30dkeeps versions whose content is dated 60 and 50 days ago), a version with content dated 10 years ahead that doesn't push out the newest one under1, and a restore that can be undone, as the content from before it is kept. Run locally on posix (15/15) and decomposed (14/14, the posix-only scenario is skipped), last on 2026-11-24, after the rebase onto main (reva at 20c6e7824); the dry run also withSTORAGE_USERS_FILEMETADATA_CACHE_STORE=nats-js-kv(2026-11-18).tests/acceptance/features/collaborativePosix/cleanupFileVersions.feature, with 3 scenarios for the versions that changes on disk create (STORAGE_USERS_POSIX_ENABLE_FS_REVISIONS): the configured strategy cleans them up, with and without background workers, and so does the command. ThecollaborativePosixsuite doesn't run in the CI for now (watch-fs. Flaky api tests #2036), so they are ready for when it does again; they passed locally 4 times in a row, and again with reva at a37f627e2. Since the rebase onto main, they sometimes fail at their very first upload, which comes back empty: that is posix: uploads of new files lose their content with the fs watcher and a short scan debounce delay (also the driver's default of 10ms) reva#1062 (new uploads lose their content when the posix watcher reacts quickly), not the cleanup (2026-11-24: one of two runs passed, in the other, two scenarios failed that way).Types of 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.