diff --git a/components/datadog/agent/docker.go b/components/datadog/agent/docker.go index 119565dd3..7bdd7acd6 100644 --- a/components/datadog/agent/docker.go +++ b/components/datadog/agent/docker.go @@ -117,6 +117,13 @@ func dockerAgentComposeManifest(agentImagePath string, apiKey pulumi.StringInput } func defaultAgentParams(params *dockeragentparams.Params) { + // After setting params.FullImagePath check if you need to use JMX Docker image + defer func(p *dockeragentparams.Params) { + if p.JMX { + p.FullImagePath = fmt.Sprintf("%s-jmx", p.FullImagePath) + } + }(params) + if params.FullImagePath != "" { return } @@ -128,8 +135,4 @@ func defaultAgentParams(params *dockeragentparams.Params) { params.ImageTag = defaultAgentImageTag } params.FullImagePath = utils.BuildDockerImagePath(params.Repository, params.ImageTag) - - if params.JMX { - params.FullImagePath = fmt.Sprintf("%s-jmx", params.FullImagePath) - } } diff --git a/components/datadog/dockeragentparams/params.go b/components/datadog/dockeragentparams/params.go index 59c847614..a677da1bb 100644 --- a/components/datadog/dockeragentparams/params.go +++ b/components/datadog/dockeragentparams/params.go @@ -60,14 +60,17 @@ func NewParams(e config.Env, options ...Option) (*Params, error) { } if e.PipelineID() != "" && e.CommitSHA() != "" { - exists, err := e.InternalRegistryImageTagExists(fmt.Sprintf("%s/agent", e.InternalRegistry()), fmt.Sprintf("%s-%s", e.PipelineID(), e.CommitSHA())) - if err != nil { - return nil, err - } - if !exists { - return nil, fmt.Errorf("image %s/agent:%s not found in the internal registry", e.InternalRegistry(), fmt.Sprintf("%s-%s", e.PipelineID(), e.CommitSHA())) + baseTag := fmt.Sprintf("%s-%s", e.PipelineID(), e.CommitSHA()) + for _, tag := range []string{baseTag, fmt.Sprintf("%s-jmx", baseTag)} { + exists, err := e.InternalRegistryImageTagExists(fmt.Sprintf("%s/agent", e.InternalRegistry()), tag) + if err != nil { + return nil, err + } + if !exists { + return nil, fmt.Errorf("image %s/agent:%s not found in the internal registry", e.InternalRegistry(), tag) + } } - options = append(options, WithFullImagePath(utils.BuildDockerImagePath("669783387624.dkr.ecr.us-east-1.amazonaws.com/agent", fmt.Sprintf("%s-%s", e.PipelineID(), e.CommitSHA())))) + options = append(options, WithFullImagePath(utils.BuildDockerImagePath("669783387624.dkr.ecr.us-east-1.amazonaws.com/agent", baseTag))) } return common.ApplyOption(version, options)