Skip to content

Commit

Permalink
Merge branch 'main' of github.com:DataDog/datadog-operator into lenai…
Browse files Browse the repository at this point in the history
…c/CONTINT-4412
  • Loading branch information
L3n41c committed Oct 7, 2024
2 parents 6e9e14d + 6dc343d commit 4a3f1d5
Show file tree
Hide file tree
Showing 56 changed files with 2,301 additions and 874 deletions.
2 changes: 2 additions & 0 deletions api/datadoghq/common/envvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ const (
DDSBOMHostEnabled = "DD_SBOM_HOST_ENABLED"
DDSBOMHostAnalyzers = "DD_SBOM_HOST_ANALYZERS"
DDSecretBackendCommand = "DD_SECRET_BACKEND_COMMAND"
DDSecretBackendArguments = "DD_SECRET_BACKEND_ARGUMENTS"
DDSecretBackendTimeout = "DD_SECRET_BACKEND_TIMEOUT"
DDSite = "DD_SITE"
DDSystemProbeAgentEnabled = "DD_SYSTEM_PROBE_ENABLED"
DDSystemProbeBPFDebugEnabled = DDSystemProbeEnvPrefix + "BPF_DEBUG"
Expand Down
1 change: 1 addition & 0 deletions api/datadoghq/v2alpha1/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ const (
DefaultAgentImageName string = "agent"
DefaultClusterAgentImageName string = "cluster-agent"
DefaultImageRegistry string = "gcr.io/datadoghq"
DefaultAzureImageRegistry string = "datadoghq.azurecr.io"
DefaultEuropeImageRegistry string = "eu.gcr.io/datadoghq"
DefaultAsiaImageRegistry string = "asia.gcr.io/datadoghq"
DefaultGovImageRegistry string = "public.ecr.aws/datadog"
Expand Down
31 changes: 27 additions & 4 deletions api/datadoghq/v2alpha1/datadogagent_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const (
defaultSite string = "datadoghq.com"
defaultEuropeSite string = "datadoghq.eu"
defaultAsiaSite string = "ap1.datadoghq.com"
defaultAzureSite string = "us3.datadoghq.com"
defaultGovSite string = "ddog-gov.com"
defaultLogLevel string = "info"

Expand Down Expand Up @@ -60,10 +61,12 @@ const (
defaultDogstatsdSocketEnabled bool = true
defaultDogstatsdHostSocketPath string = apicommon.DogstatsdAPMSocketHostPath + "/" + apicommon.DogstatsdSocketName

defaultOTLPGRPCEnabled bool = false
defaultOTLPGRPCEndpoint string = "0.0.0.0:4317"
defaultOTLPHTTPEnabled bool = false
defaultOTLPHTTPEndpoint string = "0.0.0.0:4318"
defaultOTLPGRPCEnabled bool = false
defaultOTLPGRPCHostPortEnabled bool = true
defaultOTLPGRPCEndpoint string = "0.0.0.0:4317"
defaultOTLPHTTPEnabled bool = false
defaultOTLPHTTPHostPortEnabled bool = true
defaultOTLPHTTPEndpoint string = "0.0.0.0:4318"

defaultRemoteConfigurationEnabled bool = true

Expand Down Expand Up @@ -140,6 +143,8 @@ func defaultGlobalConfig(ddaSpec *DatadogAgentSpec) {
ddaSpec.Global.Registry = apiutils.NewStringPointer(DefaultEuropeImageRegistry)
case defaultAsiaSite:
ddaSpec.Global.Registry = apiutils.NewStringPointer(DefaultAsiaImageRegistry)
case defaultAzureSite:
ddaSpec.Global.Registry = apiutils.NewStringPointer(DefaultAzureImageRegistry)
case defaultGovSite:
ddaSpec.Global.Registry = apiutils.NewStringPointer(DefaultGovImageRegistry)
default:
Expand Down Expand Up @@ -378,13 +383,31 @@ func defaultFeaturesConfig(ddaSpec *DatadogAgentSpec) {
if ddaSpec.Features.OTLP.Receiver.Protocols.GRPC == nil {
ddaSpec.Features.OTLP.Receiver.Protocols.GRPC = &OTLPGRPCConfig{}
}

apiutils.DefaultBooleanIfUnset(&ddaSpec.Features.OTLP.Receiver.Protocols.GRPC.Enabled, defaultOTLPGRPCEnabled)

if apiutils.BoolValue(ddaSpec.Features.OTLP.Receiver.Protocols.GRPC.Enabled) {
if ddaSpec.Features.OTLP.Receiver.Protocols.GRPC.HostPortConfig == nil {
ddaSpec.Features.OTLP.Receiver.Protocols.GRPC.HostPortConfig = &HostPortConfig{}
}
apiutils.DefaultBooleanIfUnset(&ddaSpec.Features.OTLP.Receiver.Protocols.GRPC.HostPortConfig.Enabled, defaultOTLPGRPCHostPortEnabled)
}

apiutils.DefaultStringIfUnset(&ddaSpec.Features.OTLP.Receiver.Protocols.GRPC.Endpoint, defaultOTLPGRPCEndpoint)

if ddaSpec.Features.OTLP.Receiver.Protocols.HTTP == nil {
ddaSpec.Features.OTLP.Receiver.Protocols.HTTP = &OTLPHTTPConfig{}
}

apiutils.DefaultBooleanIfUnset(&ddaSpec.Features.OTLP.Receiver.Protocols.HTTP.Enabled, defaultOTLPHTTPEnabled)

if apiutils.BoolValue(ddaSpec.Features.OTLP.Receiver.Protocols.HTTP.Enabled) {
if ddaSpec.Features.OTLP.Receiver.Protocols.HTTP.HostPortConfig == nil {
ddaSpec.Features.OTLP.Receiver.Protocols.HTTP.HostPortConfig = &HostPortConfig{}
}
apiutils.DefaultBooleanIfUnset(&ddaSpec.Features.OTLP.Receiver.Protocols.HTTP.HostPortConfig.Enabled, defaultOTLPHTTPHostPortEnabled)
}

apiutils.DefaultStringIfUnset(&ddaSpec.Features.OTLP.Receiver.Protocols.HTTP.Endpoint, defaultOTLPHTTPEndpoint)

// RemoteConfiguration feature
Expand Down
145 changes: 93 additions & 52 deletions api/datadoghq/v2alpha1/datadogagent_default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,21 @@ func Test_defaultGlobal(t *testing.T) {
},
},
},
{
name: "test registry defaulting based on site - Azure",
ddaSpec: &DatadogAgentSpec{
Global: &GlobalConfig{
Site: apiutils.NewStringPointer(defaultAzureSite),
},
},
want: &DatadogAgentSpec{
Global: &GlobalConfig{
Site: apiutils.NewStringPointer(defaultAzureSite),
Registry: apiutils.NewStringPointer(DefaultAzureImageRegistry),
LogLevel: apiutils.NewStringPointer(defaultLogLevel),
},
},
},
{
name: "test registry defaulting based on site - Gov",
ddaSpec: &DatadogAgentSpec{
Expand Down Expand Up @@ -227,12 +242,14 @@ func Test_defaultFeatures(t *testing.T) {
},
OTLP: &OTLPFeatureConfig{Receiver: OTLPReceiverConfig{Protocols: OTLPProtocolsConfig{
GRPC: &OTLPGRPCConfig{
Enabled: apiutils.NewBoolPointer(defaultOTLPGRPCEnabled),
Endpoint: apiutils.NewStringPointer(defaultOTLPGRPCEndpoint),
Enabled: apiutils.NewBoolPointer(defaultOTLPGRPCEnabled),
HostPortConfig: nil,
Endpoint: apiutils.NewStringPointer(defaultOTLPGRPCEndpoint),
},
HTTP: &OTLPHTTPConfig{
Enabled: apiutils.NewBoolPointer(defaultOTLPHTTPEnabled),
Endpoint: apiutils.NewStringPointer(defaultOTLPHTTPEndpoint),
Enabled: apiutils.NewBoolPointer(defaultOTLPHTTPEnabled),
HostPortConfig: nil,
Endpoint: apiutils.NewStringPointer(defaultOTLPHTTPEndpoint),
},
}}},
RemoteConfiguration: &RemoteConfigurationFeatureConfig{
Expand Down Expand Up @@ -415,12 +432,14 @@ func Test_defaultFeatures(t *testing.T) {
},
OTLP: &OTLPFeatureConfig{Receiver: OTLPReceiverConfig{Protocols: OTLPProtocolsConfig{
GRPC: &OTLPGRPCConfig{
Enabled: apiutils.NewBoolPointer(defaultOTLPGRPCEnabled),
Endpoint: apiutils.NewStringPointer(defaultOTLPGRPCEndpoint),
Enabled: apiutils.NewBoolPointer(defaultOTLPGRPCEnabled),
HostPortConfig: nil,
Endpoint: apiutils.NewStringPointer(defaultOTLPGRPCEndpoint),
},
HTTP: &OTLPHTTPConfig{
Enabled: apiutils.NewBoolPointer(defaultOTLPHTTPEnabled),
Endpoint: apiutils.NewStringPointer(defaultOTLPHTTPEndpoint),
Enabled: apiutils.NewBoolPointer(defaultOTLPHTTPEnabled),
HostPortConfig: nil,
Endpoint: apiutils.NewStringPointer(defaultOTLPHTTPEndpoint),
},
}}},
EventCollection: &EventCollectionFeatureConfig{
Expand Down Expand Up @@ -536,12 +555,14 @@ func Test_defaultFeatures(t *testing.T) {
},
OTLP: &OTLPFeatureConfig{Receiver: OTLPReceiverConfig{Protocols: OTLPProtocolsConfig{
GRPC: &OTLPGRPCConfig{
Enabled: apiutils.NewBoolPointer(defaultOTLPGRPCEnabled),
Endpoint: apiutils.NewStringPointer(defaultOTLPGRPCEndpoint),
Enabled: apiutils.NewBoolPointer(defaultOTLPGRPCEnabled),
HostPortConfig: nil,
Endpoint: apiutils.NewStringPointer(defaultOTLPGRPCEndpoint),
},
HTTP: &OTLPHTTPConfig{
Enabled: apiutils.NewBoolPointer(defaultOTLPHTTPEnabled),
Endpoint: apiutils.NewStringPointer(defaultOTLPHTTPEndpoint),
Enabled: apiutils.NewBoolPointer(defaultOTLPHTTPEnabled),
HostPortConfig: nil,
Endpoint: apiutils.NewStringPointer(defaultOTLPHTTPEndpoint),
},
}}},
RemoteConfiguration: &RemoteConfigurationFeatureConfig{
Expand Down Expand Up @@ -666,12 +687,14 @@ func Test_defaultFeatures(t *testing.T) {
},
OTLP: &OTLPFeatureConfig{Receiver: OTLPReceiverConfig{Protocols: OTLPProtocolsConfig{
GRPC: &OTLPGRPCConfig{
Enabled: apiutils.NewBoolPointer(defaultOTLPGRPCEnabled),
Endpoint: apiutils.NewStringPointer(defaultOTLPGRPCEndpoint),
Enabled: apiutils.NewBoolPointer(defaultOTLPGRPCEnabled),
HostPortConfig: nil,
Endpoint: apiutils.NewStringPointer(defaultOTLPGRPCEndpoint),
},
HTTP: &OTLPHTTPConfig{
Enabled: apiutils.NewBoolPointer(defaultOTLPHTTPEnabled),
Endpoint: apiutils.NewStringPointer(defaultOTLPHTTPEndpoint),
Enabled: apiutils.NewBoolPointer(defaultOTLPHTTPEnabled),
HostPortConfig: nil,
Endpoint: apiutils.NewStringPointer(defaultOTLPHTTPEndpoint),
},
}}},
RemoteConfiguration: &RemoteConfigurationFeatureConfig{
Expand Down Expand Up @@ -791,12 +814,14 @@ func Test_defaultFeatures(t *testing.T) {
},
OTLP: &OTLPFeatureConfig{Receiver: OTLPReceiverConfig{Protocols: OTLPProtocolsConfig{
GRPC: &OTLPGRPCConfig{
Enabled: apiutils.NewBoolPointer(defaultOTLPGRPCEnabled),
Endpoint: apiutils.NewStringPointer(defaultOTLPGRPCEndpoint),
Enabled: apiutils.NewBoolPointer(defaultOTLPGRPCEnabled),
HostPortConfig: nil,
Endpoint: apiutils.NewStringPointer(defaultOTLPGRPCEndpoint),
},
HTTP: &OTLPHTTPConfig{
Enabled: apiutils.NewBoolPointer(defaultOTLPHTTPEnabled),
Endpoint: apiutils.NewStringPointer(defaultOTLPHTTPEndpoint),
Enabled: apiutils.NewBoolPointer(defaultOTLPHTTPEnabled),
HostPortConfig: nil,
Endpoint: apiutils.NewStringPointer(defaultOTLPHTTPEndpoint),
},
}}},
RemoteConfiguration: &RemoteConfigurationFeatureConfig{
Expand Down Expand Up @@ -918,12 +943,14 @@ func Test_defaultFeatures(t *testing.T) {
},
OTLP: &OTLPFeatureConfig{Receiver: OTLPReceiverConfig{Protocols: OTLPProtocolsConfig{
GRPC: &OTLPGRPCConfig{
Enabled: apiutils.NewBoolPointer(defaultOTLPGRPCEnabled),
Endpoint: apiutils.NewStringPointer(defaultOTLPGRPCEndpoint),
Enabled: apiutils.NewBoolPointer(defaultOTLPGRPCEnabled),
HostPortConfig: nil,
Endpoint: apiutils.NewStringPointer(defaultOTLPGRPCEndpoint),
},
HTTP: &OTLPHTTPConfig{
Enabled: apiutils.NewBoolPointer(defaultOTLPHTTPEnabled),
Endpoint: apiutils.NewStringPointer(defaultOTLPHTTPEndpoint),
Enabled: apiutils.NewBoolPointer(defaultOTLPHTTPEnabled),
HostPortConfig: nil,
Endpoint: apiutils.NewStringPointer(defaultOTLPHTTPEndpoint),
},
}}},
RemoteConfiguration: &RemoteConfigurationFeatureConfig{
Expand Down Expand Up @@ -1050,12 +1077,14 @@ func Test_defaultFeatures(t *testing.T) {
},
OTLP: &OTLPFeatureConfig{Receiver: OTLPReceiverConfig{Protocols: OTLPProtocolsConfig{
GRPC: &OTLPGRPCConfig{
Enabled: apiutils.NewBoolPointer(valueTrue),
Endpoint: apiutils.NewStringPointer(defaultOTLPGRPCEndpoint),
Enabled: apiutils.NewBoolPointer(valueTrue),
HostPortConfig: &HostPortConfig{Enabled: apiutils.NewBoolPointer(defaultOTLPGRPCHostPortEnabled)},
Endpoint: apiutils.NewStringPointer(defaultOTLPGRPCEndpoint),
},
HTTP: &OTLPHTTPConfig{
Enabled: apiutils.NewBoolPointer(valueTrue),
Endpoint: apiutils.NewStringPointer(defaultOTLPHTTPEndpoint),
Enabled: apiutils.NewBoolPointer(valueTrue),
HostPortConfig: &HostPortConfig{Enabled: apiutils.NewBoolPointer(defaultOTLPGRPCHostPortEnabled)},
Endpoint: apiutils.NewStringPointer(defaultOTLPHTTPEndpoint),
},
}}},
RemoteConfiguration: &RemoteConfigurationFeatureConfig{
Expand Down Expand Up @@ -1175,12 +1204,14 @@ func Test_defaultFeatures(t *testing.T) {
},
OTLP: &OTLPFeatureConfig{Receiver: OTLPReceiverConfig{Protocols: OTLPProtocolsConfig{
GRPC: &OTLPGRPCConfig{
Enabled: apiutils.NewBoolPointer(defaultOTLPGRPCEnabled),
Endpoint: apiutils.NewStringPointer(defaultOTLPGRPCEndpoint),
Enabled: apiutils.NewBoolPointer(defaultOTLPGRPCEnabled),
HostPortConfig: nil,
Endpoint: apiutils.NewStringPointer(defaultOTLPGRPCEndpoint),
},
HTTP: &OTLPHTTPConfig{
Enabled: apiutils.NewBoolPointer(defaultOTLPHTTPEnabled),
Endpoint: apiutils.NewStringPointer(defaultOTLPHTTPEndpoint),
Enabled: apiutils.NewBoolPointer(defaultOTLPHTTPEnabled),
HostPortConfig: nil,
Endpoint: apiutils.NewStringPointer(defaultOTLPHTTPEndpoint),
},
}}},
RemoteConfiguration: &RemoteConfigurationFeatureConfig{
Expand Down Expand Up @@ -1303,12 +1334,14 @@ func Test_defaultFeatures(t *testing.T) {
},
OTLP: &OTLPFeatureConfig{Receiver: OTLPReceiverConfig{Protocols: OTLPProtocolsConfig{
GRPC: &OTLPGRPCConfig{
Enabled: apiutils.NewBoolPointer(defaultOTLPGRPCEnabled),
Endpoint: apiutils.NewStringPointer(defaultOTLPGRPCEndpoint),
Enabled: apiutils.NewBoolPointer(defaultOTLPGRPCEnabled),
HostPortConfig: nil,
Endpoint: apiutils.NewStringPointer(defaultOTLPGRPCEndpoint),
},
HTTP: &OTLPHTTPConfig{
Enabled: apiutils.NewBoolPointer(defaultOTLPHTTPEnabled),
Endpoint: apiutils.NewStringPointer(defaultOTLPHTTPEndpoint),
Enabled: apiutils.NewBoolPointer(defaultOTLPHTTPEnabled),
HostPortConfig: nil,
Endpoint: apiutils.NewStringPointer(defaultOTLPHTTPEndpoint),
},
}}},
RemoteConfiguration: &RemoteConfigurationFeatureConfig{
Expand Down Expand Up @@ -1432,12 +1465,14 @@ func Test_defaultFeatures(t *testing.T) {
},
OTLP: &OTLPFeatureConfig{Receiver: OTLPReceiverConfig{Protocols: OTLPProtocolsConfig{
GRPC: &OTLPGRPCConfig{
Enabled: apiutils.NewBoolPointer(defaultOTLPGRPCEnabled),
Endpoint: apiutils.NewStringPointer(defaultOTLPGRPCEndpoint),
Enabled: apiutils.NewBoolPointer(defaultOTLPGRPCEnabled),
HostPortConfig: nil,
Endpoint: apiutils.NewStringPointer(defaultOTLPGRPCEndpoint),
},
HTTP: &OTLPHTTPConfig{
Enabled: apiutils.NewBoolPointer(defaultOTLPHTTPEnabled),
Endpoint: apiutils.NewStringPointer(defaultOTLPHTTPEndpoint),
Enabled: apiutils.NewBoolPointer(defaultOTLPHTTPEnabled),
HostPortConfig: nil,
Endpoint: apiutils.NewStringPointer(defaultOTLPHTTPEndpoint),
},
}}},
RemoteConfiguration: &RemoteConfigurationFeatureConfig{
Expand Down Expand Up @@ -1559,12 +1594,14 @@ func Test_defaultFeatures(t *testing.T) {
},
OTLP: &OTLPFeatureConfig{Receiver: OTLPReceiverConfig{Protocols: OTLPProtocolsConfig{
GRPC: &OTLPGRPCConfig{
Enabled: apiutils.NewBoolPointer(defaultOTLPGRPCEnabled),
Endpoint: apiutils.NewStringPointer(defaultOTLPGRPCEndpoint),
Enabled: apiutils.NewBoolPointer(defaultOTLPGRPCEnabled),
HostPortConfig: nil,
Endpoint: apiutils.NewStringPointer(defaultOTLPGRPCEndpoint),
},
HTTP: &OTLPHTTPConfig{
Enabled: apiutils.NewBoolPointer(defaultOTLPHTTPEnabled),
Endpoint: apiutils.NewStringPointer(defaultOTLPHTTPEndpoint),
Enabled: apiutils.NewBoolPointer(defaultOTLPHTTPEnabled),
HostPortConfig: nil,
Endpoint: apiutils.NewStringPointer(defaultOTLPHTTPEndpoint),
},
}}},
RemoteConfiguration: &RemoteConfigurationFeatureConfig{
Expand Down Expand Up @@ -1706,12 +1743,14 @@ func Test_defaultFeatures(t *testing.T) {
},
OTLP: &OTLPFeatureConfig{Receiver: OTLPReceiverConfig{Protocols: OTLPProtocolsConfig{
GRPC: &OTLPGRPCConfig{
Enabled: apiutils.NewBoolPointer(defaultOTLPGRPCEnabled),
Endpoint: apiutils.NewStringPointer(defaultOTLPGRPCEndpoint),
Enabled: apiutils.NewBoolPointer(defaultOTLPGRPCEnabled),
HostPortConfig: nil,
Endpoint: apiutils.NewStringPointer(defaultOTLPGRPCEndpoint),
},
HTTP: &OTLPHTTPConfig{
Enabled: apiutils.NewBoolPointer(defaultOTLPHTTPEnabled),
Endpoint: apiutils.NewStringPointer(defaultOTLPHTTPEndpoint),
Enabled: apiutils.NewBoolPointer(defaultOTLPHTTPEnabled),
HostPortConfig: nil,
Endpoint: apiutils.NewStringPointer(defaultOTLPHTTPEndpoint),
},
}}},
RemoteConfiguration: &RemoteConfigurationFeatureConfig{
Expand Down Expand Up @@ -1844,12 +1883,14 @@ func Test_defaultFeatures(t *testing.T) {
},
OTLP: &OTLPFeatureConfig{Receiver: OTLPReceiverConfig{Protocols: OTLPProtocolsConfig{
GRPC: &OTLPGRPCConfig{
Enabled: apiutils.NewBoolPointer(defaultOTLPGRPCEnabled),
Endpoint: apiutils.NewStringPointer(defaultOTLPGRPCEndpoint),
Enabled: apiutils.NewBoolPointer(defaultOTLPGRPCEnabled),
HostPortConfig: nil,
Endpoint: apiutils.NewStringPointer(defaultOTLPGRPCEndpoint),
},
HTTP: &OTLPHTTPConfig{
Enabled: apiutils.NewBoolPointer(defaultOTLPHTTPEnabled),
Endpoint: apiutils.NewStringPointer(defaultOTLPHTTPEndpoint),
Enabled: apiutils.NewBoolPointer(defaultOTLPHTTPEnabled),
HostPortConfig: nil,
Endpoint: apiutils.NewStringPointer(defaultOTLPHTTPEndpoint),
},
}}},
RemoteConfiguration: &RemoteConfigurationFeatureConfig{
Expand Down
Loading

0 comments on commit 4a3f1d5

Please sign in to comment.