-
Notifications
You must be signed in to change notification settings - Fork 243
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
Conversation
6faa4ed
to
332af72
Compare
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
041da49
to
abd2434
Compare
@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. |
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. |
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.
Some nits for now. I will need to take more rounds with this. It is indeed quiet large. :/
scheduler/scheduler.go
Outdated
} | ||
|
||
// Job has been resolved | ||
if inResolved { |
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.
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 |
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.
Same as above. Use labels. Oh you might not be able to do that here since Iter is channels...
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 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.
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.
There is no real benefit unless it's called multiple times from different routines.
scheduler/scheduler.go
Outdated
// quit function if signaled. | ||
// We do not block here because this is just a pre-validation step. | ||
select { | ||
case <-quit: |
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.
As per convention this is rather called done
.
scheduler/scheduler.go
Outdated
// 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) { |
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.
executenScheduler
German a bit? :)
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.
Oh, it was late. 😄
scheduler/workload.go
Outdated
defer mw.Unlock() | ||
|
||
// Search for the id | ||
var i = -1 |
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.
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++) { |
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.
you got to have a better name for these buddy. :) It's really getting hard to follow all these a
s and x
s and y
s.
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.
will rename them
plugin/plugin.go
Outdated
plugin "github.com/hashicorp/go-plugin" | ||
"github.com/michelvocks/protobuf" |
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.
Oh, I just noticed that this is also now your protobuf. I think this might be an auto import leftover?
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.
It's currently my fork otherwise it would not compile. I have to change it for sure before we merge this 😄
@Skarlso fixed your suggestions. Thanks a lot 🤗 |
scheduler/workload.go
Outdated
return &foundWorkload | ||
} | ||
|
||
// Replace takes the given worklaod and replaces it in the managedWorkloads |
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.
Typo: worklaod => workload
scheduler/scheduler.go
Outdated
// 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 |
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.
workdload => workload
@michelvocks I added some tests for workloads as well. Going to add one more after that it's ready to merge. :) |
@michelvocks I think this is ready to merge. :) 100% coverage for workload. :) |
Fixes #19 .