Skip to content

Merge Workpackages back to main - #957

Merged
butonic merged 101 commits into
mainfrom
workpackages
Nov 13, 2026
Merged

butonic merged 101 commits into
mainfrom
workpackages

Conversation

@butonic

@butonic butonic commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Brings the workpackages branch back into main. Most of it is the upload coordinator: the storage drivers no longer run uploads themselves.

Upload coordinator (#906, #934, #935, #936, #937, #949, #978, #1001)

  • pkg/upload receives the bytes for PUT and TUS, stages them in <upload dir>/<id> + <id>.info, verifies checksums, checks quota and locks, and either finishes the upload right away or hands it to postprocessing.
  • Drivers only implement PrepareUpload (write the node metadata before postprocessing), CommitUpload (write the bytes) and RollbackUpload. InitiateUpload, Upload, ListUploadSessions, the per driver session stores and the tus data store methods are gone (~5800 lines), including the legacy pkg/storage/pkg/decomposedfs/upload store and the DisableVersioning aspect.
  • Synchronous uploads on decomposed and decomposeds3 store the blob before the node points to it and never mark the node as processing. Nodes left processing by older versions heal on the first download (recoverInterruptedUpload).
  • Failed blob commits are retried with capped backoff and log the space and node id.
  • A denied TUS upload answers 403 instead of 500, staged uploads are served with byte ranges again (antivirus scans only the first bytes of large files), and orphaned upload sessions give their quota back (fix(decomposedfs): release the quota of orphaned upload sessions #951).
  • New config: upload_directory on the storageprovider and dataprovider services (needed for drivers without a local root), plus asyncfileuploads, mount_id and events.{numconsumers,consumer_group,commit_max_retries,commit_retry_backoff} read from the driver config by the coordinator.

Storage capabilities (#932)

  • Drivers can declare what they support (storage.CapabilityProvider), and the OCS capabilities report it per provider. Drivers without a declaration keep the old behaviour.

Space membership (#990, #992, #993, #994)

  • Expiring manager shares no longer count as the remaining manager, and an expiration can no longer be set on the last permanent manager.
  • Space root shares with some grant management bits but not the full manager permissions are rejected.
  • New spaces.server_managed capability (default false), and service accounts may update and list grants, so the server can manage space membership.

Smaller fixes

Breaking for anything implementing storage.FS outside this repo: InitiateUpload and Upload are replaced by PrepareUpload and RollbackUpload, and ComposableFS is gone. The opencloud bump needs the coordinator wiring from opencloud-eu/opencloud#3839, which already runs this branch through the opencloud CI.

Known open issues, not addressed here:

Review focus:

  • pkg/upload/coordinator.go: the finish paths (inline, async, rollback) and what happens to the staged session on each failure.
  • pkg/storage/pkg/decomposedfs/prepare_upload.go and commit_upload.go: the order of blob write, node switch, revisions and propagation.
  • posix: PrepareUpload writes the new metadata onto the live node before postprocessing, and revisions are still created via CreateRevision.

Each part was reviewed in its own PR, linked above; reviewing per PR is easier than reviewing the diff.

Assisted by Claude Code (claude-opus-5-5): it collected the changes from the merged PRs and wrote this description.

LarsJurgensen and others added 16 commits October 23, 2026 12:34
The pkg decomposedfs fork gets PrepareUpload in the next commit.
The pkg decomposedfs fork snapshots the previous version through the
tree's CreateRevision, like the legacy upload path does, so posix keeps
a copy of the current content as a revision while decomposedfs only
copies the metadata. On failure it removes that revision without
retaking the node lock and restores the old mtime in the same batch as
the other attributes.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
CommitUpload wrote the staged bytes through a bare node without a space
root, which the posix blobstore rejects, and always onto the live node.
On posix the content lives in the node itself, so:

- commit against the real, locked node
- if a newer upload took over the node, write into the revision that
  upload created for this session; without one (versioning disabled)
  discard the bytes, nothing references them
- add UploadSource.Path so a staged file can be moved into place
  instead of copied from a reader
- stage posix reader uploads in the space's .oc-tmp dir, which the
  watcher ignores, and don't re-stage a file that already is there

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
Hunks that conflict with our revert code (RevertUpload) keep our side; the next
commit adapts RollbackUpload to it.
Both decomposedfs copies get Node.RevertLatestRevision, which restores
the latest revision onto the node and removes it, without purging the
node or unmarking processing. RollbackUpload uses it. Without a revision
(versioning disabled) it returns PreconditionFailed and leaves the node
alone instead of purging it, as the previous metadata can't be restored.

Adds RollbackUpload to the pkg fork, with specs for both copies and
posix.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
RollbackUpload keeps our PreconditionFailed when there is no revision
to restore. The pkg decomposedfs fork gets the fixes in the next commit.
- PrepareUpload checks the quota for new files too
- CommitUpload stores the scan result on the node that holds the
  content: the node, or the revision when a newer upload took over
- RollbackUpload purges a node the upload created

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
Every driver copies options.DisableVersioning into the aspect, and only
the legacy upload session store reads it; PrepareUpload reads the
option. It can go when the upload coordinator replaces that store.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
The legacy decomposedfs copy stays a snapshot of the original driver,
including its known flaws; our own upload behaviour lives in the pkg
fork. So this undoes what the earlier commits added there:

- CommitUpload takes a body only; a staged file path is for the pkg fork
- RollbackUpload purges an existing node when there is no revision to
  restore, like upstream, instead of returning PreconditionFailed
- Node.RevertCurrentRevision provides upstream's API on top of our
  RevertUpload; DeleteRevision is back as it was
- the rollback specs are upstream's

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
port upload driver contract: PrepareUpload, RollbackUpload, scan results
Signed-off-by: Christian Richter <[email protected]>
Brings the ListFolder permissions race fix, the WWW-Authenticate realm
escaping, the async propagator deprecation and the
go-playground/locales bump into workpackages.

Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
@butonic butonic changed the title Track Workpackages Diff [DO NOT MERGE] Track Workpackages Diff Oct 30, 2026
@butonic butonic added the Type:Maintenance E.g. technical debt, packaging, etc. label Oct 30, 2026
butonic and others added 12 commits November 3, 2026 15:08
Fix Tree.Delete rollback to remove stale trash symlinks and restore renamed nodes when deletion fails.
Port of owncloud#692, adapted to our diverged decomposedfs copies:

- Add an Orphaned upload session filter to storage.UploadSessionFilter,
  evaluated last in ListUploadSessions of both copies because it reads
  the node metadata of every session.
- Add IsOrphaned and syntheticNode to OcisSession and DecomposedFsSession.
- Extract the node reverting from upload.Cleanup into revertNode and run
  it before the bin and info files are removed, so a failure leaves a
  recoverable session instead of a deleted one. The readable-node branch
  keeps our local RevertUpload/Purge logic (upstream has
  RevertCurrentRevision). When the node metadata is unreadable, revert
  the optimistic size propagation from a node built out of the session's
  SpaceID/NodeID/NodeParentID and remove the orphaned node, so the space
  quota is released; the upload is kept when the quota cannot be
  released. In the pkg fork the orphaned node is removed via lu.PurgeNode
  and its metadata via the MetadataNode-based backend Purge.
- Clean up orphaned sessions on PostprocessingFinished instead of
  returning early and leaving them to be retried forever.
- Add the regression test to both upload_async_test.go copies.

Changelog is maintained in the ready-release-go PR, not per commit.

Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
- Add node.ErrMissingParentID and treat a session as orphaned only when
  reading its node fails with it. Other read errors, e.g. an unavailable
  cache, are logged and leave the session untouched.
- On PostprocessingFinished, only drop the bytes and info of an orphaned
  session when postprocessing asked to delete the upload.
- Clear and persist the session's sizeDiff before reverting it, so a
  repeated cleanup does not release the quota twice.
- Remove the bytes even if reverting the node failed, so infected files
  do not stay on disk. Only the info is kept for a retry.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
Cleaning up an orphaned upload removed the node without checking
whether the upload created it. For an upload that overwrites a file
the node holds the previous version, on posix the user's file itself,
so it got deleted. We now only revert the size diff for an existing
node.

A node the upload created is removed only while it is still empty: the
uploaded bytes only get there when the upload is finalized. If it has
content, something outside of us wrote it, e.g. an editor saving
atomically on posix before the watcher assimilated the file, so we keep
it.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
fix(decomposedfs): release the quota of orphaned upload sessions
Upload sessions carry an explicit status (uploading, processing,
failed) with a message, as the decomposedfs sessions do. Listing
uploads shows it, and IsProcessing reports the processing status
instead of guessing from the offset and the scan result.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
… gateway

OpenCloud signs data URLs in the proxy, at the edge, so its storages
configure only the download endpoint. The session then signed a token
against an empty data gateway endpoint, and postprocessing got a bare
"/<token>" it could not download the staged bytes from: the virus scan
never ran. Return the data server URL itself in that case, as the
driver sessions did.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
The decomposedfs upload sessions synced every chunk right away, so an
upload could be resumed after a crash and slow disks were spared one
large flush at the end of the upload. Do the same in the coordinator's
sessions, and log failed chunk writes as they did.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
staticcheck S1016 flags the struct literal: both types have the same
fields, so a plain conversion does the job.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
feat(upload): add driver independent upload sessions
TouchFile only returns an error here, so the coordinator reads the
touched node back to learn its id and space owner or manager.
butonic and others added 13 commits November 11, 2026 13:26
A space manager share could get an expiration even when it was the
last permanent manager of the space. Once it expired the space was
left without a manager. The last manager check in UpdateShare only ran
when the new permissions stripped AddGrant or RemoveGrant.

We now also run it when the share keeps the manager permissions but
ends up with an expiration, either from the update or because it
already had one and only the permissions change. Removing an
expiration does not need the check.

Upstream did this in the gateway, where space grants were still
handled at the time (`owncloud#631`). Our space membership lives
in the share provider since
#593, so the check goes into
UpdateShare next to the existing one, which ignores expiring managers
since #990.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
A space share could carry a single grant management bit, e.g. viewer
permissions plus RemoveGrant. decomposedfs treated RemoveGrant alone as
the manager marker, so such a grantee could manage the space while the
UI showed a viewer.

The share provider now rejects space root shares that carry any of
AddGrant, UpdateGrant, RemoveGrant or DenyGrant without the full
manager permissions, both on create and on update. In decomposedfs
IsManager, IsEditor and IsViewer become IsSpaceManager, IsSpaceEditor
and IsSpaceViewer and check the role bitmaps instead of a single bit.
A space manager needs AddGrant, UpdateGrant and RemoveGrant. DenyGrant
is not required, so older manager and coowner grants still count.

Upstream put the share check into the gateway (`owncloud#653`).
Space membership lives in the share provider since
#593, so the check goes into
CreateShare and UpdateShare there. Update requests are checked against
the effective new permissions, the same ones the last manager check
uses.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
usershareprovider: tighten space manager checks
Resolve the usershareprovider.go conflict in favour of #993, which landed the same last manager expiration check first. Its mayRemoveLastPermanentManager is the more precise variant: it resolves the permissions and expiration an update leaves on the share, so only expiring managers trigger the check.

Drop this branch's specs that #993 covers with the same or stronger scenarios and keep the one it lacks: an expiration in the payload is ignored when the update mask does not list it.

Co-authored-by: Copilot <[email protected]>
Advertise spaces.server_managed in the capabilities and let service
accounts update and list grants, so the server can manage space
membership automatically.

Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
fix(usershareprovider): prevent setting an expiration on the last space manager
The ERR_ALREADY_EXISTS prefix dropped the space between "already
exists:" and the detail, so every AlreadyExists message changed from
"error: already exists: foo" to "error: already exists:foo". We now
append the space in Error() and keep the prefix without it, so
strings.Contains checks on the prefix still match.

Also add specs for ListPublicShares: an AlreadyExists error from the
share manager (the metadata space exists but the service user cannot
see it) yields an OK response with no shares, other errors stay an
internal error carrying the error message.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
feat(spaces): allow managing spaces through the server
fix(publicshareprovider): do not fail listing public shares when the metadata space is not accessible
Brings the typed storage results (#986), the stuck synchronous upload
fix (#976), the main-queue replica fix (#984), the posix id cache fail
fast (#989) and release 2.52.2 into workpackages.

The typed results were mostly mechanical: the ocm received driver keeps
its service account client, nextcloud keeps its real TouchFile (now
returning a TouchFileResult), and the coordinator ignores the TouchFile
result and still reads the node back, because not every driver fills
it.

#976 patched the legacy upload session store, which workpackages
removed. Its recovery of nodes left processing by an interrupted
synchronous upload moves into the pkg fork as
Decomposedfs.recoverInterruptedUpload. The coordinator stages sessions
in the same <upload dir>/<id> and <id>.info layout as the old store, so
nodes stuck by older versions still heal on the first download.
Aspects.DisableVersioning stays gone, SeparateBlobs comes along.

The sync specs now drive uploads through the coordinator. The two
blob-first specs follow with the next commit, which moves the blob-first
write to the coordinator path.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
The coordinator finished inline uploads in three steps: PrepareUpload
pointed the node to the session's blob and marked it as processing,
CommitUpload stored the blob, and MarkProcessing removed the mark. A
crash in between left the mark forever, since nothing postprocesses
synchronous uploads, and downloads failed with 425. This is the
coordinator side of the bug #976 fixed in the legacy upload path on
main.

We now hand PrepareUpload the staged file (UploadInfo.Source) on the
inline path. With a blobstore that keeps blobs apart from the nodes
(decomposed, decomposeds3), PrepareUpload stores the blob and only then
switches the node, without a mark. For an existing file that happens
under the node lock, after the etag and quota checks. For a new file
the blob is stored before the node exists, like main does: a crash
while writing must not leave a node without metadata that blocks the
name. PrepareUpload reports Committed, so the coordinator skips
CommitUpload and MarkProcessing. Posix and the other drivers ignore
Source and keep the old flow.

A mark left by an interrupted upload is cleared in the same write, by
emptying it. Only a processing mark counts as an upload superseding
the node now, an empty one would make every later upload take a
snapshot. The revisions kept only for a rollback go away like after a
live commit, but not before the size was propagated: until then the
rollback still needs them and their blobs.

If the blob cannot be stored, PrepareUpload wraps
storage.ErrSourceNotStored and the coordinator keeps the session as
failed, like after a failed CommitUpload: the staged bytes are the only
copy of the upload and the failure may be transient.

If writing the node fails, PrepareUpload puts the old metadata back.
The new blob is still kept, because the failed write might have
switched the node anyway, so the spec from main now expects the old
content plus a leftover blob.

Assisted-by: Claude Code:claude-fable-5-2
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
@butonic
butonic marked this pull request as ready for review November 13, 2026 14:26
@butonic butonic changed the title [DO NOT MERGE] Track Workpackages Diff Merge Workpackages back to main Nov 13, 2026
@butonic butonic added Type:Breaking-Change and removed Type:Maintenance E.g. technical debt, packaging, etc. labels Nov 13, 2026
@butonic butonic self-assigned this Nov 13, 2026

@micbar micbar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These PRs have already been reviewed.

@butonic
butonic merged commit 0368566 into main Nov 13, 2026
21 checks passed
@butonic
butonic deleted the workpackages branch November 13, 2026 14:48
@openclouders openclouders mentioned this pull request Nov 13, 2026
1 task
butonic added a commit to opencloud-eu/opencloud that referenced this pull request Nov 13, 2026
workpackages was merged into reva main with
opencloud-eu/reva#957, so we no longer need to
pin the workpackages branch. The code is the same as 7ff1d6fb1, only
the version changes.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
@butonic
butonic restored the workpackages branch November 13, 2026 14:52
@butonic
butonic deleted the workpackages branch November 13, 2026 14:53
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.

9 participants