8000 feat(api): ignore worker model group name in requirement when startin… · ovh/cds@9e58713 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit 9e58713

Browse files
richardltsguiheux
authored andcommitted
feat(api): ignore worker model group name in requirement when starting worker (#4261)
1 parent 3af23cd commit 9e58713

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

engine/hatchery/swarm/swarm_util_create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ func (h *HatcherySwarm) computeDockerOpts(isSharedInfra bool, requirements []sdk
199199

200200
func (d *dockerOpts) computeDockerOptsOnModelRequirement(isSharedInfra bool, req sdk.Requirement) error {
201201
// args are separated by a space
202-
// example: golang:1.9.1 --port=8080:8080/tcp
202+
// example: myGroup/golang:1.9.1 --port=8080:8080/tcp
203203
for idx, opt := range strings.Split(req.Value, " ") {
204204
if idx == 0 || strings.TrimSpace(opt) == "" {
205205
continue // it's image name

engine/worker/requirement.go

Lines changed: 5 additions & 4 deletions
8000
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,12 @@ func checkModelRequirement(w *currentWorker, r sdk.Requirement) (bool, error) {
115115
if w.model.ID == 0 {
116116
return false, nil
117117
}
118-
t := strings.Split(r.Value, " ")
119-
if len(t) > 0 {
120-
return t[0] == w.model.Name, nil
118+
modelName := strings.Split(r.Value, " ")[0]
119+
modelPath := strings.SplitN(modelName, "/", 2)
120+
if len(modelPath) == 2 {
121+
modelName = modelPath[1]
121122
}
122-
return false, nil
123+
return modelName == w.model.Name, nil
123124
}
124125

125126
func checkNetworkAccessRequirement(w *currentWorker, r sdk.Requirement) (bool, error) {

sdk/hatchery/hatchery.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ func canRunJob(h Interface, j workerStarterRequest, model sdk.Model) bool {
363363
modelName = modelPath[1]
364364
}
365365
if modelName != model.Name {
366-
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)
366+
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)
367367
return false
368368
}
369369
}

0 commit comments

Comments
 (0)
0