From 24c004762ef474adf5cecbc90c3d59cad54eaadd Mon Sep 17 00:00:00 2001 From: Coenen Benjamin Date: Wed, 17 Oct 2018 14:15:39 +0200 Subject: [PATCH] feat(hatchery): display warning in spawn info for deprecated model (close #3422) (#3464) Signed-off-by: Benjamin Coenen --- sdk/hatchery/hatchery.go | 6 ++++++ sdk/hatchery/starter.go | 10 ++++++++++ sdk/messages.go | 2 ++ 3 files changed, 18 insertions(+) diff --git a/sdk/hatchery/hatchery.go b/sdk/hatchery/hatchery.go index 67aa762a5d..108645643b 100644 --- a/sdk/hatchery/hatchery.go +++ b/sdk/hatchery/hatchery.go @@ -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 diff --git a/sdk/hatchery/starter.go b/sdk/hatchery/starter.go index f91b59907d..68e3a69a11 100644 --- a/sdk/hatchery/starter.go +++ b/sdk/hatchery/starter.go @@ -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 { diff --git a/sdk/messages.go b/sdk/messages.go index edb1454ab6..0e870eca6c 100644 --- a/sdk/messages.go +++ b/sdk/messages.go @@ -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 @@ -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