Skip to content

Commit

Permalink
Adding support for using JMX image for e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosroman committed Nov 20, 2024
1 parent bedfa69 commit e304c9a
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 5 deletions.
5 changes: 5 additions & 0 deletions components/datadog/agent/docker.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package agent

import (
"fmt"
"strings"

"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
Expand Down Expand Up @@ -127,4 +128,8 @@ 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)
}
}
6 changes: 5 additions & 1 deletion components/datadog/agent/docker_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const (
defaultOTAgentImageTag = "nightly-ot-beta-main"
)

func dockerAgentFullImagePath(e config.Env, repositoryPath, imageTag string, otel bool) string {
func dockerAgentFullImagePath(e config.Env, repositoryPath, imageTag string, otel, jmx bool) string {
// return agent image path if defined
if e.AgentFullImagePath() != "" {
return e.AgentFullImagePath()
Expand Down Expand Up @@ -53,6 +53,10 @@ func dockerAgentFullImagePath(e config.Env, repositoryPath, imageTag string, ote
imageTag = dockerAgentImageTag(e, config.AgentSemverVersion)
}

if jmx {
imageTag = fmt.Sprintf("%s-jmx", imageTag)
}

return utils.BuildDockerImagePath(repositoryPath, imageTag)
}

Expand Down
2 changes: 1 addition & 1 deletion components/datadog/agent/ecs.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func ecsLinuxAgentSingleContainerDefinition(e config.Env, apiKeySSMParamName pul
Cpu: pulumi.IntPtr(200),
Memory: pulumi.IntPtr(512),
Name: pulumi.String("datadog-agent"),
Image: pulumi.String(dockerAgentFullImagePath(e, "public.ecr.aws/datadog/agent", "", false)),
Image: pulumi.String(dockerAgentFullImagePath(e, "public.ecr.aws/datadog/agent", "", false, false)),
Essential: pulumi.BoolPtr(true),
LinuxParameters: ecs.TaskDefinitionLinuxParametersArgs{
Capabilities: ecs.TaskDefinitionKernelCapabilitiesArgs{
Expand Down
4 changes: 2 additions & 2 deletions components/datadog/agent/ecsFargate.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

func ECSFargateLinuxContainerDefinition(e config.Env, image string, apiKeySSMParamName pulumi.StringInput, fakeintake *fakeintake.Fakeintake, logConfig ecs.TaskDefinitionLogConfigurationPtrInput) *ecs.TaskDefinitionContainerDefinitionArgs {
if image == "" {
image = dockerAgentFullImagePath(e, "public.ecr.aws/datadog/agent", "", false)
image = dockerAgentFullImagePath(e, "public.ecr.aws/datadog/agent", "", false, false)
}
return &ecs.TaskDefinitionContainerDefinitionArgs{
Cpu: pulumi.IntPtr(0),
Expand Down Expand Up @@ -96,7 +96,7 @@ func ECSFargateLinuxContainerDefinition(e config.Env, image string, apiKeySSMPar
// https://docs.aws.amazon.com/AmazonECS/latest/developerguide/tutorial-deploy-fluentbit-on-windows.html
func ECSFargateWindowsContainerDefinition(e config.Env, image string, apiKeySSMParamName pulumi.StringInput, fakeintake *fakeintake.Fakeintake) *ecs.TaskDefinitionContainerDefinitionArgs {
if image == "" {
image = dockerAgentFullImagePath(e, "public.ecr.aws/datadog/agent", "", false)
image = dockerAgentFullImagePath(e, "public.ecr.aws/datadog/agent", "", false, false)
}
return &ecs.TaskDefinitionContainerDefinitionArgs{
Cpu: pulumi.IntPtr(0),
Expand Down
2 changes: 1 addition & 1 deletion components/datadog/agent/kubernetes_helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func NewHelmInstallation(e config.Env, args HelmInstallationArgs, opts ...pulumi
}

// Compute some values
agentImagePath := dockerAgentFullImagePath(e, "", "", args.OTelAgent)
agentImagePath := dockerAgentFullImagePath(e, "", "", args.OTelAgent, false)
if args.AgentFullImagePath != "" {
agentImagePath = args.AgentFullImagePath
}
Expand Down
18 changes: 18 additions & 0 deletions components/datadog/dockeragentparams/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ type Params struct {
ImageTag string
// Repository is the docker repository to use.
Repository string
// JMX is true if the JMX image is needed
JMX bool
// AgentServiceEnvironment is a map of environment variables to set in the docker compose agent service's environment.
AgentServiceEnvironment pulumi.Map
// ExtraComposeManifests is a list of extra docker compose manifests to add beside the agent service.
Expand Down Expand Up @@ -85,6 +87,14 @@ func WithRepository(repository string) func(*Params) error {
}
}

// WithJMX makes the image be the one with Java installed
func WithJMX() func(*Params) error {
return func(p *Params) error {
p.JMX = true
return nil
}
}

func WithFullImagePath(fullImagePath string) func(*Params) error {
return func(p *Params) error {
p.FullImagePath = fullImagePath
Expand Down Expand Up @@ -223,3 +233,11 @@ func WithExtraComposeManifest(name string, content pulumi.StringInput) func(*Par
return nil
}
}

// WithExtraComposeInlineManifest adds extra docker.ComposeInlineManifest
func WithExtraComposeInlineManifest(cpms ...docker.ComposeInlineManifest) func(*Params) error {
return func(p *Params) error {
p.ExtraComposeManifests = append(p.ExtraComposeManifests, cpms...)
return nil
}
}

0 comments on commit e304c9a

Please sign in to comment.