Skip to content

Commit

Permalink
feat(api): ignore worker model group name in requirement when startin…
Browse files Browse the repository at this point in the history
…g worker (#4261)
  • Loading branch information
richardlt authored and sguiheux committed May 7, 2019
1 parent 3af23cd commit 9e58713
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion engine/hatchery/swarm/swarm_util_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func (h *HatcherySwarm) computeDockerOpts(isSharedInfra bool, requirements []sdk

func (d *dockerOpts) computeDockerOptsOnModelRequirement(isSharedInfra bool, req sdk.Requirement) error {
// args are separated by a space
// example: golang:1.9.1 --port=8080:8080/tcp
// example: myGroup/golang:1.9.1 --port=8080:8080/tcp
for idx, opt := range strings.Split(req.Value, " ") {
if idx == 0 || strings.TrimSpace(opt) == "" {
continue // it's image name
Expand Down
9 changes: 5 additions & 4 deletions engine/worker/requirement.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,12 @@ func checkModelRequirement(w *currentWorker, r sdk.Requirement) (bool, error) {
if w.model.ID == 0 {
return false, nil
}
t := strings.Split(r.Value, " ")
if len(t) > 0 {
return t[0] == w.model.Name, nil
modelName := strings.Split(r.Value, " ")[0]
modelPath := strings.SplitN(modelName, "/", 2)
if len(modelPath) == 2 {
modelName = modelPath[1]
}
return false, nil
return modelName == w.model.Name, nil
}

func checkNetworkAccessRequirement(w *currentWorker, r sdk.Requirement) (bool, error) {
Expand Down
2 changes: 1 addition & 1 deletion sdk/hatchery/hatchery.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ func canRunJob(h Interface, j workerStarterRequest, model sdk.Model) bool {
modelName = modelPath[1]
}
if modelName != model.Name {
log.Debug("canRunJob> %d - job %d - model requirement r.Value(%s) != model.Name(%s)", j.timestamp, j.id, strings.Split(r.Value, " ")[0], model.Name)
log.Debug("canRunJob> %d - job %d - model requirement from requirement r.Value(%s) don't match model.Name(%s)", j.timestamp, j.id, r.Value, model.Name)
return false
}
}
Expand Down

0 comments on commit 9e58713

Please sign in to comment.