Skip to content

httpreader: random access over an HTTP resource - #1953

Merged
github-actions[bot] merged 5 commits into
quay:mainfrom
hdonnay:hack/httpreader
Aug 26, 2026
Merged

httpreader: random access over an HTTP resource#1953
github-actions[bot] merged 5 commits into
quay:mainfrom
hdonnay:hack/httpreader

Conversation

@hdonnay

@hdonnay hdonnay commented Jul 17, 2026

Copy link
Copy Markdown
Member

This adds a package (internal/httpreader) that implements io.ReaderAt over HTTP requests. It incorporates a lot of tricks I know from a past life dealing with RFC7233 non- and selectively- compliant servers.

Then, the fetcher package gains the capability to use an httpreader.Reader when it notices that a layer is uncompressed.

Future work may involve the tarfs layer doing transparent caching and being able to handle compressed layers directly.

@hdonnay
hdonnay requested review from a team as code owners July 17, 2026 18:41
@hdonnay
hdonnay requested a review from crozzy July 17, 2026 18:41
@hdonnay

hdonnay commented Jul 17, 2026

Copy link
Copy Markdown
Member Author

Conflicts with #1948

@hdonnay
hdonnay force-pushed the hack/httpreader branch 6 times, most recently from 9c3ce05 to 719faf9 Compare July 22, 2026 16:41
@hdonnay
hdonnay force-pushed the hack/httpreader branch 2 times, most recently from 7635a0a to 01c8352 Compare July 27, 2026 20:06
@BradLugo
BradLugo self-requested a review July 27, 2026 20:12

@BradLugo BradLugo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think there's enough to address for now. I'll do another deep dive in the next review

Comment thread internal/httpreader/reader.go
Comment thread internal/httpreader/content_range.rl
Comment thread internal/httpreader/reader.go Outdated
Comment thread internal/httpreader/metrics.go
Comment thread internal/httpreader/ragel.sh
Comment thread internal/httpreader/reader.go Outdated
Comment thread pkg/tarfs/testdata/paxsize.tar
Comment thread pkg/tarfs/tarfs_test.go
Comment thread pkg/tarfs/parse.go
Comment thread libindex/fetcher.go Outdated
@hdonnay
hdonnay force-pushed the hack/httpreader branch 2 times, most recently from 28024a7 to 29a4bdc Compare July 28, 2026 18:38
@hdonnay
hdonnay requested a review from BradLugo July 28, 2026 18:44
@hdonnay
hdonnay force-pushed the hack/httpreader branch 2 times, most recently from 06bd4c0 to 1196816 Compare August 13, 2026 20:21

@BradLugo BradLugo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

More questions

Comment thread internal/httpreader/content_range.rl Outdated
Comment thread internal/httpreader/reader.go
Comment thread internal/httpreader/content_range.rl Outdated
Comment thread pkg/tarfs/parse.go Outdated
Comment thread pkg/tarfs/parse.go Outdated
Comment thread libindex/fetcher.go
Comment thread libindex/fetcher.go Outdated
Comment thread libindex/fetcher.go Outdated
Comment on lines +134 to +136
if err != nil {
return err
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we fall back to spooling to disk instead?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think any failure of the inspect routine means the spooling would fail, also.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not so sure, e.g., I can see some weirdness happening where a server/proxy/WAF returns a non-200 when it receives a request with the Range header or something. In any case, after thinking about it for a bit, should we move the inspect after we check the cache anyway?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Reorganized it so the inspect and fetchFileForCache calls both happen only on the "cache miss" path.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I still think there may be edge cases where the inspect would fail, but the GET from the spooling would succeed (e.g., a weirdly configured proxy/WAF that blocks Range but would succeed on a regular GET). I think falling back to spooling would be ideal, but I won't block on it. Feel free to resolve this thread and merge.

Comment thread libindex/fetcher.go Outdated
Comment thread libindex/fetcher.go Outdated
@hdonnay
hdonnay requested a review from BradLugo August 18, 2026 21:36
@hdonnay
hdonnay force-pushed the hack/httpreader branch 5 times, most recently from 2fdeec5 to ba37694 Compare August 20, 2026 18:36
Comment thread pkg/tarfs/parse.go Outdated
@hdonnay
hdonnay requested a review from BradLugo August 25, 2026 15:42

@BradLugo BradLugo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Non-blocking recommendation: #1953 (comment)

This package does an io.ReaderAt over an HTTP resource. It includes a
novel way to determine the end of a resource for partially-compliant
servers. Using wholly-compliant servers is recommended.

Signed-off-by: Hank Donnay <hdonnay@redhat.com>
Change-Id: I08d6671217535ac897a2ed5c9cd20aa06a6a6964
Signed-off-by: Hank Donnay <hdonnay@redhat.com>
Change-Id: I162632409abf01efcec4633713c9f0d06a6a6964
Signed-off-by: Hank Donnay <hdonnay@redhat.com>
Change-Id: I8bd87cb66de93dad080c1d6d8aac34a96a6a6964
Signed-off-by: Hank Donnay <hdonnay@redhat.com>
Change-Id: I6c2d6cfae9f6e742056c157e38b8b6156a6a6964
This handles the "easy" case of simply proxying reads for uncompressed
tar archives to range requests.

Future improvements would move the "spooling" out of this package and
into the `fs.FS` implementation.

Signed-off-by: Hank Donnay <hdonnay@redhat.com>
Change-Id: I9d200dd841954054df0b187b9fd160a56a6a6964
@hdonnay

hdonnay commented Aug 26, 2026

Copy link
Copy Markdown
Member Author

/fast-forward

@github-actions
github-actions Bot merged commit 1b54724 into quay:main Aug 26, 2026
6 checks passed
@hdonnay
hdonnay deleted the hack/httpreader branch August 26, 2026 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants