Add an option for dev time: always build all jobs

This commit is contained in:
Graham Christensen 2018-03-18 16:10:12 -04:00
parent bebe197643
commit f971b7b22d
No known key found for this signature in database
GPG key ID: ACA1C1D120C83D5C
2 changed files with 39 additions and 13 deletions

View file

@ -51,21 +51,38 @@ fn main() {
}) })
.unwrap(); .unwrap();
channel let queue_name: String;
.declare_queue(easyamqp::QueueConfig { if cfg.runner.build_all_jobs != Some(true) {
queue: format!("build-inputs-{}", cfg.nix.system.clone()), queue_name = channel
passive: false, .declare_queue(easyamqp::QueueConfig {
durable: true, queue: format!("build-inputs-{}", cfg.nix.system.clone()),
exclusive: false, passive: false,
auto_delete: false, durable: true,
no_wait: false, exclusive: false,
arguments: None, auto_delete: false,
}) no_wait: false,
.unwrap(); arguments: None,
})
.unwrap().queue;
} else {
warn!("Building all jobs, please don't use this unless you're");
warn!("developing and have Graham's permission!");
queue_name = channel
.declare_queue(easyamqp::QueueConfig {
queue: "".to_owned(),
passive: false,
durable: false,
exclusive: true,
auto_delete: true,
no_wait: false,
arguments: None,
})
.unwrap().queue;
}
channel channel
.bind_queue(easyamqp::BindQueueConfig { .bind_queue(easyamqp::BindQueueConfig {
queue: format!("build-inputs-{}", cfg.nix.system.clone()), queue: queue_name.clone(),
exchange: "build-jobs".to_owned(), exchange: "build-jobs".to_owned(),
routing_key: None, routing_key: None,
no_wait: false, no_wait: false,
@ -82,7 +99,7 @@ fn main() {
cfg.runner.identity.clone(), cfg.runner.identity.clone(),
)), )),
easyamqp::ConsumeConfig { easyamqp::ConsumeConfig {
queue: format!("build-inputs-{}", cfg.nix.system.clone()), queue: queue_name.clone(),
consumer_tag: format!("{}-builder", cfg.whoami()), consumer_tag: format!("{}-builder", cfg.whoami()),
no_local: false, no_local: false,
no_ack: false, no_ack: false,
@ -93,6 +110,7 @@ fn main() {
) )
.unwrap(); .unwrap();
println!("Fetching jobs from {}", &queue_name);
channel.start_consuming(); channel.start_consuming();
channel.close(200, "Bye").unwrap(); channel.close(200, "Bye").unwrap();
println!("Closed the channel"); println!("Closed the channel");

View file

@ -62,6 +62,14 @@ pub struct RunnerConfig {
pub repos: Option<Vec<String>>, pub repos: Option<Vec<String>>,
pub trusted_users: Option<Vec<String>>, pub trusted_users: Option<Vec<String>>,
pub known_users: Option<Vec<String>>, pub known_users: Option<Vec<String>>,
/// If true, will create its own queue attached to the build job
/// exchange. This means that builders with this enabled will
/// trigger duplicate replies to the request for this
/// architecture.
///
/// This should only be turned on for development.
pub build_all_jobs: Option<bool>
} }
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]