Skip to content
Merged
3 changes: 2 additions & 1 deletion comp/otelcol/converter/impl/autoconfigure.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ func (c *ddConverter) enhanceConfig(conf *confmap.Conf) {
"key": c.coreConfig.GetString("api_key"),
"site": site,
},
"deployment_type": deploymentType,
"deployment_type": deploymentType,
"installation_method": c.coreConfig.GetString("otelcollector.installation_method"),
Comment thread
liustanley marked this conversation as resolved.
}
}
addComponentToConfig(conf, extension)
Expand Down
6 changes: 6 additions & 0 deletions comp/otelcol/converter/impl/converter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ func TestConvert(t *testing.T) {
expectedResult: "extensions/no-extensions/datadog-gateway/config-result.yaml",
agentConfig: "extensions/no-extensions/datadog-gateway/acfg.yaml",
},
{
name: "extensions/no-extensions/datadog-installation-method",
provided: "extensions/no-extensions/datadog-installation-method/config.yaml",
expectedResult: "extensions/no-extensions/datadog-installation-method/config-result.yaml",
agentConfig: "extensions/no-extensions/datadog-installation-method/acfg.yaml",
},
{
name: "extensions/other-extensions/datadog",
provided: "extensions/other-extensions/datadog/config.yaml",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ extensions:
key: "ggggg77777"
site: "datadoghq.com"
deployment_type: daemonset
installation_method: ""
ddflare/dd-autoconfigured:

service:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ extensions:
key: ggggg77777
site: "datadoghq.com"
deployment_type: daemonset
installation_method: ""

service:
extensions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ extensions:
key: ggggg77777
site: "datadoghq.com"
deployment_type: gateway
installation_method: ""

service:
extensions:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
api_key: ggggg77777
otelcollector:
converter:
features: [pprof, zpages, health_check, datadog]
features: [pprof, zpages, health_check, datadog]
installation_method: bare-metal
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ extensions:
key: ggggg77777
site: "datadoghq.com"
deployment_type: daemonset
installation_method: "bare-metal"

service:
extensions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ extensions:
key: ggggg77777
site: "us5.datadoghq.com"
deployment_type: daemonset
installation_method: ""

service:
extensions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ extensions:
key: ggggg77777
site: "datadoghq.com"
deployment_type: daemonset
installation_method: ""

service:
extensions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ extensions:
key: "ggggg77777"
site: "datadoghq.eu"
deployment_type: daemonset
installation_method: ""
ddflare/dd-autoconfigured:
health_check/dd-autoconfigured:
pprof/dd-autoconfigured:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ extensions:
key: "ggggg77777"
site: "datadoghq.eu"
deployment_type: daemonset
installation_method: ""
ddflare/dd-autoconfigured:
health_check/dd-autoconfigured:
pprof/dd-autoconfigured:
Expand Down
1 change: 1 addition & 0 deletions pkg/config/setup/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1145,6 +1145,7 @@ func InitConfig(config pkgconfigmodel.Setup) {
})
})
config.BindEnvAndSetDefault("otelcollector.gateway.mode", false)
config.BindEnvAndSetDefault("otelcollector.installation_method", "")

// inventories
config.BindEnvAndSetDefault("inventories_enabled", true)
Expand Down
27 changes: 27 additions & 0 deletions pkg/fleet/installer/packages/datadog_agent_ddot_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/DataDog/datadog-agent/pkg/util/winutil"

"golang.org/x/sys/windows"
"golang.org/x/sys/windows/registry"
"golang.org/x/sys/windows/svc"
"golang.org/x/sys/windows/svc/mgr"
)
Expand Down Expand Up @@ -204,6 +205,9 @@ func ensureDDOTService() error {
}
// Best-effort: align service DACL to allow the core Agent user to control OTEL service
configureDDOTServicePermissions(s)
if err := setDDOTServiceEnvVars(); err != nil {
return err
}
return nil
}

Expand All @@ -223,6 +227,9 @@ func ensureDDOTService() error {
}
// Best-effort: align service DACL to allow the core Agent user to control OTEL service
configureDDOTServicePermissions(s)
if err := setDDOTServiceEnvVars(); err != nil {
return err
}
return nil
}

Expand Down Expand Up @@ -337,6 +344,20 @@ func configureDDOTServicePermissions(s *mgr.Service) {
}
}

// setDDOTServiceEnvVars writes the DDOT service environment variables to the registry.
func setDDOTServiceEnvVars() error {
key, _, err := registry.CreateKey(
registry.LOCAL_MACHINE,
`SYSTEM\CurrentControlSet\Services\`+otelServiceName+`\Environment`,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Write the Windows service Environment value on the service key

Our Windows service helper writes a service's environment as an Environment multi-string value directly on HKLM\SYSTEM\CurrentControlSet\Services\<name> (test/new-e2e/tests/windows/common/service.go:257-267), but this code creates a ...\Services\datadog-otel-agent\Environment subkey and writes that subkey's default value instead. In Windows installs that rely on this hook, the DDOT service will still start without DD_OTELCOLLECTOR_INSTALLATION_METHOD, so the new installation_method remains empty even though installation succeeds.

Useful? React with 👍 / 👎.

registry.SET_VALUE,
)
if err != nil {
return fmt.Errorf("failed to open service environment registry key: %w", err)
}
defer key.Close()
return key.SetStringsValue("", []string{"DD_OTELCOLLECTOR_INSTALLATION_METHOD=bare-metal"})
}

// stopServiceIfExists stops the service if it exists
func stopServiceIfExists(name string) error {
// Use robust stop; ignore 'service does not exist'
Expand Down Expand Up @@ -481,6 +502,9 @@ func ensureDDOTServiceForExtension(binaryPath string) error {
return err
}
configureDDOTServicePermissions(s)
if err := setDDOTServiceEnvVars(); err != nil {
return err
}
return nil
}

Expand All @@ -498,5 +522,8 @@ func ensureDDOTServiceForExtension(binaryPath string) error {
return err
}
configureDDOTServicePermissions(s)
if err := setDDOTServiceEnvVars(); err != nil {
return err
}
return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Restart=on-failure
RestartSec=2
EnvironmentFile=-{{.EtcDir}}/environment
Environment="DD_FLEET_POLICIES_DIR={{.FleetPoliciesDir}}"
Environment="DD_OTELCOLLECTOR_INSTALLATION_METHOD=bare-metal"
Comment thread
liustanley marked this conversation as resolved.
{{- if not .Stable}}
Environment="DD_INVENTORIES_FIRST_RUN_DELAY=5"
{{- end}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Restart=on-failure
RestartSec=2
EnvironmentFile=-/etc/datadog-agent-exp/environment
Environment="DD_FLEET_POLICIES_DIR=/etc/datadog-agent-exp/managed/datadog-agent/stable"
Environment="DD_OTELCOLLECTOR_INSTALLATION_METHOD=bare-metal"
Environment="DD_INVENTORIES_FIRST_RUN_DELAY=5"
ExecStart=/opt/datadog-agent/ext/ddot/embedded/bin/otel-agent run --config /etc/datadog-agent-exp/otel-config.yaml --core-config /etc/datadog-agent-exp/datadog.yaml --pidfile /opt/datadog-agent/run/otel-agent.pid
StartLimitInterval=10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Restart=on-failure
RestartSec=2
EnvironmentFile=-/etc/datadog-agent/environment
Environment="DD_FLEET_POLICIES_DIR=/etc/datadog-agent/managed/datadog-agent/stable"
Environment="DD_OTELCOLLECTOR_INSTALLATION_METHOD=bare-metal"
ExecStart=/opt/datadog-agent/ext/ddot/embedded/bin/otel-agent run --config /etc/datadog-agent/otel-config.yaml --core-config /etc/datadog-agent/datadog.yaml --pidfile /opt/datadog-agent/run/otel-agent.pid
StartLimitInterval=10
StartLimitBurst=5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Restart=on-failure
RestartSec=2
EnvironmentFile=-/etc/datadog-agent-exp/environment
Environment="DD_FLEET_POLICIES_DIR=/etc/datadog-agent-exp/managed/datadog-agent/stable"
Environment="DD_OTELCOLLECTOR_INSTALLATION_METHOD=bare-metal"
Environment="DD_INVENTORIES_FIRST_RUN_DELAY=5"
ExecStart=/opt/datadog-agent/ext/ddot/embedded/bin/otel-agent run --config /etc/datadog-agent-exp/otel-config.yaml --core-config /etc/datadog-agent-exp/datadog.yaml --pidfile /opt/datadog-agent/run/otel-agent.pid
StartLimitInterval=10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Restart=on-failure
RestartSec=2
EnvironmentFile=-/etc/datadog-agent/environment
Environment="DD_FLEET_POLICIES_DIR=/etc/datadog-agent/managed/datadog-agent/stable"
Environment="DD_OTELCOLLECTOR_INSTALLATION_METHOD=bare-metal"
ExecStart=/opt/datadog-agent/ext/ddot/embedded/bin/otel-agent run --config /etc/datadog-agent/otel-config.yaml --core-config /etc/datadog-agent/datadog.yaml --pidfile /opt/datadog-agent/run/otel-agent.pid
StartLimitInterval=10
StartLimitBurst=5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Restart=on-failure
RestartSec=2
EnvironmentFile=-/etc/datadog-agent-exp/environment
Environment="DD_FLEET_POLICIES_DIR=/etc/datadog-agent-exp/managed/datadog-agent/stable"
Environment="DD_OTELCOLLECTOR_INSTALLATION_METHOD=bare-metal"
Environment="DD_INVENTORIES_FIRST_RUN_DELAY=5"
ExecStart=/opt/datadog-packages/datadog-agent/experiment/ext/ddot/embedded/bin/otel-agent run --config /etc/datadog-agent-exp/otel-config.yaml --core-config /etc/datadog-agent-exp/datadog.yaml --pidfile /opt/datadog-packages/datadog-agent/experiment/run/otel-agent.pid
StartLimitInterval=10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Restart=on-failure
RestartSec=2
EnvironmentFile=-/etc/datadog-agent/environment
Environment="DD_FLEET_POLICIES_DIR=/etc/datadog-agent/managed/datadog-agent/stable"
Environment="DD_OTELCOLLECTOR_INSTALLATION_METHOD=bare-metal"
ExecStart=/opt/datadog-packages/datadog-agent/stable/ext/ddot/embedded/bin/otel-agent run --config /etc/datadog-agent/otel-config.yaml --core-config /etc/datadog-agent/datadog.yaml --pidfile /opt/datadog-packages/datadog-agent/stable/run/otel-agent.pid
StartLimitInterval=10
StartLimitBurst=5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Restart=on-failure
RestartSec=2
EnvironmentFile=-/etc/datadog-agent-exp/environment
Environment="DD_FLEET_POLICIES_DIR=/etc/datadog-agent-exp/managed/datadog-agent/stable"
Environment="DD_OTELCOLLECTOR_INSTALLATION_METHOD=bare-metal"
Environment="DD_INVENTORIES_FIRST_RUN_DELAY=5"
ExecStart=/opt/datadog-packages/datadog-agent/experiment/ext/ddot/embedded/bin/otel-agent run --config /etc/datadog-agent-exp/otel-config.yaml --core-config /etc/datadog-agent-exp/datadog.yaml --pidfile /opt/datadog-packages/datadog-agent/experiment/run/otel-agent.pid
StartLimitInterval=10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Restart=on-failure
RestartSec=2
EnvironmentFile=-/etc/datadog-agent/environment
Environment="DD_FLEET_POLICIES_DIR=/etc/datadog-agent/managed/datadog-agent/stable"
Environment="DD_OTELCOLLECTOR_INSTALLATION_METHOD=bare-metal"
ExecStart=/opt/datadog-packages/datadog-agent/stable/ext/ddot/embedded/bin/otel-agent run --config /etc/datadog-agent/otel-config.yaml --core-config /etc/datadog-agent/datadog.yaml --pidfile /opt/datadog-packages/datadog-agent/stable/run/otel-agent.pid
StartLimitInterval=10
StartLimitBurst=5
Expand Down
Loading