From cbe7e21346f9d0773e2fff5e10d4cbf409b4ccdd Mon Sep 17 00:00:00 2001 From: Andrzej Kuriata Date: Mon, 7 Dec 2015 09:55:52 -0500 Subject: [PATCH] fix #479 - Plugins can remain running after a task fails to start --- scheduler/scheduler.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scheduler/scheduler.go b/scheduler/scheduler.go index 1a11e9ba4..01d2a63a7 100644 --- a/scheduler/scheduler.go +++ b/scheduler/scheduler.go @@ -326,8 +326,15 @@ func (s *scheduler) startTask(id, source string) []serror.SnapError { mts, plugins := s.gatherMetricsAndPlugins(t.workflow) cps := returnCorePlugin(plugins) - errs := s.metricManager.SubscribeDeps(t.ID(), mts, cps) - if len(errs) > 0 { + sub_errs := s.metricManager.SubscribeDeps(t.ID(), mts, cps) + if len(sub_errs) > 0 { + // Tear down plugin processes started so far. + unsub_errs := s.metricManager.UnsubscribeDeps(t.ID(), mts, cps) + errs := append(sub_errs, unsub_errs...) + logger.WithFields(log.Fields{ + "task-id": t.ID(), + "_error": errs, + }).Error("task failed to start due to dependencies") return errs }