Skip to content

Commit

Permalink
feat(hatchery): display warning in spawn info for deprecated model (c…
Browse files Browse the repository at this point in the history
…lose #3422) (#3464)

Signed-off-by: Benjamin Coenen <benjamin.coenen@corp.ovh.com>
  • Loading branch information
bnjjj committed Oct 17, 2018
1 parent 3cb2f8e commit 24c0047
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sdk/hatchery/hatchery.go
Expand Up @@ -424,6 +424,12 @@ func canRunJob(h Interface, j workerStarterRequest, model sdk.Model) bool {
containsHostnameRequirement = true
}
}

if model.IsDeprecated && !containsModelRequirement {
log.Debug("canRunJob> %d - job %d - Cannot launch this model because it is deprecated", j.timestamp, j.id)
return false
}

// Common check
for _, r := range j.requirements {
// If requirement is a Model requirement, it's easy. It's either can or can't run
Expand Down
10 changes: 10 additions & 0 deletions sdk/hatchery/starter.go
Expand Up @@ -191,6 +191,16 @@ func spawnWorkerForJob(h Interface, j workerStarterRequest) (bool, error) {
},
})

if j.model.IsDeprecated {
infos = append(infos, sdk.SpawnInfo{
RemoteTime: time.Now(),
Message: sdk.SpawnMsg{
ID: sdk.MsgSpawnInfoDeprecatedModel.ID,
Args: []interface{}{j.model.Name},
},
})
}

ctxtJobSendSpawnInfo, cancelJobSendSpawnInfo := context.WithTimeout(ctx, 10*time.Second)
_, next = observability.Span(ctx, "hatchery.QueueJobSendSpawnInfo", observability.Tag("status", "spawnOK"))
if err := h.CDSClient().QueueJobSendSpawnInfo(ctxtJobSendSpawnInfo, j.isWorkflowJob, j.id, infos); err != nil {
Expand Down
2 changes: 2 additions & 0 deletions sdk/messages.go
Expand Up @@ -76,6 +76,7 @@ var (
MsgWorkflowImportedInserted = &Message{"MsgWorkflowImportedInserted", trad{FR: "Le workflow %s a été créé", EN: "Workflow %s has been created"}, nil}
MsgSpawnInfoHatcheryCannotStartJob = &Message{"MsgSpawnInfoHatcheryCannotStart", trad{FR: "Aucune hatchery n'a pu démarrer de worker respectant vos pré-requis de job, merci de les vérifier.", EN: "No hatchery can spawn a worker corresponding your job's requirements. Please check your job's requirements."}, nil}
MsgWorkflowRunBranchDeleted = &Message{"MsgWorkflowRunBranchDeleted", trad{FR: "La branche %s a été supprimée", EN: "Branch %s has been deleted"}, nil}
MsgSpawnInfoDeprecatedModel = &Message{"MsgSpawnInfoDeprecatedModel", trad{FR: "Attention vous utilisez un worker model (%s) déprécié", EN: "Pay attention you are using a deprecated worker model (%s)"}, nil}
)

// Messages contains all sdk Messages
Expand Down Expand Up @@ -137,6 +138,7 @@ var Messages = map[string]*Message{
MsgWorkflowNodeMutexRelease.ID: MsgWorkflowNodeMutexRelease,
MsgSpawnInfoHatcheryCannotStartJob.ID: MsgSpawnInfoHatcheryCannotStartJob,
MsgWorkflowRunBranchDeleted.ID: MsgWorkflowRunBranchDeleted,
MsgSpawnInfoDeprecatedModel.ID: MsgSpawnInfoDeprecatedModel,
}

//Message represent a struc format translated messages
Expand Down

0 comments on commit 24c0047

Please sign in to comment.