Skip to content

Commit

Permalink
Add timeout to support bundle calls (#5219)
Browse files Browse the repository at this point in the history
Listing modules when generating a support bundle requires the management socket. If the management socket has not started, then the support bundle request blocks forever.

This PR adds a timeout to management socket requests to prevent the request from hanging.
  • Loading branch information
gordonwang0 authored Jul 7, 2021
1 parent 876900a commit 16ede21
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions edgelet/support-bundle/src/support_bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,16 +213,24 @@ where
.runtime
.list_with_details()
.collect()
// Getting modules requires the management socket, which might not be available if
// aziot-edged hasn't started. Require this operation to complete within a timeout
// so it doesn't block forever on an unavailable socket.
.timeout(std::time::Duration::from_secs(30))
.then(move |result| {
future::ok(match result {
Ok(modules) => modules
future::ok(if let Ok(modules) = result {
modules
.into_iter()
.map(|(module, _s)| module.name().to_owned())
.filter(move |name| {
!include_ms_only || MS_MODULES.iter().any(|ms| ms == name)
})
.collect(),
Err(_) => Vec::new(),
.collect()
} else {
println!(
"Warning: Unable to call management socket. Module list not available."
);
Vec::new()
})
});

Expand Down

0 comments on commit 16ede21

Please sign in to comment.