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

DependsOn job dependency management #67

Merged
merged 6 commits into from
Aug 12, 2018

Conversation

michelvocks
Copy link
Member

Fixes #19 .

@michelvocks michelvocks self-assigned this Aug 1, 2018
@michelvocks michelvocks force-pushed the dependson branch 2 times, most recently from 6faa4ed to 332af72 Compare August 6, 2018 10:17
@codecov-io
Copy link

codecov-io commented Aug 6, 2018

Codecov Report

Merging #67 into master will increase coverage by 2.9%.
The diff coverage is 87.66%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master      #67     +/-   ##
=========================================
+ Coverage   60.98%   63.88%   +2.9%     
=========================================
  Files          18       19      +1     
  Lines        1548     1653    +105     
=========================================
+ Hits          944     1056    +112     
+ Misses        500      489     -11     
- Partials      104      108      +4
Impacted Files Coverage Δ
scheduler/workload.go 100% <100%> (ø)
scheduler/scheduler.go 75.09% <83.76%> (+12.93%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8b39c4e...ae46472. Read the comment docs.

@michelvocks michelvocks force-pushed the dependson branch 2 times, most recently from 041da49 to abd2434 Compare August 6, 2018 17:27
@michelvocks michelvocks changed the title [WIP][POC] DependsOn job dependency management [WIP] DependsOn job dependency management Aug 6, 2018
@michelvocks michelvocks requested a review from Skarlso August 6, 2018 17:27
@michelvocks michelvocks added the Needs Work The PR still requires some work from the submitter. label Aug 6, 2018
@michelvocks
Copy link
Member Author

michelvocks commented Aug 6, 2018

@Skarlso huge PR. I'm sorry 😥

A few points related to this PR:

job1 := sdk.Job{
    Title: "myjob",
    Handler: MyHandler,
}
job2 := sdk.Job{
    Title: "otherjob",
    Handler: OtherHandler,
    DependsOn: []sdk.Job{job1},
}

That would work but if your have a few jobs it will be a mess to handle. Especially when you want to change the depends-on structure. You end up coping all jobs in a specific order so that they exist... which sucks.

@michelvocks michelvocks changed the title [WIP] DependsOn job dependency management DependsOn job dependency management Aug 8, 2018
@michelvocks michelvocks removed the Needs Work The PR still requires some work from the submitter. label Aug 8, 2018
@Skarlso
Copy link
Member

Skarlso commented Aug 8, 2018

Gah!! Somehow I didn't get the email on the ping. :( So sorry @michelvocks. You can ping me in slack as well, if there is a PR to check. I'll get that for sure. :) Looking over it now.

Skarlso
Skarlso previously requested changes Aug 9, 2018
Copy link
Member

@Skarlso Skarlso left a comment

Choose a reason for hiding this comment

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

Some nits for now. I will need to take more rounds with this. It is indeed quiet large. :/

}

// Job has been resolved
if inResolved {
Copy link
Member

Choose a reason for hiding this comment

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

A nicer and better way of doing this is actually using labels.

OUTER:
for _, job := range j.DependsOn {
...
		var inResolved bool
		for _, resolvedJob := range resolved {
			if resolvedJob.ID == job.ID {
				continue OUTER
			}
		}
... // continue doing stuff here


// Job has been resolved
if resolved {
continue
Copy link
Member

Choose a reason for hiding this comment

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

Same as above. Use labels. Oh you might not be able to do that here since Iter is channels...

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah right. I actually hate this iter-channel stuff. You cannot leave the loop otherwise you get a deadlock. Might need to change that in the future.

Copy link
Member

Choose a reason for hiding this comment

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

There is no real benefit unless it's called multiple times from different routines.

// quit function if signaled.
// We do not block here because this is just a pre-validation step.
select {
case <-quit:
Copy link
Member

Choose a reason for hiding this comment

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

As per convention this is rather called done.

// After a workload has been send to the executenSCheduler, the method will
// block and wait until the workload is done.
// This method is designed to be called recursive and blocking.
func (s *Scheduler) resolveDependencies(j gaia.Job, mw *managedWorkloads, executenScheduler chan gaia.Job, quit chan bool) {
Copy link
Member

Choose a reason for hiding this comment

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

executenScheduler German a bit? :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, it was late. 😄

defer mw.Unlock()

// Search for the id
var i = -1
Copy link
Member

Choose a reason for hiding this comment

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

just i := -1

// Iterate all dependent jobs
for (let x = 0, y = deps.length; x < y; x++) {
// iterate again all jobs
for (let a = 0, b = jobs.length; a < b; a++) {
Copy link
Member

Choose a reason for hiding this comment

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

you got to have a better name for these buddy. :) It's really getting hard to follow all these as and xs and ys.

Copy link
Member Author

Choose a reason for hiding this comment

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

will rename them

plugin/plugin.go Outdated
plugin "github.com/hashicorp/go-plugin"
"github.com/michelvocks/protobuf"
Copy link
Member

Choose a reason for hiding this comment

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

Oh, I just noticed that this is also now your protobuf. I think this might be an auto import leftover?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's currently my fork otherwise it would not compile. I have to change it for sure before we merge this 😄

@michelvocks
Copy link
Member Author

@Skarlso fixed your suggestions. Thanks a lot 🤗

return &foundWorkload
}

// Replace takes the given worklaod and replaces it in the managedWorkloads
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: worklaod => workload

// This method is designed to be called recursive and blocking.
func (s *Scheduler) resolveDependencies(j gaia.Job, mw *managedWorkloads, executeScheduler chan gaia.Job, done chan bool) {
for _, depJob := range j.DependsOn {
// Check if this workdload is already resolved
Copy link
Contributor

Choose a reason for hiding this comment

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

workdload => workload

@michelvocks michelvocks mentioned this pull request Aug 10, 2018
@Skarlso Skarlso dismissed their stale review August 11, 2018 07:39

updated

@Skarlso
Copy link
Member

Skarlso commented Aug 11, 2018

@michelvocks I added some tests for workloads as well. Going to add one more after that it's ready to merge. :)

@Skarlso Skarlso added the Ready To Merge PR is ready to be merged into master label Aug 11, 2018
@Skarlso
Copy link
Member

Skarlso commented Aug 11, 2018

@michelvocks I think this is ready to merge. :) 100% coverage for workload. :)

@michelvocks michelvocks merged commit 22073ca into gaia-pipeline:master Aug 12, 2018
@michelvocks michelvocks deleted the dependson branch August 12, 2018 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready To Merge PR is ready to be merged into master
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants