Skip to content

Commit ed1e5cc

Browse files
committed
Merge branch 'main' into aiuto/curl
2 parents e74dd2e + 197c8df commit ed1e5cc

File tree

11 files changed

+306
-73
lines changed

11 files changed

+306
-73
lines changed

comp/privateactionrunner/impl/privateactionrunner.go

Lines changed: 43 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ type Provides struct {
4848
Comp privateactionrunner.Component
4949
}
5050

51-
type privateactionrunnerImpl struct {
51+
type PrivateActionRunner struct {
5252
workflowRunner *runners.WorkflowRunner
5353
commonRunner *runners.CommonRunner
5454
drain func()
@@ -61,60 +61,73 @@ func NewComponent(reqs Requires) (Provides, error) {
6161
reqs.Log.Info("private-action-runner is not enabled. Set privateactionrunner.enabled: true in your datadog.yaml file or set the environment variable DD_PRIVATEACTIONRUNNER_ENABLED=true.")
6262
return Provides{}, privateactionrunner.ErrNotEnabled
6363
}
64-
persistedIdentity, err := enrollment.GetIdentityFromPreviousEnrollment(reqs.Config)
64+
65+
runner, err := NewPrivateActionRunner(ctx, reqs.Config, reqs.Hostname, reqs.RcClient, reqs.Log)
66+
if err != nil {
67+
return Provides{}, err
68+
}
69+
reqs.Lifecycle.Append(compdef.Hook{
70+
OnStart: runner.Start,
71+
OnStop: runner.Stop,
72+
})
73+
return Provides{Comp: runner}, nil
74+
}
75+
76+
func NewPrivateActionRunner(
77+
ctx context.Context,
78+
coreConfig model.ReaderWriter,
79+
hostnameGetter hostnameinterface.Component,
80+
rcClient rcclient.Component,
81+
logger log.Component,
82+
) (*PrivateActionRunner, error) {
83+
persistedIdentity, err := enrollment.GetIdentityFromPreviousEnrollment(coreConfig)
6584
if err != nil {
66-
return Provides{}, fmt.Errorf("self-enrollment failed: %w", err)
85+
return nil, fmt.Errorf("self-enrollment failed: %w", err)
6786
}
6887
if persistedIdentity != nil {
69-
reqs.Config.Set("privateactionrunner.private_key", persistedIdentity.PrivateKey, model.SourceAgentRuntime)
70-
reqs.Config.Set("privateactionrunner.urn", persistedIdentity.URN, model.SourceAgentRuntime)
88+
coreConfig.Set("privateactionrunner.private_key", persistedIdentity.PrivateKey, model.SourceAgentRuntime)
89+
coreConfig.Set("privateactionrunner.urn", persistedIdentity.URN, model.SourceAgentRuntime)
7190
}
7291

73-
cfg, err := parconfig.FromDDConfig(reqs.Config)
92+
cfg, err := parconfig.FromDDConfig(coreConfig)
7493
if err != nil {
75-
return Provides{}, err
94+
return nil, err
7695
}
7796

78-
canSelfEnroll := reqs.Config.GetBool("privateactionrunner.self_enroll")
97+
canSelfEnroll := coreConfig.GetBool("privateactionrunner.self_enroll")
7998
if cfg.IdentityIsIncomplete() && canSelfEnroll {
80-
reqs.Log.Info("Identity not found and self-enrollment enabled. Self-enrolling private action runner")
81-
updatedCfg, err := performSelfEnrollment(ctx, reqs.Log, reqs.Config, reqs.Hostname, cfg)
99+
logger.Info("Identity not found and self-enrollment enabled. Self-enrolling private action runner")
100+
updatedCfg, err := performSelfEnrollment(ctx, logger, coreConfig, hostnameGetter, cfg)
82101
if err != nil {
83-
return Provides{}, fmt.Errorf("self-enrollment failed: %w", err)
102+
return nil, fmt.Errorf("self-enrollment failed: %w", err)
84103
}
85-
reqs.Config.Set("privateactionrunner.private_key", updatedCfg.PrivateKey, model.SourceAgentRuntime)
86-
reqs.Config.Set("privateactionrunner.urn", updatedCfg.Urn, model.SourceAgentRuntime)
104+
coreConfig.Set("privateactionrunner.private_key", updatedCfg.PrivateKey, model.SourceAgentRuntime)
105+
coreConfig.Set("privateactionrunner.urn", updatedCfg.Urn, model.SourceAgentRuntime)
87106
cfg = updatedCfg
88107
} else if cfg.IdentityIsIncomplete() {
89-
return Provides{}, errors.New("identity not found and self-enrollment disabled. Please provide a valid URN and private key")
108+
return nil, errors.New("identity not found and self-enrollment disabled. Please provide a valid URN and private key")
90109
}
91-
reqs.Log.Info("Private action runner starting")
92-
reqs.Log.Info("==> Version : " + parversion.RunnerVersion)
93-
reqs.Log.Info("==> Site : " + cfg.DatadogSite)
94-
reqs.Log.Info("==> URN : " + cfg.Urn)
110+
logger.Info("Private action runner starting")
111+
logger.Info("==> Version : " + parversion.RunnerVersion)
112+
logger.Info("==> Site : " + cfg.DatadogSite)
113+
logger.Info("==> URN : " + cfg.Urn)
95114

96-
keysManager := taskverifier.NewKeyManager(reqs.RcClient)
115+
keysManager := taskverifier.NewKeyManager(rcClient)
97116
taskVerifier := taskverifier.NewTaskVerifier(keysManager, cfg)
98117
opmsClient := opms.NewClient(cfg)
99118

100119
r, err := runners.NewWorkflowRunner(cfg, keysManager, taskVerifier, opmsClient)
101120
if err != nil {
102-
return Provides{}, err
121+
return nil, err
103122
}
104-
runner := &privateactionrunnerImpl{
123+
runner := &PrivateActionRunner{
105124
workflowRunner: r,
106125
commonRunner: runners.NewCommonRunner(cfg),
107126
}
108-
reqs.Lifecycle.Append(compdef.Hook{
109-
OnStart: runner.Start,
110-
OnStop: runner.Stop,
111-
})
112-
return Provides{
113-
Comp: runner,
114-
}, nil
127+
return runner, nil
115128
}
116129

117-
func (p *privateactionrunnerImpl) Start(_ context.Context) error {
130+
func (p *PrivateActionRunner) Start(_ context.Context) error {
118131
// Use background context to avoid inheriting any deadlines from component lifecycle which stop the PAR loop
119132
ctx, cancel := context.WithCancel(context.Background())
120133
p.drain = cancel
@@ -125,7 +138,7 @@ func (p *privateactionrunnerImpl) Start(_ context.Context) error {
125138
return p.workflowRunner.Start(ctx)
126139
}
127140

128-
func (p *privateactionrunnerImpl) Stop(ctx context.Context) error {
141+
func (p *PrivateActionRunner) Stop(ctx context.Context) error {
129142
err := p.workflowRunner.Stop(ctx)
130143
if err != nil {
131144
return err

omnibus/config/software/curl.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
dependency "zlib"
2222
dependency "openssl3"
23-
dependency "nghttp2"
2423
source url: "https://curl.haxx.se/download/curl-#{version}.tar.gz",
2524
sha256: "e9274a5f8ab5271c0e0e6762d2fce194d5f98acc568e4ce816845b2dcc0cf88f"
2625

@@ -31,6 +30,10 @@
3130
license_file "https://raw.githubusercontent.com/bagder/curl/master/COPYING"
3231
env = with_standard_compiler_flags(with_embedded_path)
3332

33+
command_on_repo_root "bazelisk run -- @nghttp2//:install --verbose --destdir='#{install_dir}'"
34+
command_on_repo_root "bazelisk run -- @nghttp2//:install_pc --destdir='/'"
35+
# nghttp2 is at the bottom. It does not need rpath rewriting.
36+
3437
configure_options = [
3538
"--disable-manual",
3639
"--disable-debug",

omnibus/config/software/nghttp2.rb

Lines changed: 0 additions & 34 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"signed":{"_type":"root","spec_version":"1.0","version":1,"expires":"0001-01-01T00:00:00Z","keys":{"1bd43b99872bee114b2b1c33cff7afbdb8ccfc799751aaa11c2336f3540d1c10":{"keytype":"ecdsa","scheme":"ecdsa-sha2-nistp256","keyid_hash_algorithms":["sha256","sha512"],"keyval":{"public":"-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEUDdWZozMy6DojzrxkhevLhLzom0E\nnW0C7JWPXgnoL58OHhqDTHhkiUP5H3+fGdVKZ33Vca686aWWSwZUY6xSRQ==\n-----END PUBLIC KEY-----\n"}},"3360f9a30c063542b2d193fe01854ea3b7ae92c641812b97ce01180bf150c835":{"keytype":"ecdsa","scheme":"ecdsa-sha2-nistp256","keyid_hash_algorithms":["sha256","sha512"],"keyval":{"public":"-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEE/Evc+4Qx1yPwe0SyvP52C9z8inY\ncTH0eCXHRu+mzShDx7Ne8gyA/vU696i9jcc4pfsOwo1WpIkJsXuqP0jG6A==\n-----END PUBLIC KEY-----\n"}}},"roles":{"root":{"keyids":["1bd43b99872bee114b2b1c33cff7afbdb8ccfc799751aaa11c2336f3540d1c10","3360f9a30c063542b2d193fe01854ea3b7ae92c641812b97ce01180bf150c835"],"threshold":2},"snapshot":{"keyids":["1bd43b99872bee114b2b1c33cff7afbdb8ccfc799751aaa11c2336f3540d1c10","3360f9a30c063542b2d193fe01854ea3b7ae92c641812b97ce01180bf150c835"],"threshold":2},"targets":{"keyids":["1bd43b99872bee114b2b1c33cff7afbdb8ccfc799751aaa11c2336f3540d1c10","3360f9a30c063542b2d193fe01854ea3b7ae92c641812b97ce01180bf150c835"],"threshold":2},"timestamp":{"keyids":["1bd43b99872bee114b2b1c33cff7afbdb8ccfc799751aaa11c2336f3540d1c10","3360f9a30c063542b2d193fe01854ea3b7ae92c641812b97ce01180bf150c835"],"threshold":2}},"consistent_snapshot":true},"signatures":[{"keyid":"1bd43b99872bee114b2b1c33cff7afbdb8ccfc799751aaa11c2336f3540d1c10","sig":"3045022016088517105a41506c4465e636483b2eb782d03322da78273a28dd427f2acc78022100cfd965ae1e32c86761d6256a67708e5808f3f98413976373febe23bfefec8da1"},{"keyid":"3360f9a30c063542b2d193fe01854ea3b7ae92c641812b97ce01180bf150c835","sig":"3045022007f880ebf48676740f6cb9d216c91e0f51427ef9f44a73f4a7de8da6e4b4b53d022100b0f87441a0761422d7ac57582215d9570de78a0c30dd86479accedf7a00a6a1b"}]}
1+
{"signed":{"_type":"root","spec_version":"1.0","version":3,"expires":"2026-10-31T17:00:00Z","keys":{"1bd43b99872bee114b2b1c33cff7afbdb8ccfc799751aaa11c2336f3540d1c10":{"keytype":"ecdsa","scheme":"ecdsa-sha2-nistp256","keyid_hash_algorithms":["sha256","sha512"],"keyval":{"public":"-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEUDdWZozMy6DojzrxkhevLhLzom0E\nnW0C7JWPXgnoL58OHhqDTHhkiUP5H3+fGdVKZ33Vca686aWWSwZUY6xSRQ==\n-----END PUBLIC KEY-----\n"}},"3360f9a30c063542b2d193fe01854ea3b7ae92c641812b97ce01180bf150c835":{"keytype":"ecdsa","scheme":"ecdsa-sha2-nistp256","keyid_hash_algorithms":["sha256","sha512"],"keyval":{"public":"-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEE/Evc+4Qx1yPwe0SyvP52C9z8inY\ncTH0eCXHRu+mzShDx7Ne8gyA/vU696i9jcc4pfsOwo1WpIkJsXuqP0jG6A==\n-----END PUBLIC KEY-----\n"}}},"roles":{"root":{"keyids":["1bd43b99872bee114b2b1c33cff7afbdb8ccfc799751aaa11c2336f3540d1c10","3360f9a30c063542b2d193fe01854ea3b7ae92c641812b97ce01180bf150c835"],"threshold":2},"snapshot":{"keyids":["1bd43b99872bee114b2b1c33cff7afbdb8ccfc799751aaa11c2336f3540d1c10","3360f9a30c063542b2d193fe01854ea3b7ae92c641812b97ce01180bf150c835"],"threshold":2},"targets":{"keyids":["1bd43b99872bee114b2b1c33cff7afbdb8ccfc799751aaa11c2336f3540d1c10","3360f9a30c063542b2d193fe01854ea3b7ae92c641812b97ce01180bf150c835"],"threshold":2},"timestamp":{"keyids":["1bd43b99872bee114b2b1c33cff7afbdb8ccfc799751aaa11c2336f3540d1c10","3360f9a30c063542b2d193fe01854ea3b7ae92c641812b97ce01180bf150c835"],"threshold":2}},"consistent_snapshot":true},"signatures":[{"keyid":"1bd43b99872bee114b2b1c33cff7afbdb8ccfc799751aaa11c2336f3540d1c10","sig":"3045022100d31c2a8767706ebe22b9bc2592e18fe4067ac430cf77dc92bca781b120338db1022050fe0ebb8a47abe9b4cc25384f288a046e33f959dd46acc449fe8eb3581d776e"},{"keyid":"3360f9a30c063542b2d193fe01854ea3b7ae92c641812b97ce01180bf150c835","sig":"304502205d9d39c9b04ee047addd2d72a06d129fda1a81c23e5044d8009e054f6cf2e7fa0221009586e2a872bb68fc508b0667a59ed110276f2cf7840de968ca9a9b3643dcdf81"}]}

test/new-e2e/tests/installer/windows/base_suite.go

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"context"
1010
"fmt"
1111
"path/filepath"
12+
"strconv"
1213
"strings"
1314
"time"
1415

@@ -525,6 +526,62 @@ func (s *BaseSuite) collectxperf() {
525526
}
526527
}
527528

529+
// startProcdump sets up procdump and starts it in the background.
530+
func (s *BaseSuite) startProcdump() *windowscommon.ProcdumpSession {
531+
host := s.Env().RemoteHost
532+
533+
// Setup procdump on remote host
534+
s.T().Log("Setting up procdump on remote host")
535+
err := windowscommon.SetupProcdump(host)
536+
s.Require().NoError(err, "should setup procdump")
537+
538+
// Start procdump
539+
ps, err := windowscommon.StartProcdump(host, "agent.exe")
540+
s.Require().NoError(err, "should start procdump")
541+
542+
return ps
543+
}
544+
545+
// collectProcdumps stops procdump and downloads any captured dumps if the test failed.
546+
func (s *BaseSuite) collectProcdumps(ps *windowscommon.ProcdumpSession) {
547+
// Only collect dumps if the test failed
548+
if !s.T().Failed() {
549+
ps.Close()
550+
return
551+
}
552+
553+
host := s.Env().RemoteHost
554+
555+
// Wait for procdump to finish writing dump files BEFORE closing the session.
556+
// Procdump is configured to capture 5 dumps, so wait until all 5 are created.
557+
expectedDumpCount := 5
558+
s.T().Logf("Waiting for procdump to create %d dump files...", expectedDumpCount)
559+
deadline := time.Now().Add(120 * time.Second)
560+
for time.Now().Before(deadline) {
561+
output, err := host.Execute(fmt.Sprintf(`(Get-ChildItem -Path '%s' -Filter '*.dmp' -ErrorAction SilentlyContinue | Measure-Object).Count`, windowscommon.ProcdumpsPath))
562+
if err == nil {
563+
countStr := strings.TrimSpace(output)
564+
count, parseErr := strconv.Atoi(countStr)
565+
if parseErr == nil && count >= expectedDumpCount {
566+
s.T().Logf("All %d dump files ready", count)
567+
break
568+
}
569+
s.T().Logf("Found %s dump files, waiting for %d...", countStr, expectedDumpCount)
570+
}
571+
time.Sleep(5 * time.Second)
572+
}
573+
574+
ps.Close()
575+
576+
// Download all dump files
577+
outDir := s.SessionOutputDir()
578+
if err := host.GetFolder(windowscommon.ProcdumpsPath, outDir); err != nil {
579+
s.T().Logf("Warning: failed to download dump %s: %v", windowscommon.ProcdumpsPath, err)
580+
} else {
581+
s.T().Logf("Downloaded procdumps to: %s", outDir)
582+
}
583+
}
584+
528585
// InstallWithXperf installs the MSI with xperf tracing to diagnose service startup issues.
529586
// This wraps the MSI installation with performance tracing and service status checking.
530587
//
@@ -553,6 +610,34 @@ func (s *BaseSuite) InstallWithXperf(opts ...MsiOption) {
553610
s.T().Log("MSI installation and service startup completed successfully")
554611
}
555612

613+
// InstallWithDiagnostics installs the MSI with comprehensive diagnostics collection:
614+
// - xperf tracing for system-wide performance analysis
615+
// - procdump collection to capture agent memory dump if it crashes during startup
616+
func (s *BaseSuite) InstallWithDiagnostics(opts ...MsiOption) {
617+
s.T().Helper()
618+
619+
// Start xperf tracing
620+
s.T().Log("Starting xperf tracing")
621+
s.startxperf()
622+
defer s.collectxperf()
623+
624+
// Start procdump in background to capture crash dumps
625+
s.T().Log("Starting procdump")
626+
ps := s.startProcdump()
627+
defer s.collectProcdumps(ps)
628+
629+
// Proceed with installation
630+
s.T().Log("Installing MSI")
631+
err := s.Installer().Install(opts...)
632+
s.Require().NoError(err, "MSI installation failed")
633+
634+
// Wait for service to be running
635+
s.T().Log("Checking agent service status after MSI installation")
636+
err = s.WaitForAgentService("Running")
637+
s.Require().NoError(err, "Agent service status check failed")
638+
s.T().Log("MSI installation and service startup completed successfully")
639+
}
640+
556641
// MustStartExperimentCurrentVersion start an experiment with current version of the Agent
557642
func (s *BaseSuite) MustStartExperimentCurrentVersion() {
558643
s.T().Helper()

test/new-e2e/tests/installer/windows/suites/agent-package/upgrade_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ func (s *testAgentUpgradeSuite) installPreviousAgentVersion(opts ...installerwin
616616
installerwindows.WithMSILogFile("install-previous-version.log"),
617617
}
618618
options = append(options, opts...)
619-
s.InstallWithXperf(options...)
619+
s.InstallWithDiagnostics(options...)
620620

621621
// sanity check: make sure we did indeed install the stable version
622622
s.Require().Host(s.Env().RemoteHost).
@@ -635,7 +635,7 @@ func (s *testAgentUpgradeSuite) installCurrentAgentVersion(opts ...installerwind
635635
installerwindows.WithMSILogFile("install-current-version.log"),
636636
}
637637
options = append(options, opts...)
638-
s.InstallWithXperf(options...)
638+
s.InstallWithDiagnostics(options...)
639639

640640
// sanity check: make sure we did indeed install the stable version
641641
s.Require().Host(s.Env().RemoteHost).

test/new-e2e/tests/installer/windows/suites/installer-package/base_installer_package_suite.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func (s *baseInstallerPackageSuite) freshInstall() {
2626
// Arrange
2727

2828
// Act
29-
s.InstallWithXperf(
29+
s.InstallWithDiagnostics(
3030
installerwindows.WithMSILogFile("fresh-install.log"),
3131
)
3232

test/new-e2e/tests/installer/windows/suites/installer-package/install_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func (s *testInstallerSuite) installWithExistingConfigFile(logFilename string) {
101101
// Arrange
102102

103103
// Act
104-
s.InstallWithXperf(
104+
s.InstallWithDiagnostics(
105105
installerwindows.WithMSILogFile(logFilename),
106106
)
107107

@@ -116,7 +116,7 @@ func (s *testInstallerSuite) repair() {
116116
s.Require().NoError(s.Env().RemoteHost.Remove(consts.BinaryPath))
117117

118118
// Act
119-
s.InstallWithXperf(
119+
s.InstallWithDiagnostics(
120120
installerwindows.WithMSILogFile("repair.log"),
121121
)
122122

0 commit comments

Comments
 (0)