From cb49dfffd877d4f20167a8424507ecb4c7f29bb1 Mon Sep 17 00:00:00 2001 From: Richard LT Date: Mon, 13 Jun 2022 15:08:09 +0200 Subject: [PATCH] feat(worker,hatchery): model requirement check enforce group name (#6209) --- engine/worker/internal/requirement.go | 4 ++-- sdk/hatchery/hatchery.go | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/engine/worker/internal/requirement.go b/engine/worker/internal/requirement.go index 257a24f386..878de3ed0a 100644 --- a/engine/worker/internal/requirement.go +++ b/engine/worker/internal/requirement.go @@ -121,8 +121,8 @@ func checkModelRequirement(w *CurrentWorker, r sdk.Requirement) (bool, error) { } isSharedInfra := w.model.Group.Name == sdk.SharedInfraGroupName && modelName == w.model.Name - isSameName := modelName == w.model.Name // for backward compatibility with runs, if only the name match we considered that the model can be used, keep this condition until the workflow runs were not migrated. - return isSharedInfra || isSameName, nil + + return isSharedInfra, nil } func checkServiceRequirement(w *CurrentWorker, r sdk.Requirement) (bool, error) { diff --git a/sdk/hatchery/hatchery.go b/sdk/hatchery/hatchery.go index a4ca73ca6e..a87f05f99f 100644 --- a/sdk/hatchery/hatchery.go +++ b/sdk/hatchery/hatchery.go @@ -423,8 +423,7 @@ func canRunJobWithModel(ctx context.Context, h InterfaceWithModels, j workerStar modelName := strings.Split(r.Value, " ")[0] isGroupModel := modelName == fmt.Sprintf("%s/%s", model.Group.Name, model.Name) isSharedInfraModel := model.Group.Name == sdk.SharedInfraGroupName && modelName == model.Name - isSameName := modelName == model.Name // for backward compatibility with runs, if only the name match we considered that the model can be used, keep this condition until the workflow runs were not migrated. - if !isGroupModel && !isSharedInfraModel && !isSameName { + if !isGroupModel && !isSharedInfraModel { log.Debug(ctx, "canRunJobWithModel> %d - job %d - model requirement r.Value(%s) do not match model.Name(%s) and model.Group(%s)", j.timestamp, j.id, strings.Split(r.Value, " ")[0], model.Name, model.Group.Name) next() return false