diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a81cb94b..2dc038044 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### BUG FIXES +* Over-consumption of Consul connections ([GH-745](https://github.com/ystia/yorc/issues/745)) * Yorc panics attempting to print an error handling a script execution stdout ([GH-741](https://github.com/ystia/yorc/issues/741)) * Error submitting a SLURM job with no execution option ([GH-739](https://github.com/ystia/yorc/issues/739)) diff --git a/tasks/tasks.go b/tasks/tasks.go index 481d46608..05b43f496 100644 --- a/tasks/tasks.go +++ b/tasks/tasks.go @@ -625,15 +625,11 @@ func MonitorTaskFailure(ctx context.Context, taskID string, f func()) { func monitorTaskFlag(ctx context.Context, taskID, flag string, value []byte, f func()) { go func() { var lastIndex uint64 + queryMeta := &api.QueryOptions{} + queryMeta = queryMeta.WithContext(ctx) for { - select { - case <-ctx.Done(): - log.Debugf("Task monitoring for flag %s exit", flag) - return - default: - } - - kvp, qMeta, err := consulutil.GetKV().Get(path.Join(consulutil.TasksPrefix, taskID, flag), &api.QueryOptions{WaitIndex: lastIndex}) + queryMeta.WaitIndex = lastIndex + kvp, qMeta, err := consulutil.GetKV().Get(path.Join(consulutil.TasksPrefix, taskID, flag), queryMeta) select { case <-ctx.Done():