Skip to content

Commit 72c58ff

Browse files
committed
Remove pubsub integration
Pubsub was never used to my knowledge, and made the queue builder more complicated. This: - Removes pubsub integration - Changes `QueueInProgress` to no longer track how many crates were built since the last pubsub update - Makes the `BuilderState` enum much simpler - Fixes a bug where an error building a crate would freeze the whole queue for 60 seconds (since it would remain in whatever state it had before rather than calling increment). - Fixes a couple typos In particular, the queue builder is no longer doing network IO, so it's less likely anything can go wrong outside of a build.
1 parent 75f7a1c commit 72c58ff

File tree

4 files changed

+14
-97
lines changed

4 files changed

+14
-97
lines changed

src/build_queue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ impl BuildQueue {
153153
self.lock_path().exists()
154154
}
155155

156-
/// Creates a lock file. Daemon will check this lock file and stop operating if its exists.
156+
/// Creates a lock file. Daemon will check this lock file and stop operating if it exists.
157157
pub fn lock(&self) -> Result<()> {
158158
let path = self.lock_path();
159159
if !path.exists() {

src/utils/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ pub mod consistency;
1717
mod copy;
1818
pub(crate) mod daemon;
1919
mod html;
20-
mod pubsubhubbub;
2120
mod queue;
2221
mod queue_builder;
2322
mod rustc_version;

src/utils/pubsubhubbub.rs

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/utils/queue_builder.rs

Lines changed: 13 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
use crate::{
2-
docbuilder::RustwideBuilder,
3-
utils::{pubsubhubbub, report_error},
4-
BuildQueue,
5-
};
6-
use anyhow::{Context, Error};
1+
use crate::{docbuilder::RustwideBuilder, utils::report_error, BuildQueue};
2+
use anyhow::Error;
73
use log::{debug, error, info, warn};
84
use std::panic::{catch_unwind, AssertUnwindSafe};
95
use std::sync::Arc;
@@ -23,81 +19,47 @@ pub fn queue_builder(
2319
EmptyQueue,
2420
/// The builder has just seen the lock file.
2521
Locked,
26-
/// The builder has just finished building a crate. The enclosed count is the number of
27-
/// crates built since the caches have been refreshed.
28-
QueueInProgress(usize),
22+
/// The builder has started (or just finished) building a crate.
23+
QueueInProgress,
2924
}
3025

3126
let mut status = BuilderState::Fresh;
3227

3328
loop {
34-
if !status.is_in_progress() {
29+
if !matches!(status, BuilderState::QueueInProgress) {
3530
thread::sleep(Duration::from_secs(60));
3631
}
3732

3833
// check lock file
3934
if build_queue.is_locked() {
40-
warn!("Lock file exits, skipping building new crates");
35+
warn!("Lock file exists, skipping building new crates");
4136
status = BuilderState::Locked;
4237
continue;
4338
}
4439

45-
if status.count() >= 10 {
46-
// periodically, ping the hubs
47-
debug!("10 builds in a row; pinging pubsubhubhub");
48-
status = BuilderState::QueueInProgress(0);
49-
50-
match pubsubhubbub::ping_hubs().context("Failed to ping hub") {
51-
Err(e) => report_error(&e),
52-
Ok(n) => debug!("Succesfully pinged {} hubs", n),
53-
}
54-
}
55-
5640
// Only build crates if there are any to build
5741
debug!("Checking build queue");
58-
match build_queue
59-
.pending_count()
60-
.context("Failed to read the number of crates in the queue")
61-
{
42+
match build_queue.pending_count() {
6243
Err(e) => {
63-
report_error(&e);
44+
report_error(&e.context("Failed to read the number of crates in the queue"));
6445
continue;
6546
}
6647

6748
Ok(0) => {
68-
if status.count() > 0 {
69-
// ping the hubs before continuing
70-
match pubsubhubbub::ping_hubs().context("Failed to ping hub") {
71-
Err(e) => report_error(&e),
72-
Ok(n) => debug!("Succesfully pinged {} hubs", n),
73-
}
74-
}
7549
debug!("Queue is empty, going back to sleep");
7650
status = BuilderState::EmptyQueue;
7751
continue;
7852
}
7953

80-
Ok(queue_count) => {
81-
info!(
82-
"Starting build with {} crates in queue (currently on a {} crate streak)",
83-
queue_count,
84-
status.count()
85-
);
86-
}
54+
Ok(queue_count) => info!("Starting build with {} crates in queue", queue_count),
8755
}
8856

57+
status = BuilderState::QueueInProgress;
58+
8959
// If a panic occurs while building a crate, lock the queue until an admin has a chance to look at it.
9060
let res = catch_unwind(AssertUnwindSafe(|| {
91-
match build_queue
92-
.build_next_queue_package(&mut builder)
93-
.context("Failed to build crate from queue")
94-
{
95-
Err(e) => report_error(&e),
96-
Ok(crate_built) => {
97-
if crate_built {
98-
status.increment();
99-
}
100-
}
61+
if let Err(e) = build_queue.build_next_queue_package(&mut builder) {
62+
report_error(&e.context("Failed to build crate from queue"));
10163
}
10264
}));
10365

@@ -107,21 +69,4 @@ pub fn queue_builder(
10769
build_queue.lock().expect("failed to lock queue");
10870
}
10971
}
110-
111-
impl BuilderState {
112-
fn count(&self) -> usize {
113-
match *self {
114-
BuilderState::QueueInProgress(n) => n,
115-
_ => 0,
116-
}
117-
}
118-
119-
fn is_in_progress(&self) -> bool {
120-
matches!(*self, BuilderState::QueueInProgress(_))
121-
}
122-
123-
fn increment(&mut self) {
124-
*self = BuilderState::QueueInProgress(self.count() + 1);
125-
}
126-
}
12772
}

0 commit comments

Comments
 (0)