Skip to content

Fix test flake related to slow inventory collection #8763

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions nexus/inventory/src/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,35 @@ impl<'a> Collector<'a> {
// keeps the code simpler.

debug!(&self.log, "begin collection");
let start_time = std::time::Instant::now();

let step_start = std::time::Instant::now();
self.collect_all_mgs().await;
debug!(&self.log, "collect_all_mgs completed"; "duration" => ?step_start.elapsed());

let step_start = std::time::Instant::now();
self.collect_all_sled_agents().await;
debug!(&self.log, "collect_all_sled_agents completed"; "duration" => ?step_start.elapsed());

let step_start = std::time::Instant::now();
self.collect_all_keepers().await;
debug!(&self.log, "collect_all_keepers completed"; "duration" => ?step_start.elapsed());

let step_start = std::time::Instant::now();
self.collect_all_cockroach().await;
debug!(&self.log, "collect_all_cockroach completed"; "duration" => ?step_start.elapsed());

// The following must be called after "collect_all_sled_agents",
// or they'll see an empty set of services.
let step_start = std::time::Instant::now();
self.collect_all_timesync().await;
debug!(&self.log, "collect_all_timesync completed"; "duration" => ?step_start.elapsed());

let step_start = std::time::Instant::now();
self.collect_all_dns_generations().await;
debug!(&self.log, "collect_all_dns_generations completed"; "duration" => ?step_start.elapsed());

debug!(&self.log, "finished collection");
debug!(&self.log, "finished collection"; "total_duration" => ?start_time.elapsed());

Ok(self.in_progress.build())
}
Expand Down Expand Up @@ -462,7 +479,21 @@ impl<'a> Collector<'a> {
let url = format!("http://{addr}");
let log = self.log.new(o!("ntp_admin_url" => url.clone()));

(cfg.id, ntp_admin_client::Client::new(&url, log))
let timeout = Duration::from_secs(5);
let reqwest_client = reqwest::ClientBuilder::new()
.connect_timeout(timeout)
.timeout(timeout)
.build()
.expect("Failed to build HTTP client");

(
cfg.id,
ntp_admin_client::Client::new_with_client(
&url,
reqwest_client,
log,
),
)
})
.collect();

Expand Down
2 changes: 1 addition & 1 deletion nexus/src/app/background/tasks/inventory_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl InventoryCollector {
disable: bool,
) -> InventoryCollector {
let (tx, _) = watch::channel(None);
let timeout = Duration::from_secs(15);
let timeout = Duration::from_secs(5);
let cockroach_admin_client = CockroachClusterAdminClient::new(
opctx
.log
Expand Down
Loading