diff --git a/app/src/storage/blobs.rs b/app/src/storage/blobs.rs index a5c3eb13..115c2d8b 100644 --- a/app/src/storage/blobs.rs +++ b/app/src/storage/blobs.rs @@ -259,11 +259,19 @@ impl BlobStore { let url = self.bucket.create_bucket(&self.credentials).sign(URL_TTL); let response = self.http.put(url).send().await.map_err(|e| error(e.to_string()))?; let status = response.status(); - if status.is_success() || status.as_u16() == 409 { - Ok(()) - } else { - Err(error(format!("creating bucket: HTTP {status}"))) + if !(status.is_success() || status.as_u16() == 409) { + return Err(error(format!("creating bucket: HTTP {status}"))); + } + // A 409 can come while another caller is still creating the bucket (tests in one binary all start by making + // it), and an upload straight after then gets NoSuchBucket: wait until the bucket answers. + for _ in 0..100 { + let url = self.bucket.head_bucket(Some(&self.credentials)).sign(URL_TTL); + if self.http.head(url).send().await.is_ok_and(|r| r.status().is_success()) { + return Ok(()); + } + tokio::time::sleep(Duration::from_millis(100)).await; } + Err(error("the bucket still isn't there 10 s after creating it")) } /// The application's store (`S3_*`): one per application, from the container, so its HTTP connections belong to