Skip to content

v0.37.0

Choose a tag to compare

@github-actions github-actions released this 24 Nov 14:27
· 26 commits to main since this release
2e46c91

Highlights

  • Object.OpenRange(offset, 0) on s3 and azblob returned the body where it now reads nothing (#572, fixes #569). Affected: s3 in every release from v0.0.1 through v0.36.0, and azblob in every release from v0.5.0, which added the backend, through v0.36.0. The trigger is a length of 0 and nothing else: on s3 the Range header's end wrapped to bytes=0-18446744073709551615 for offset 0 or became bytes=5-4 for offset 5, and against a real S3 bucket in ap-northeast-1 with v0.36.0 both calls read all 1024 bytes of a 1024-byte object; on azblob a count of 0 means "to the end" to the SDK, so the call read the blob from offset to its end (from the code, not run before the fix). No error was returned. A caller that computes a range and arrives at 0, such as the tail of an object already read to its end, received those bytes in place of none. osfs, memfs and gcs already read nothing, and s2 itself never passes 0: s2-server derives a length of at least 1 for a range GET and for UploadPartCopy, so a server is not affected. How to check your own callers is under Library users.
  • azblob: Storage.Copy now works on a private container, and on sources over 256 MB (#573, fixes #571). In every release from v0.5.0 through v0.36.0, Copy used Copy Blob From URL with the source's plain URL, which the service cannot read on a private container (the default): against a real Azure Storage account it failed with CannotVerifyCopySource for a shared key or connection string at any size, and for DefaultAzureCredential at 300 MB. Since v0.12.3 that failure was reported as s2.ErrNotExist, so an existing source was called missing; before, it was the provider's error. s2.Move, which on azblob is Copy then Delete, failed the same way, and so did a CopyStorage on one storage, which stopped at its first object. Nothing was lost: Move returns the error from Copy before it deletes. Copy now uses Copy Blob, which authorizes a same-account source with the request's own credential. s2-server's CopyObject and UploadPartCopy never used Copy and are unchanged.
  • s3 and azblob report an archived object with an error wrapping errors.ErrUnsupported (#574, fixes #562): S3 GLACIER, DEEP_ARCHIVE and an Intelligent-Tiering archive tier until a restore finishes, and the Azure Archive tier until rehydration finishes. In v0.36.0 Get succeeded for such an object and the body read failed with the provider's error, so CopyStorage stopped at the first one; it now skips it and counts it in Unsupported. An s2-server built with the server_s3 or server_azblob tag answers a GetObject or copy of such an object with 403 InvalidObjectState instead of 500 InternalError, and a HeadObject with a bare 403 instead of 200; aws-sdk-go-v2 retries a 500 by default and not a 403. Such a server must also keep its own state out of any rule that archives objects: see docs/upgrading.md. The official binaries and image include osfs and memfs only and answer as before.
  • s2.Open reads an object's body by name in one request (#570, fixes #568), where Get followed by Object.Open costs two on s3, gcs and azblob. Measured for #568 with v0.36.0 on a real S3 bucket in ap-northeast-1, sequentially, 1 KiB × 1000: Get + Open took about 50 s, and one GetObject per object, the request s2.Open sends on s3, about 29 s. All bundled backends implement the new optional s2.Opener; for a storage that does not, s2.Open falls back to Get and Object.Open. s2.Open pins no version; Get followed by Object.Open still does and is unchanged, so keep it where the body must match attributes read first.

Changes

Fixed

  • s3: OpenRange with a length of 0 sends a HeadObject instead of a GetObject and returns an empty reader. It fails with ErrNotExist for a missing key and with ErrModified when the ETag differs from the one Get or List saw, as the body read does (#572, fixes #569)
  • azblob: OpenRange with a length of 0 reads the blob's properties instead of downloading, with the same outcomes; the ETag comparison ignores the quotes, which Azure puts around it in the properties and not in a listing (#572)
  • s2: the Object.OpenRange godoc says "a length of 0 reads nothing" (#572)
  • azblob: Copy uses Copy Blob (StartCopyFromURL) instead of Copy Blob From URL (CopyFromURL), so a same-account source is authorized by the request's own credential and the 256 MB limit of Copy Blob From URL no longer applies. A copy the service reports as pending is waited for by reading the destination's copy status every 500 ms; one that ends as failed or aborted returns azblob: copy <source key>: <status>: <description>. A missing source still wraps ErrNotExist, and CannotVerifyCopySource is no longer mapped to it (#573, fixes #571)
  • s3: Get and OpenRange with a length of 0 return an error wrapping errors.ErrUnsupported when the HEAD reports GLACIER, DEEP_ARCHIVE or an Intelligent-Tiering ArchiveStatus, unless its Restore reports ongoing-request="false"; GLACIER_IR and a restored object read as before. Open, OpenRange, s2.Open and Copy map the InvalidObjectState that GetObject and CopyObject answer the same way, and an archived source over the 5 GiB CopyObject limit is refused before any multipart upload starts (#574, fixes #562)
  • s3: against an s2-server, whose HeadObject answers such an object with a bare 403, Get sends one GetObject with Range: bytes=0-0 after a 403 and wraps errors.ErrUnsupported only when that answers InvalidObjectState; any other answer keeps the HEAD's error. Exists reports such an object as present, where it failed with that 403 (#574)
  • azblob: Get and OpenRange with a length of 0 return an error wrapping errors.ErrUnsupported when the properties report the Archive tier, which a blob keeps while its rehydration is pending; Open, OpenRange, s2.Open and Copy map BlobArchived the same way, and Copy also checks the source's tier when Copy Blob answers PendingCopyOperation, which a rehydrating source does (#574)
  • s2: CopyStorage on one storage counts an object in Unsupported when Copy wraps errors.ErrUnsupported and Get of the source does too, as the copy across two storages already counted one from Get; any other errors.ErrUnsupported from Copy stops the copy. The Storage.Copy godoc says a src the backend cannot read wraps errors.ErrUnsupported, as Get does (#574)
  • server: a body read that fails with errors.ErrUnsupported after Get found the object answers as Get failing that way does: GetObject, ranged or not, CopyObject and UploadPartCopy, with or without x-amz-copy-source-range, answer 403 InvalidObjectState, and the console's view and preview 403, where v0.36.0 answered 500 InternalError and 500 (#574)
  • s3: the ErrNotExist and ErrModified errors from Open and OpenRange name the object without the storage's prefix, as Get does (#570)

Features

  • s2: Opener, an optional interface with Open(ctx, name) (io.ReadCloser, error), and Open(ctx, s, name), which uses it and otherwise falls back to Get followed by Object.Open. An Opener pins no version, so it never fails with ErrModified; it fails as Get does for a missing or invalid name, and ctx must stay live until the reader is closed. In the fallback, ctx reaches only Get, and a Put between Get and Open still fails with ErrModified (#570, fixes #568)
  • s3, gcs, azblob: implement Opener with one GetObject, NewRangeReader or DownloadStream, and no attributes request (#570)
  • fs: osfs and memfs implement Opener: the name is found as Get finds it, under the same shared lock, and the body is opened without reading the metadata file. A directory or a name that is only a prefix of other keys is ErrNotExist (#570)
  • s2test: TestStorageOpen; StorageDelegator gains OpenFunc and an Open method (#570)

Documentation

  • README gains a paragraph on s2.Open (#570); docs/backends.md names the archived objects s3 and azblob report, and asks to keep s2-server's state under .buckets/ and .multipart/ out of rules that archive objects (#574)

CI / Build

  • Bump intra-repo deps to v0.37.0 (#576); v0.36.0 bookkeeping for cmd/s2-server (#567)

Upgrading

  • Submodule consumers: go get github.com/mojatter/s2/<module>@v0.37.0
  • s2-server operators running the image: docker pull mojatter/s2-server:0.37.0 (:latest points at it too)
  • cmd/s2-server/v0.37.0 is published separately, shortly after: go install github.com/mojatter/s2/cmd/s2-server@v0.37.0
  • No module's go directive moved and go.work is unchanged since v0.36.0.
  • No configuration changes and no change to the data at rest; downgrading to v0.36.0 is safe. An s2-server built with the server_s3 or server_azblob tag answers differently for archived objects and has one thing to check first: see docs/upgrading.md.

Library users

  • To check for past effects of OpenRange with a length of 0 on s3 or azblob: s2 keeps no record of it, so go by your own calls. Look for an OpenRange whose length is computed and can come out as 0. Through v0.36.0 such a call returned, without an error, the whole object on s3 whatever the offset, and on azblob the blob from the offset to its end, so whatever was built from that read holds those bytes where it was meant to hold none. Where such a read was written on, to another object, a file or a database, check that destination too: it is longer than intended by the whole object's length on s3, and by the length from the offset to the end on azblob. Calls with a length of 1 or more were not affected, and neither were osfs, memfs and gcs.
  • OpenRange with a length of 0 now costs one HeadObject on s3 and one properties read on azblob, and fails as Open does: ErrNotExist for a deleted object, ErrModified for one replaced since Get or List, errors.ErrUnsupported for an archived one.
  • On s3 and azblob, Get of an archived object now fails with an error wrapping errors.ErrUnsupported, where it returned the object, so code that read the size, ETag or metadata of an archived object through Get no longer can until it is restored or rehydrated. List still returns such an object, and Exists still reports it. Open, OpenRange, s2.Open and Copy fail with the same error, where they failed with the provider's.
  • CopyStorage out of, or within, a bucket or container that holds archived objects now completes: each is counted in CopyStorageResult.Unsupported and reported to ObjectDone with CopyStorageUnsupported, where v0.36.0 stopped at the first with an error. They are not copied; check Unsupported before treating the destination as complete.
  • Checked for #574 against a real S3 bucket in ap-northeast-1 and a real Azure Storage account: an S3 DEEP_ARCHIVE object, directly and through a local s2-server on that bucket, an Azure Archive blob and one whose rehydration was pending were unsupported through Get, Open, OpenRange, s2.Open, OpenRange(0, 0) and Copy, and counted by CopyStorage; an S3 GLACIER object after an Expedited restore, a GLACIER_IR object and an Azure Hot blob read and copied. An Intelligent-Tiering archive tier and an archived source over 5 GiB were not run; unit tests cover them.
  • s3: when a HEAD answers 403, Get, Exists and OpenRange with a length of 0 now send one more request, a GetObject with Range: bytes=0-0, to tell an archived object behind an s2-server from a denied one. The error for a HEAD that fails for a reason other than a missing key now reads failed to head object: … from Get, where it read failed to get object: ….
  • s3: an error from Open or OpenRange for a missing or modified object now names the object as Get does, without the storage's prefix.
  • azblob: Copy no longer returns ErrNotExist for a source the service could not authorize. A copy the service leaves pending blocks Copy until it ends; if ctx ends first, Copy returns the ctx error and the copy is not aborted, so the service may still write dst after Copy has returned that error: do not read it as dst left untouched. Storage.Copy takes no condition on dst, s2.Move returns that error without deleting the source, and a Copy the service answers with PendingCopyOperation is not retried: unless the source is archived it returns the provider's error. On a real Azure Storage account, with a connection string and with DefaultAzureCredential, Copy Blob reported success at once for 1 KiB and for 300 MB, so the wait was exercised by unit tests only.
  • s2.Open returns the body the name holds when the read starts. Use Get and Object.Open when the body must match attributes you read first.

Storage implementers

  • Opener is optional: an existing implementation or wrapper compiles and behaves as before, and s2.Open on it costs a Get and an Object.Open. A wrapper that embeds s2.Storage does not expose the inner storage's Open, so s2.Open on it takes the fallback and goes through the wrapper's Get.
  • Object.OpenRange with a length of 0 must read nothing and fail as Open does. A backend that passes 0 on to its provider as "to the end" now fails s2test.TestStorageOpenSinceGet.
  • For a src your backend cannot read as stored, return an error wrapping errors.ErrUnsupported from Copy, as from Get. CopyStorage on one storage counts the object in Unsupported only when Get of it wraps the error too.
  • s2test.TestStorageOpen: new. Through s2.Open it reads an object, a directory marker (empty) and an object through Sub, and expects ErrNotExist for a missing name and for a name that is only a prefix of other keys, and ErrInvalidName for an invalid one. A storage without Opener passes it through the fallback; call it from your suite, since no other check runs it.
  • s2test.TestStorageOpenSinceGet: now also calls OpenRange(0, 0) and OpenRange(1, 0), which must read nothing on an unchanged object, fail with ErrModified once the key holds another version and with ErrNotExist once it is deleted.
  • s2test.StorageDelegator: has the new field OpenFunc and an Open method, so it now satisfies s2.Opener and s2.Open on it never takes the fallback; without OpenFunc its Open opens what Get returns.
  • No other s2test check changed since v0.36.0.

s2-server operators

  • The official binaries and image include osfs and memfs only; nothing changes for them and there is nothing to do.
  • An s2-server built with the server_s3 or server_azblob tag: an archived object answers GetObject, CopyObject and UploadPartCopy with 403 InvalidObjectState instead of 500 InternalError, and HeadObject with a bare 403 instead of 200. aws-sdk-go-v2 retries 500, 502, 503 and 504 by default and not 403, so such a request now fails on the first answer. Before upgrading, make sure no rule archives s2-server's own state under .buckets/ and .multipart/: an archived .buckets/<name> now fails every multipart request on that bucket with 500 InternalError. How to check, and what to do with what you find, is in docs/upgrading.md.
  • An s2-server built with a backend registered outside s2: a body read that wraps errors.ErrUnsupported now answers 403 InvalidObjectState, as a Get that does has since v0.36.0, where it answered 500 InternalError.

Full Changelog

v0.36.0...v0.37.0