-
Notifications
You must be signed in to change notification settings - Fork 117
fix(minidump): Streaming uploads from external relays #5977
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
Changes from 7 commits
258008a
446608b
ead27e7
eb07686
d121d95
3081790
3728a42
086aa74
af63465
0fbc612
2d181f1
d60db31
66d2616
23f6990
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,7 +30,9 @@ | |
| #[cfg(feature = "processing")] | ||
| use crate::services::objectstore; | ||
| use crate::services::projects::cache::Project; | ||
| use crate::services::upload::{self, ByteStream, SignedLocation}; | ||
| use crate::services::upload::{ | ||
| self, ByteStream, Final, LocationQueryParams, Provisional, SignedLocation, UploadLength, | ||
| }; | ||
| use crate::services::upstream::UpstreamRequestError; | ||
| use crate::statsd::RelayCounters; | ||
| use crate::utils::{ApiErrorResponse, MeteredStream}; | ||
|
|
@@ -76,7 +78,6 @@ | |
| } | ||
|
|
||
| let status = match self { | ||
| Error::Tus(tus::Error::DeferLengthNotAllowed) => StatusCode::FORBIDDEN, | ||
| Error::Tus(_) => StatusCode::BAD_REQUEST, | ||
| Error::Request(error) => return error.into_response(), | ||
| Error::SendError(_) => StatusCode::INTERNAL_SERVER_ERROR, | ||
|
|
@@ -129,7 +130,7 @@ | |
| } | ||
| } | ||
|
|
||
| impl IntoResponse for SignedLocation { | ||
| impl<L: UploadLength> IntoResponse for SignedLocation<L> { | ||
| fn into_response(self) -> Response { | ||
| let mut headers = tus::response_headers(); | ||
| match self.into_header_value() { | ||
|
|
@@ -153,8 +154,7 @@ | |
| check_kill_switch(&state)?; | ||
|
|
||
| relay_log::trace!("Validating headers"); | ||
| let upload_length = tus::validate_post_headers(&headers, meta.request_trust().is_trusted()) | ||
| .map_err(Error::from)?; | ||
| let upload_length = tus::validate_post_headers(&headers).map_err(Error::from)?; | ||
|
Check warning on line 157 in relay-server/src/endpoints/upload.rs
|
||
| let config = state.config(); | ||
|
|
||
| if upload_length.is_some_and(|len| len > config.max_upload_size()) { | ||
|
|
@@ -177,6 +177,7 @@ | |
| let scoping = check_request(&state, meta, upload_length, project).await?; | ||
|
|
||
| // Unconditionally create the upload location: | ||
| relay_log::trace!("Creating upload location"); | ||
| let result = create(&state, scoping, upload_length).await; | ||
| let location = result.inspect_err(|e| { | ||
| relay_log::warn!(error = e as &dyn std::error::Error, "create failed"); | ||
|
|
@@ -195,7 +196,7 @@ | |
| meta: RequestMeta, | ||
| headers: HeaderMap, | ||
| Path(upload::LocationPath { project_id, key }): Path<upload::LocationPath>, | ||
| Query(upload::LocationQueryParams { length, signature }): Query<upload::LocationQueryParams>, | ||
| Query(LocationQueryParams { length, signature }): Query<LocationQueryParams<Provisional>>, | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Introducing the differentiation between |
||
| body: Body, | ||
| ) -> axum::response::Result<impl IntoResponse> { | ||
| check_kill_switch(&state)?; | ||
|
|
@@ -220,15 +221,15 @@ | |
| })?; | ||
|
|
||
| relay_log::trace!("Checking request"); | ||
| let scoping = check_request(&state, meta, length, project).await?; | ||
| let scoping = check_request(&state, meta, length.value(), project).await?; | ||
|
|
||
| let stream = body | ||
| .into_data_stream() | ||
| .map(|result| result.map_err(io::Error::other)) | ||
| .boxed(); | ||
| let stream = MeteredStream::new(stream, "upload"); | ||
|
|
||
| let (lower_bound, upper_bound) = match length { | ||
| let (lower_bound, upper_bound) = match length.value() { | ||
| None => (1, config.max_upload_size()), | ||
| Some(u) => (u, u), | ||
| }; | ||
|
|
@@ -282,7 +283,7 @@ | |
| state: &ServiceState, | ||
| scoping: Scoping, | ||
| upload_length: Option<usize>, | ||
| ) -> Result<SignedLocation, Error> { | ||
| ) -> Result<SignedLocation<Provisional>, Error> { | ||
| let location = state | ||
| .upload() | ||
| .send(upload::Create { | ||
|
|
@@ -297,9 +298,9 @@ | |
| async fn upload( | ||
| state: &ServiceState, | ||
| scoping: Scoping, | ||
| location: SignedLocation, | ||
| location: SignedLocation<Provisional>, | ||
| stream: BoundedStream<MeteredStream<ByteStream>>, | ||
| ) -> Result<SignedLocation, Error> { | ||
| ) -> Result<SignedLocation<Final>, Error> { | ||
| let location = state | ||
| .upload() | ||
| .send(upload::Stream { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the functional change of this PR: We now always allow the
Defer-Length: 1header (i.e. open-ended uploads for which the length is unknown upfront). Correct rate limiting is guaranteed by theSignedLocation<Final>type.