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

fix(hatchery): context cancellation #3167

Merged
merged 1 commit into from
Aug 8, 2018
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
3 changes: 1 addition & 2 deletions sdk/hatchery/hatchery.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ func Create(h Interface) error {

workerRequest := workerStarterRequest{
ctx: currentCtx,
cancel: endTrace,
id: j.ID,
isWorkflowJob: true,
execGroups: j.ExecGroups,
Expand Down Expand Up @@ -307,7 +308,6 @@ func Create(h Interface) error {
temptToSpawn: true,
}
endTrace("no model or service ratio reached")

continue
}

Expand All @@ -317,7 +317,6 @@ func Create(h Interface) error {
//Ask to start
log.Info("hatchery> Request a worker for job %d (%.3f seconds elapsed)", j.ID, time.Since(t0).Seconds())
workersStartChan <- workerRequest
endTrace("")

case err := <-errs:
log.Error("%v", err)
Expand Down
7 changes: 7 additions & 0 deletions sdk/hatchery/starter.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

type workerStarterRequest struct {
ctx context.Context
cancel func(reason string)
id int64
isWorkflowJob bool
model sdk.Model
Expand Down Expand Up @@ -70,6 +71,12 @@ func workerStarter(h Interface, jobs <-chan workerStarterRequest, results chan<-
results <- res
end()

if err != nil {
j.cancel(err.Error())
} else {
j.cancel("")
}

} else { // Start a worker for registering
log.Debug("Spawning worker for register model %s", m.Name)
if atomic.LoadInt64(&nbWorkerToStart) > int64(h.Configuration().Provision.MaxConcurrentProvisioning) {
Expand Down