Skip to content

Commit

Permalink
Merge pull request #747 from ystia/backport_41/bugfix/GH-745_Over_con…
Browse files Browse the repository at this point in the history
…sumption_of_Consul_connections

[backport 41] Fix Consul connections over consumtion on task monitoring
  • Loading branch information
loicalbertin authored Jun 11, 2021
2 parents c1876bc + bc1e530 commit b721fc9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 4 additions & 8 deletions tasks/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit b721fc9

Please sign in to comment.