Skip to content

Commit

Permalink
Not allow null'ish schedule
Browse files Browse the repository at this point in the history
  • Loading branch information
tailhook committed Feb 15, 2018
1 parent 27d87f6 commit 7b0e667
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/daemon/scheduler/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ pub fn main(state: SharedState, settings: Settings) -> !
current_host: settings.hostname.clone(),
current_id: settings.id.clone(),
parents: cookie.parent_schedules.iter()
.map(|x| Parent(x.clone())).collect(),
.map(|x| Parent(x.clone())).collect(),
actions: cookie.actions.clone(),
runtime: runtime.data.clone(),
// TODO(tailhook) show runtime errors
Expand All @@ -204,11 +204,19 @@ pub fn main(state: SharedState, settings: Settings) -> !
SCHEDULING_TIME.set((Instant::now() - instant).to_msec() as i64);

let json = match result {
Ok(json) => {
Ok(json @ Json::Object(_)) => {
state.clear_error("scheduler");
SCHEDULER_SUCCEEDED.incr(1);
json
}
Ok(val) => {
error!("Scheduler returned {:?}", val);
state.set_error("scheduler", "invalid return value".into());
state.set_schedule_debug_info(input, dbg);
SCHEDULER_FAILED.incr(1);
sleep(Duration::from_secs(1));
continue;
}
Err(e) => {
error!("Scheduling failed: {}", e);
state.set_error("scheduler", format!("{}", e));
Expand Down

0 comments on commit 7b0e667

Please sign in to comment.