Skip to content

Commit

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

[backport 40] Fix Consul connections over consumtion on task monitoring
  • Loading branch information
loicalbertin authored Jun 11, 2021
2 parents 32f91cd + d5400c4 commit f2019f6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))

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 f2019f6

Please sign in to comment.