Skip to content
Snippets Groups Projects
Commit ce64ba07 authored by Sybren A. Stüvel's avatar Sybren A. Stüvel
Browse files

Manager: added /timeout URL to kick the task timeout checker

The task timeout checker runs periodically, but only starts 5 minutes after
manager startup. This allows workers to push updates to the manager after
downtime, before getting timed out. This /timeout URL is there to allow
enforcing timeouts within that 5 minute window.
parent 0b2a2111
No related branches found
No related tags found
No related merge requests found
...@@ -53,7 +53,7 @@ func (self *TaskTimeoutChecker) Go() { ...@@ -53,7 +53,7 @@ func (self *TaskTimeoutChecker) Go() {
self.done_chan, self.done_wg) self.done_chan, self.done_wg)
for _ = range timer { for _ = range timer {
self.check(db) self.Check(db)
} }
} }
...@@ -65,7 +65,7 @@ func (self *TaskTimeoutChecker) Close() { ...@@ -65,7 +65,7 @@ func (self *TaskTimeoutChecker) Close() {
log.Debug("TaskTimeoutChecker: shutdown complete.") log.Debug("TaskTimeoutChecker: shutdown complete.")
} }
func (self *TaskTimeoutChecker) check(db *mgo.Database) { func (self *TaskTimeoutChecker) Check(db *mgo.Database) {
timeout_threshold := UtcNow().Add(-self.config.ActiveTaskTimeoutInterval) timeout_threshold := UtcNow().Add(-self.config.ActiveTaskTimeoutInterval)
log.Debugf("Failing all active tasks that have not been touched since %s", timeout_threshold) log.Debugf("Failing all active tasks that have not been touched since %s", timeout_threshold)
......
...@@ -50,6 +50,14 @@ func http_kick(w http.ResponseWriter, r *http.Request) { ...@@ -50,6 +50,14 @@ func http_kick(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "Kicked task downloader") fmt.Fprintln(w, "Kicked task downloader")
} }
func http_timeout(w http.ResponseWriter, r *http.Request) {
mongo_sess := session.Copy()
defer mongo_sess.Close()
task_timeout_checker.Check(mongo_sess.DB(""))
fmt.Fprintln(w, "Kicked task timeouter")
}
func http_task_update(w http.ResponseWriter, r *auth.AuthenticatedRequest) { func http_task_update(w http.ResponseWriter, r *auth.AuthenticatedRequest) {
mongo_sess := session.Copy() mongo_sess := session.Copy()
defer mongo_sess.Close() defer mongo_sess.Close()
...@@ -209,6 +217,7 @@ func main() { ...@@ -209,6 +217,7 @@ func main() {
router.HandleFunc("/may-i-run/{task-id}", worker_authenticator.Wrap(http_worker_may_run_task)).Methods("GET") router.HandleFunc("/may-i-run/{task-id}", worker_authenticator.Wrap(http_worker_may_run_task)).Methods("GET")
router.HandleFunc("/sign-off", worker_authenticator.Wrap(http_worker_sign_off)).Methods("POST") router.HandleFunc("/sign-off", worker_authenticator.Wrap(http_worker_sign_off)).Methods("POST")
router.HandleFunc("/kick", http_kick) router.HandleFunc("/kick", http_kick)
router.HandleFunc("/timeout", http_timeout)
upstream.SendStartupNotification() upstream.SendStartupNotification()
go task_update_pusher.Go() go task_update_pusher.Go()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment