Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[backport 40] Fix Consul connections over consumtion on task monitoring #748

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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