diff --git a/CHANGELOG.md b/CHANGELOG.md index d62adc194..f8d61d5ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## UNRELEASED +### BUG FIXES + +* Over-consumption of Consul connections ([GH-745](https://github.com/ystia/yorc/issues/745)) + ## 4.1.1 (May 06, 2021) ### ENHANCEMENTS 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():