Skip to content

Commit 757cfd2

Browse files
committed
[ACTP] package and activate par-control
1 parent 8824a00 commit 757cfd2

43 files changed

Lines changed: 1091 additions & 96 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@
192192
/.gitlab/.pre/deps_build/ @DataDog/ebpf-platform @DataDog/agent-build @DataDog/windows-products
193193

194194
/.gitlab/windows/test/e2e_install_packages/windows.yml @DataDog/windows-products
195+
/.gitlab/windows/test/e2e/windows.yml @DataDog/windows-products @DataDog/agent-devx
195196

196197
/.gitlab/.pre/common/ @DataDog/agent-devx
197198

.gitlab/JOBOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ new-e2e-package-signing-* @DataDog/agent-delivery
250250
# --- GPU ---
251251
new-e2e-gpu* @DataDog/ebpf-platform @DataDog/gpu-monitoring-agent
252252
# --- Action platform / discovery ---
253-
new-e2e-privateactionrunner @DataDog/action-platform
253+
new-e2e-privateactionrunner* @DataDog/action-platform
254254
new-e2e-discovery @DataDog/agent-discovery
255255
# --- Windows-only jobs (single owner: windows-products) ---
256256
new-e2e-windows-* @DataDog/windows-products

.gitlab/test/e2e/e2e.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,7 @@ new-e2e-privateactionrunner:
489489
variables:
490490
TARGETS: ./tests/privateactionrunner
491491
TEAM: action-platform
492+
EXTRA_PARAMS: --skip "Windows"
492493

493494
new-e2e-fips-compliance-test:
494495
extends: .new_e2e_template

.gitlab/windows/test/e2e/windows.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,18 @@ new-e2e-agent-subcommands-windows:
6060
ON_NIGHTLY_FIPS: "true"
6161
EXTRA_PARAMS: --run "Windows"
6262

63+
new-e2e-privateactionrunner-windows:
64+
extends: .new_e2e_template_needs_windows_x64
65+
rules:
66+
- !reference [.except_disable_e2e_tests]
67+
- !reference [.except_mergequeue]
68+
- !reference [.on_privateactionrunner_or_e2e_changes]
69+
- !reference [.manual]
70+
variables:
71+
TARGETS: ./tests/privateactionrunner
72+
TEAM: action-platform
73+
EXTRA_PARAMS: --run "Windows"
74+
6375
new-e2e-windows-fips-compliance-test:
6476
extends: .new_e2e_template
6577
needs:

omnibus/config/projects/agent.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,11 @@
340340
windows_symbol_stripping_file "#{install_dir}\\bin\\agent\\dd-procmgr.exe"
341341
windows_symbol_stripping_file "#{install_dir}\\bin\\agent\\agent-data-plane.exe"
342342

343+
if not fips_mode?
344+
# TODO(ACTP-XXX): PAR is not enabled in Gov yet
345+
windows_symbol_stripping_file "#{install_dir}\\bin\\agent\\par-control.exe"
346+
end
347+
343348
if windows_signing_enabled?
344349
# Sign additional binaries from here.
345350
# We can't request signing from the respective components/software definitions
@@ -366,7 +371,7 @@
366371
"#{install_dir}\\bin\\agent\\dd-procmgrd.exe",
367372
"#{install_dir}\\bin\\agent\\dd-procmgr.exe",
368373
"#{install_dir}\\bin\\agent\\agent-data-plane.exe",
369-
]
374+
] + (fips_mode? ? [] : ["#{install_dir}\\bin\\agent\\par-control.exe"])
370375

371376
BINARIES_TO_SIGN.each do |bin|
372377
sign_file bin

omnibus/config/software/datadog-agent.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,10 @@
192192
elsif not heroku_target?
193193
copy 'bin/privateactionrunner/privateactionrunner', "#{install_dir}/embedded/bin"
194194
end
195+
196+
if linux_target? || windows_target?
197+
command "bazel run #{omnibazel_flags} //pkg/privateactionrunner/par-control:install -- --destdir=#{install_dir}", :env => env, :live_stream => Omnibus.logger.live_stream(:info)
198+
end
195199
end
196200

197201
# System-probe

packages/agent/product/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ pkg_filegroup(
5454
] + select({
5555
"//packages/agent:linux_default": [
5656
"//pkg/discovery/module/rust:all_files",
57+
"//pkg/privateactionrunner/par-control:all_files_linux",
5758
"//pkg/procmgr/rust:all_files_linux",
5859
],
5960
"//packages/agent:linux_fips": [
@@ -73,6 +74,7 @@ pkg_filegroup(
7374
],
7475
"@platforms//os:windows": [
7576
"//packages/windows:all_files",
77+
"//pkg/privateactionrunner/par-control:all_files_windows",
7678
"//pkg/procmgr/rust:all_files_windows",
7779
],
7880
"//conditions:default": [],

pkg/fleet/installer/packages/datadog_agent_linux.go

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ var (
104104
// agentPackageUninstallPaths are the agent paths that are deleted during an uninstall
105105
agentPackageUninstallPaths = file.Paths{
106106
"embedded/ssl/fipsmodule.cnf",
107+
"processes.d/datadog-agent-par-control.yaml",
107108
"processes.d/datadog-agent-action-executor.yaml",
108109
"run",
109110
".pre_python_installed_packages.txt",
@@ -272,16 +273,29 @@ func retireLegacyProcmgrUnits(ctx HookContext) error {
272273
return nil
273274
}
274275

275-
const parExecutorProcmgrConfigName = "datadog-agent-action-executor.yaml"
276+
const (
277+
parControlProcmgrConfigName = "datadog-agent-par-control.yaml"
278+
parExecutorProcmgrConfigName = "datadog-agent-action-executor.yaml"
279+
)
280+
281+
func writePARProcmgrConfigs(installRoot string) error {
282+
return errors.Join(
283+
writePARProcmgrConfig(installRoot, parControlProcmgrConfigName, embedded.PARControlProcessConfig),
284+
writePARProcmgrConfig(installRoot, parExecutorProcmgrConfigName, embedded.PARExecutorProcessConfig),
285+
)
286+
}
276287

277-
func writePARExecutorProcmgrConfig(installRoot string) error {
288+
func writePARProcmgrConfig(installRoot, name, config string) error {
278289
processesDir := filepath.Join(installRoot, "processes.d")
279-
config := strings.ReplaceAll(embedded.PARExecutorProcessConfig, "/opt/datadog-agent", installRoot)
290+
config = strings.ReplaceAll(config, "/opt/datadog-agent", installRoot)
280291
if err := os.MkdirAll(processesDir, 0755); err != nil {
281-
return fmt.Errorf("failed to write PAR executor procmgr config: %w", err)
292+
return fmt.Errorf("failed to create processes.d for %s: %w", name, err)
293+
}
294+
path := filepath.Join(processesDir, name)
295+
if err := os.WriteFile(path, []byte(config), 0644); err != nil {
296+
return fmt.Errorf("failed to write %s: %w", path, err)
282297
}
283-
path := filepath.Join(processesDir, parExecutorProcmgrConfigName)
284-
return os.WriteFile(path, []byte(config), 0644)
298+
return nil
285299
}
286300

287301
// uninstallFilesystem cleans the filesystem by removing various temporary files, symlinks and installation metadata
@@ -368,8 +382,8 @@ func postInstallDatadogAgent(ctx HookContext) (err error) {
368382
if err := writeDDOTProcmgrConfig(ctx.PackagePath); err != nil {
369383
log.Warnf("failed to write DDOT process manager config: %v", err)
370384
}
371-
if err := writePARExecutorProcmgrConfig(ctx.PackagePath); err != nil {
372-
log.Warnf("failed to write PAR executor process manager config: %v", err)
385+
if err := writePARProcmgrConfigs(ctx.PackagePath); err != nil {
386+
log.Warnf("failed to write PAR process manager configs: %v", err)
373387
}
374388
if err := agentService.WriteStable(ctx); err != nil {
375389
return fmt.Errorf("failed to write stable units: %s", err)
@@ -484,8 +498,8 @@ func postStartExperimentDatadogAgent(ctx HookContext) error {
484498
if err := restoreODBCConfig(ctx.PackagePath); err != nil {
485499
log.Warnf("failed to restore ODBC config: %s", err)
486500
}
487-
if err := writePARExecutorProcmgrConfig(ctx.PackagePath); err != nil {
488-
log.Warnf("failed to write PAR executor process manager config: %v", err)
501+
if err := writePARProcmgrConfigs(ctx.PackagePath); err != nil {
502+
log.Warnf("failed to write PAR process manager configs: %v", err)
489503
}
490504
if err := agentService.WriteExperiment(ctx); err != nil {
491505
return err
@@ -534,8 +548,8 @@ func postPromoteExperimentDatadogAgent(ctx HookContext) error {
534548
if err := installFilesystem(ctx); err != nil {
535549
return err
536550
}
537-
if err := writePARExecutorProcmgrConfig(ctx.PackagePath); err != nil {
538-
log.Warnf("failed to write PAR executor process manager config: %v", err)
551+
if err := writePARProcmgrConfigs(ctx.PackagePath); err != nil {
552+
log.Warnf("failed to write PAR process manager configs: %v", err)
539553
}
540554
detachedCtx := context.WithoutCancel(ctx.Context)
541555
ctx.Context = detachedCtx

pkg/fleet/installer/packages/datadog_agent_par_linux_test.go

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,43 @@ import (
1616
"github.com/stretchr/testify/require"
1717
)
1818

19-
func TestWritePARExecutorProcmgrConfig(t *testing.T) {
19+
// Fleet policies follow the supervising unit's config dir, so an experiment
20+
// reads the experiment tree rather than stable.
21+
const fleetPoliciesDirSetting = "DD_FLEET_POLICIES_DIR: ${DD_CONF_DIR}/managed/datadog-agent/stable"
22+
23+
func TestWritePARProcmgrConfigs(t *testing.T) {
2024
installRoot := t.TempDir()
21-
configPath := filepath.Join(installRoot, "processes.d", parExecutorProcmgrConfigName)
25+
require.NoError(t, writePARProcmgrConfigs(installRoot))
2226

23-
require.NoError(t, writePARExecutorProcmgrConfig(installRoot))
24-
content, err := os.ReadFile(configPath)
25-
require.NoError(t, err)
27+
executor := readProcmgrConfig(t, installRoot, parExecutorProcmgrConfigName)
28+
assert.Contains(t, executor, "${DD_CONF_DIR}/datadog.yaml")
29+
assert.Contains(t, executor, filepath.Join(installRoot, "embedded", "bin", "privateactionrunner"))
30+
// Only par-control starts the executor, and procmgr must not resurrect it.
31+
assert.Contains(t, executor, "auto_start: false")
32+
assert.Contains(t, executor, "restart: never")
33+
assert.Contains(t, executor, fleetPoliciesDirSetting)
34+
assert.NotContains(t, executor, "/opt/datadog-agent/")
2635

27-
assert.Contains(t, string(content), "${DD_CONF_DIR}/datadog.yaml")
28-
assert.Contains(t, string(content), filepath.Join(installRoot, "embedded", "bin", "privateactionrunner"))
29-
assert.Contains(t, string(content), "auto_start: false")
30-
assert.Contains(t, string(content), "restart: never")
31-
assert.NotContains(t, string(content), "/opt/datadog-agent/")
36+
control := readProcmgrConfig(t, installRoot, parControlProcmgrConfigName)
37+
assert.Contains(t, control, "${DD_CONF_DIR}/datadog.yaml")
38+
assert.Contains(t, control, filepath.Join(installRoot, "embedded", "bin", "par-control"))
39+
// Rust resolves operational configuration directly; Go remains responsible
40+
// only for the hostname-aware enrollment bootstrap.
41+
assert.NotContains(t, control, "--config-helper")
42+
assert.Contains(t, control, "--ensure-enrollment-command")
43+
assert.Contains(t, control, filepath.Join(installRoot, "embedded", "bin", "privateactionrunner"))
44+
assert.Contains(t, control, fleetPoliciesDirSetting)
45+
// The control plane is always on: procmgr starts it with the Agent and restarts
46+
// it on crash. on-failure ignores the clean exit taken when split mode is off.
47+
assert.Contains(t, control, "auto_start: true")
48+
assert.Contains(t, control, "stop_timeout: 180")
49+
assert.Contains(t, control, "restart: on-failure")
50+
assert.NotContains(t, control, "/opt/datadog-agent/")
51+
}
52+
53+
func readProcmgrConfig(t *testing.T, installRoot, name string) string {
54+
t.Helper()
55+
content, err := os.ReadFile(filepath.Join(installRoot, "processes.d", name))
56+
require.NoError(t, err)
57+
return string(content)
3258
}

pkg/fleet/installer/packages/datadog_agent_windows.go

Lines changed: 18 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,10 @@ func postInstallDatadogAgent(ctx HookContext) error {
143143
}
144144
}
145145

146-
if err := ensureADPProcmgrConfig(); err != nil {
147-
return fmt.Errorf("failed to write ADP process manager config: %w", err)
148-
}
149-
if err := ensurePARProcmgrConfig(); err != nil {
150-
return fmt.Errorf("failed to write PAR process manager config: %w", err)
151-
}
152-
if err := ensurePARExecutorProcmgrConfig(); err != nil {
153-
return fmt.Errorf("failed to write PAR executor process manager config: %w", err)
146+
for _, cfg := range procmgrConfigs {
147+
if err := ensureProcmgrConfig(cfg); err != nil {
148+
return fmt.Errorf("failed to write %s process manager config: %w", cfg.label, err)
149+
}
154150
}
155151

156152
// No need to explicitly start the Agent here
@@ -203,47 +199,31 @@ func resolveDatadogProgramFilesInstallRoot() (string, error) {
203199
return installRoot, nil
204200
}
205201

206-
func ensureADPProcmgrConfig() error {
207-
installRoot, err := resolveDatadogProgramFilesInstallRoot()
208-
if err != nil {
209-
return err
210-
}
211-
212-
if env.FromEnv().ProcessManagerEnabled {
213-
return processmanager.WriteADPProcmgrConfig(installRoot)
214-
}
215-
if err := processmanager.RemoveADPProcmgrConfig(installRoot); err != nil {
216-
log.Warnf("ADP: could not remove stale process manager config: %v", err)
217-
}
218-
return nil
202+
// procmgrConfig is a processes.d definition managed at install time.
203+
type procmgrConfig struct {
204+
label string
205+
write func(installRoot string) error
206+
remove func(installRoot string) error
219207
}
220208

221-
func ensurePARProcmgrConfig() error {
222-
installRoot, err := resolveDatadogProgramFilesInstallRoot()
223-
if err != nil {
224-
return err
225-
}
226-
227-
if env.FromEnv().ProcessManagerEnabled {
228-
return processmanager.WritePARProcmgrConfig(installRoot)
229-
}
230-
if err := processmanager.RemovePARProcmgrConfig(installRoot); err != nil {
231-
log.Warnf("PAR: could not remove stale process manager config: %v", err)
232-
}
233-
return nil
209+
var procmgrConfigs = []procmgrConfig{
210+
{"ADP", processmanager.WriteADPProcmgrConfig, processmanager.RemoveADPProcmgrConfig},
211+
{"PAR", processmanager.WritePARProcmgrConfig, processmanager.RemovePARProcmgrConfig},
212+
{"PAR executor", processmanager.WritePARExecutorProcmgrConfig, processmanager.RemovePARExecutorProcmgrConfig},
213+
{"PAR control plane", processmanager.WritePARControlProcmgrConfig, processmanager.RemovePARControlProcmgrConfig},
234214
}
235215

236-
func ensurePARExecutorProcmgrConfig() error {
216+
func ensureProcmgrConfig(cfg procmgrConfig) error {
237217
installRoot, err := resolveDatadogProgramFilesInstallRoot()
238218
if err != nil {
239219
return err
240220
}
241221

242222
if env.FromEnv().ProcessManagerEnabled {
243-
return processmanager.WritePARExecutorProcmgrConfig(installRoot)
223+
return cfg.write(installRoot)
244224
}
245-
if err := processmanager.RemovePARExecutorProcmgrConfig(installRoot); err != nil {
246-
log.Warnf("PAR executor: could not remove stale process manager config: %v", err)
225+
if err := cfg.remove(installRoot); err != nil {
226+
log.Warnf("%s: could not remove stale process manager config: %v", cfg.label, err)
247227
}
248228
return nil
249229
}

0 commit comments

Comments
 (0)