From f95be8495f3f497a4dc316326e1700b2552ec55f Mon Sep 17 00:00:00 2001 From: Sven Urbanski Date: Fri, 27 Sep 2024 17:43:16 +0200 Subject: [PATCH] fix: improve prognosis performance (#1995) Ref: SRX-YNEAHU --- .../cd-service/pkg/repository/transformer.go | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/services/cd-service/pkg/repository/transformer.go b/services/cd-service/pkg/repository/transformer.go index a8f353ad5..2f39602e7 100644 --- a/services/cd-service/pkg/repository/transformer.go +++ b/services/cd-service/pkg/repository/transformer.go @@ -3457,21 +3457,19 @@ func (c *ReleaseTrain) Transform( return "", err } - prognosis := c.Prognosis(ctx, state, transaction, configs) - span2, ctx := tracer.StartSpanFromContext(ctx, "ReleaseTrain Apply") - defer span2.Finish() - - if prognosis.Error != nil { - return "", prognosis.Error - } - var targetGroupName = c.Target var envGroupConfigs, isEnvGroup = getEnvironmentGroupsEnvironmentsOrEnvironment(configs, targetGroupName, c.TargetType) + if len(envGroupConfigs) == 0 { + if c.TargetType == api.ReleaseTrainRequest_ENVIRONMENT.String() || c.TargetType == api.ReleaseTrainRequest_ENVIRONMENTGROUP.String() { + return "", grpc.PublicError(ctx, fmt.Errorf("could not find target of type %v and name '%v'", c.TargetType, targetGroupName)) + } + return "", grpc.PublicError(ctx, fmt.Errorf("could not find environment group or environment configs for '%v'", targetGroupName)) + } // sorting for determinism - envNames := make([]string, 0, len(prognosis.EnvironmentPrognoses)) - for envName := range prognosis.EnvironmentPrognoses { - envNames = append(envNames, envName) + envNames := make([]string, 0, len(envGroupConfigs)) + for env := range envGroupConfigs { + envNames = append(envNames, env) } sort.Strings(envNames)