Skip to content

Commit

Permalink
Log when we receive a 503 Service Unavailable
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-F-Bryan committed May 28, 2023
1 parent 5974333 commit 6c2bb4b
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/wasi/src/runtime/package_loader/builtin_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl BuiltinPackageLoader {

if !response.is_ok() {
let url = &dist.webc;
return Err(crate::runtime::resolver::polyfills::http_error(&response)
return Err(crate::runtime::resolver::utils::http_error(&response)
.context(format!("The GET request to \"{url}\" failed")));
}

Expand Down
2 changes: 1 addition & 1 deletion lib/wasi/src/runtime/resolver/filesystem_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl Source for FileSystemSource {
let container = Container::from_disk(&path)
.with_context(|| format!("Unable to parse \"{}\"", path.display()))?;

let url = crate::runtime::resolver::polyfills::url_from_file_path(&path)
let url = crate::runtime::resolver::utils::url_from_file_path(&path)
.ok_or_else(|| anyhow::anyhow!("Unable to turn \"{}\" into a URL", path.display()))?;

let summary = PackageSummary {
Expand Down
2 changes: 1 addition & 1 deletion lib/wasi/src/runtime/resolver/in_memory_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ mod tests {
entrypoint: Some("bash".to_string()),
},
dist: DistributionInfo {
webc: crate::runtime::resolver::polyfills::url_from_file_path(
webc: crate::runtime::resolver::utils::url_from_file_path(
bash.canonicalize().unwrap()
)
.unwrap(),
Expand Down
2 changes: 1 addition & 1 deletion lib/wasi/src/runtime/resolver/inputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl PackageSummary {
let container = Container::from_disk(&path)?;
let webc_sha256 = WebcHash::for_file(&path)?;
let url =
crate::runtime::resolver::polyfills::url_from_file_path(&path).ok_or_else(|| {
crate::runtime::resolver::utils::url_from_file_path(&path).ok_or_else(|| {
anyhow::anyhow!("Unable to turn \"{}\" into a file:// URL", path.display())
})?;

Expand Down
2 changes: 1 addition & 1 deletion lib/wasi/src/runtime/resolver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ mod in_memory_source;
mod inputs;
mod multi_source_registry;
mod outputs;
pub(crate) mod polyfills;
pub(crate) mod utils;
mod resolve;
mod source;
mod wapm_source;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ pub(crate) fn http_error(response: &HttpResponse) -> Error {
.get("Retry-After")
.and_then(|retry_after| retry_after.to_str().ok())
{
tracing::debug!(
%retry_after,
"Received 503 Service Unavailable while looking up a package. The backend may still be generating the *.webc file.",
);
return anyhow::anyhow!("{status} (Retry After: {retry_after})");
}
}
Expand Down
8 changes: 4 additions & 4 deletions lib/wasi/src/runtime/resolver/web_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,15 @@ impl WebSource {
let request = HttpRequest {
url: url.clone(),
method: Method::HEAD,
headers: super::polyfills::webc_headers(),
headers: super::utils::webc_headers(),
body: None,
options: Default::default(),
};

let response = self.client.request(request).await?;

if !response.is_ok() {
return Err(super::polyfills::http_error(&response)
return Err(super::utils::http_error(&response)
.context(format!("The HEAD request to \"{url}\" failed")));
}

Expand All @@ -208,14 +208,14 @@ impl WebSource {
let request = HttpRequest {
url: url.clone(),
method: Method::GET,
headers: super::polyfills::webc_headers(),
headers: super::utils::webc_headers(),
body: None,
options: Default::default(),
};
let response = self.client.request(request).await?;

if !response.is_ok() {
return Err(super::polyfills::http_error(&response)
return Err(super::utils::http_error(&response)
.context(format!("The GET request to \"{url}\" failed")));
}

Expand Down

0 comments on commit 6c2bb4b

Please sign in to comment.