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

Remove collisions on PrepareRun stage #546

Merged
merged 3 commits into from
Jun 8, 2018

Conversation

strangeman
Copy link
Contributor

Fix for #545

  1. I added isolation (same as for 'main' tasks) for prepare step
  2. I disabled listPlaybookHosts for tasks with project concurrency because it not needed for it

@strangeman strangeman changed the title Remove collisions on prepareTask stage Remove collisions on PrepareRun stage Jun 7, 2018
if t := p.queue[0]; t.task.Status != taskFailStatus {
if t.prepared {
fmt.Println("Running a task.")
resourceLocker <- &resourceLock{lock: true, holder: t}
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, you're right

resourceLocker <- &resourceLock{lock: true, holder: t}
go t.run()
p.queue = p.queue[1:]
} else {
Copy link
Contributor

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

Copy link
Contributor Author

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"

@twhiston
Copy link
Contributor

twhiston commented Jun 7, 2018

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.

@strangeman
Copy link
Contributor Author

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
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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

@twhiston
Copy link
Contributor

twhiston commented Jun 8, 2018

ok no worries re: tests, i'll try to add some for it in the coming weeks

@twhiston twhiston merged commit 853fe5f into semaphoreui:develop Jun 8, 2018
@strangeman strangeman deleted the 545-prepare-collisions branch October 22, 2018 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants