-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Remove collisions on PrepareRun stage #546
Remove collisions on PrepareRun stage #546
Conversation
api/tasks/pool.go
Outdated
if t := p.queue[0]; t.task.Status != taskFailStatus { | ||
if t.prepared { | ||
fmt.Println("Running a task.") | ||
resourceLocker <- &resourceLock{lock: true, holder: t} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be outside of the conditional since we do it on both sides of the branch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, you're right
api/tasks/pool.go
Outdated
resourceLocker <- &resourceLock{lock: true, holder: t} | ||
go t.run() | ||
p.queue = p.queue[1:] | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe it makes sense to reverse the logic and put the prepare inside the branch then make run the default
behavior that occurs after, outside of a branch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this makes sense. In this case, we will get more straightforward logic: "prepare task if it not prepared and then launch it"
is there any way we could write a test to prove this works as well? Would be cool to start trying to add tests for this stuff so we can ensure we don't get regressions. |
089d9c3
to
a817d2d
Compare
Uhh, I'm not sure how we can cover it via tests :( |
resourceLocker <- &resourceLock{lock: true, holder: t} | ||
if !t.prepared { | ||
go t.prepareRun() | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we continue here and not just directly run the task after we prepare it? The next tick will just run the task anyway right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope, without continue
it trying to run a task at the same tick with prepare
because it checking the lock before this branch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should have had a coffee before reviewing this pr 😆
approved
ok no worries re: tests, i'll try to add some for it in the coming weeks |
Fix for #545
listPlaybookHosts
for tasks withproject
concurrency because it not needed for it