Skip to content

Add S3 ListBuckets, DeleteBucket and DeleteObjects - #202

Merged
saworbit merged 1 commit into
mainfrom
fix/s3-bucket-operations
Nov 14, 2026
Merged

saworbit merged 1 commit into
mainfrom
fix/s3-bucket-operations

Conversation

@saworbit

@saworbit saworbit commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

Fixes #159

  • GET / is ListBuckets: ListAllMyBucketsResult with each bucket's name and creation date, in byte order. It takes prefix, max-buckets (1 to 10000) and continuation-token. Other parameters, such as bucket-region, get NotImplemented.
  • DELETE /{bucket} is DeleteBucket. A bucket holding objects gets 409 BucketNotEmpty. A key whose capsule spacectl delete removed reads as missing, so it doesn't count: it's unbound in the batch that deletes the bucket, and doesn't come back if the bucket is created again. DELETE /{bucket}?policy and other configuration deletes still get NotImplemented, so they can't delete the bucket.
  • POST /{bucket}?delete is DeleteObjects. All the deletes commit as one journal BATCH. Keys that aren't there count as deleted, as with DELETE. Quiet reports only errors. A key given with a version id other than null gets an error and is left alone, since there's no versioning. A POST without ?delete still gets NotImplemented.
  • The DeleteObjects body is read by a small strict parser rather than a new dependency. It reads Delete, Object, Key, VersionId and Quiet, and ignores ETag, LastModifiedTime and Size. It refuses comments, CDATA, a DOCTYPE, processing instructions, unknown elements or entities, characters XML can't carry, and more than 1000 objects, all with MalformedXML. So it never reads a document differently from an XML parser.
  • The journal records a bucket delete as a NAMESPACE record with op 2, which the format reserved for it (§5.5). The index and journal compaction both drop the namespace. A build from before this refuses a store that holds one.
  • DeleteBucket runs under the pipeline lock, and a PUT now checks its bucket again under that lock before it commits. So a PUT whose bucket is deleted while its body is stored fails with NoSuchBucket and leaves nothing.
  • Multipart upload, the last item of [Gap] S3 view has no ListBuckets, DeleteBucket, DeleteObjects or multipart upload #159, is now [S3] Multipart upload #201.

Tests: HTTP tests for ListBuckets paging, prefix and bad parameters; DeleteBucket on a full, empty and missing bucket, and creating it again; DeleteObjects with entities, duplicates, a versioned key, quiet mode, a broken document and a missing bucket. Lifecycle tests: a deleted bucket and a DeleteObjects survive a restart and a lost index, a dangling key doesn't come back, and a PUT racing DeleteBucket stores nothing. Parser unit tests cover what S3 clients send and 19 documents it must refuse. The journal compaction tests now delete namespaces too, without changing their random draws (see #188).

Fifteen mutants each fail a test: DeleteBucket ignoring live objects, leaving dangling keys or taking any query; the PUT skipping its commit-time bucket check; the index, compaction or decoder mishandling a namespace delete; ListBuckets ignoring the token or the prefix; DeleteObjects deleting versioned keys, ignoring Quiet or dropping a capsule twice; and the parser accepting comments, any element or control characters. Nothing tests DeleteBucket committing outside the lock. That race needs a hook to pause it between its check and its commit, and my attempt at that mutant still took the lock. I ran boto3 against serve-s3: list_buckets and its paginator, delete_objects, Bucket.objects.all().delete() and delete_bucket work. The AWS CLI isn't installed here, so it's still untested.

Docs: CHANGELOG, on-disk-format §4.2, §5.5, §6 and §7, QUICKSTART_S3.

GET / lists buckets, with prefix, max-buckets and continuation-token.
DELETE /{bucket} deletes an empty bucket and refuses one with objects in
it with BucketNotEmpty; the journal records it as a NAMESPACE record with
op 2. POST /{bucket}?delete deletes up to 1000 keys in one batch. A PUT
checks its bucket again at the commit, since buckets can now go away.
Multipart upload moves to #201.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Gap] S3 view has no ListBuckets, DeleteBucket, DeleteObjects or multipart upload

1 participant