Skip to content

fix(seaweedfs): remove identities left behind by deleted BucketAccesses - #4915

Open
Aleksei Sviridkin (lexfrei) wants to merge 1 commit into
fix/seaweedfs-cosi-object-lockfrom
fix/seaweedfs-cosi-orphan-identities
Open

Aleksei Sviridkin (lexfrei) wants to merge 1 commit into
fix/seaweedfs-cosi-object-lockfrom
fix/seaweedfs-cosi-orphan-identities

Conversation

@lexfrei

@lexfrei Aleksei Sviridkin (lexfrei) commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does

Removes SeaweedFS identities left behind by deleted BucketAccesses. The COSI driver up to v0.3.1 revokes only from the legacy identity.json, while SeaweedFS since 4.08 keeps each identity in its own file, so those files stayed (seaweedfs/seaweedfs-cosi-driver#11). The upstream driver v0.4.0 from #5284 deletes the file on revoke, so no new files are left. Files that v0.3.1 already left behind still hold working keys and stay until something removes them.

A post-install/post-upgrade hook in seaweedfs-system removes them. It lists the identity files before the BucketAccesses, so a file whose BucketAccess still exists is never taken for a left-over one. The rest of the rules are in the commit message and at the top of the script. When it is unsure, it removes nothing, and the errors it handles do not fail the release.

A filer that other clusters use through Client topology holds identities whose BucketAccesses this cluster cannot see. The new cosi.orphanIdentities value of the SeaweedFS application decides what happens there. The default auto only reports when filer.grpcHost is set and removes otherwise, and an operator can force report or delete.

Stacked on #4893.

Tested with bats against a fake weed shell and with helm-unittest. A mutation that swaps the two listings back makes the ordering test fail. An earlier revision of the script, which also skipped recently changed files, was tried on a live cluster with SeaweedFS 4.45 and driver v0.3.1. It only reported in report mode and removed left-over files in delete mode while live identities kept working. With BucketAccess listing forbidden, it removed nothing. The current revision has not been run on a live cluster. No run has checked that the keys of a removed identity are then rejected.

On 87d25b3 the bats, chart tests, Helm lint of the system chart and shellcheck pass offline. The Linux unit lane and E2E are pending.

Screenshots

Not a UI change.

Downstream repositories

The new value belongs to the SeaweedFS application, which the Terraform provider does not model (it only sets seaweedfs on a Tenant). The website reference page is regenerated from the README on release.

Release note

fix(seaweedfs): remove S3 identities left behind by deleted BucketAccesses on install and upgrade. The new cosi.orphanIdentities value (auto, report, delete) controls it; auto only reports on a filer published to Client-topology clusters.

@github-actions github-actions Bot added size/XL This PR changes 500-999 lines, ignoring generated files area/storage Issues or PRs related to storage (linstor, seaweedfs, bucket, velero, harbor) kind/bug Categorizes issue or PR as related to a bug labels Oct 14, 2026
@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Since SeaweedFS 4.08 the S3 gateways move every identity from
/etc/iam/identity.json into /etc/iam/identities/<name>.json, and the
COSI driver up to v0.3.1 revokes only from identity.json. Every
BucketAccess deleted on such a filer left its identity file behind,
with its keys still accepted (seaweedfs/seaweedfs-cosi-driver#11). A
driver that deletes the file on revoke does nothing for the files
already left.

A post-install/post-upgrade hook removes a ba-<uid>.json file when no
BucketAccess in any namespace names it, by uid or by
status.accountID. The uid covers a BucketAccess still being granted,
the accountID one restored with its status. The identity directory is
listed before the BucketAccesses: a BucketAccess exists before its
grant writes a file, so a file seen in the first listing whose
BucketAccess still exists is always named by the second. File ages are
not used, because grants and gateway migrations rewrite left-over
files as well. A failed or empty listing removes nothing. Each removal
is logged and recorded as an Event on the HelmRelease. The hook runs
before the Object Lock hook, so a left-over identity is removed before
that hook grants it anything.

A filer published for Client-topology clusters holds identities whose
BucketAccesses live in those clusters, so cosi.orphanIdentities
defaults to auto: report there, delete otherwise. An operator can
force either.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/storage Issues or PRs related to storage (linstor, seaweedfs, bucket, velero, harbor) kind/bug Categorizes issue or PR as related to a bug size/XL This PR changes 500-999 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant