Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider: use StreamingBody for image upload #2923

Closed
david-crespo opened this issue Apr 25, 2023 · 1 comment
Closed

Consider: use StreamingBody for image upload #2923

david-crespo opened this issue Apr 25, 2023 · 1 comment
Labels
nexus Related to nexus storage Related to storage.

Comments

@david-crespo
Copy link
Contributor

As of #2418, uploading an image is done by posting the whole image in 512kb chunks, keyed by offset. That's done in the CLI in oxidecomputer/oxide.rs#109. I am working on doing something similar in the web console: oxidecomputer/console#1453.

The responsibility for doing the chunking and making all those calls is offloaded to the client. While making 500 or 1000 network round trips from the browser or CLI is not ideal, this is a reasonable strategy and we have gone for make-the-client-do-it in other contexts as well.

However, the StreamingBody extractor added in oxidecomputer/dropshot#617 seems like a really good fit for this. It takes a single streaming body and does precisely the chunking that we're doing on the client-side. So the client would make a single streaming request with the file, and Nexus is able to loop through chunks and call disk_manual_import on each. See BufList chunking example in Dropshot.

/// Bulk write some bytes into a disk that's in state ImportingFromBulkWrites
pub async fn disk_manual_import(

Obstacles

Max request size

Streaming bodies are subject to our global configured max request body size, which is going to be too small for images, which you can expect to be measured in GiB. @sunshowers has oxidecomputer/dropshot#618 to allow per-endpoint configuration of this maximum, but hasn't been able to get them over the line due to more urgent work. Bumping the global max to a huge number is not a great interim solution.

This is new work and we already have something that works

I don't want to push this too hard for this reason. Just want to record my findings and have a good plan for followup work. I'm going to start by implementing the console side using the many POSTs and we'll see how it goes.

@david-crespo david-crespo added storage Related to storage. nexus Related to nexus labels Apr 25, 2023
@david-crespo
Copy link
Contributor Author

david-crespo commented Apr 27, 2023

Bad news! Browser support is not there in Firefox or Safari and doesn't appear to be coming soon. I'd say that more or less rules this idea out. Welp. We could still add it alongside the existing endpoint to use in the CLI, but at least in the short term there's no way it's a priority to do that because it duplicates an existing working thing.

https://caniuse.com/mdn-api_request_request_request_body_readablestream

image

@david-crespo david-crespo closed this as not planned Won't fix, can't repro, duplicate, stale Jun 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
nexus Related to nexus storage Related to storage.
Projects
None yet
Development

No branches or pull requests

1 participant