Skip to content

Commit 863185f

Browse files
committed
[ACTP] Integrate the private action runner in the cluster agent
1 parent 0134072 commit 863185f

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

cmd/cluster-agent/subcommands/start/command.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ import (
7474
integrations "github.com/DataDog/datadog-agent/comp/logs/integrations/def"
7575
metadatarunner "github.com/DataDog/datadog-agent/comp/metadata/runner"
7676
metadatarunnerimpl "github.com/DataDog/datadog-agent/comp/metadata/runner/runnerimpl"
77+
privateactionrunner "github.com/DataDog/datadog-agent/comp/privateactionrunner/impl"
7778
rccomp "github.com/DataDog/datadog-agent/comp/remote-config/rcservice"
7879
"github.com/DataDog/datadog-agent/comp/remote-config/rcservice/rcserviceimpl"
7980
"github.com/DataDog/datadog-agent/comp/remote-config/rctelemetryreporter/rctelemetryreporterimpl"
@@ -273,6 +274,7 @@ func start(log log.Component,
273274
ipc ipc.Component,
274275
diagnoseComp diagnose.Component,
275276
dcametadataComp dcametadata.Component,
277+
hostnameGetter hostnameinterface.Component,
276278

277279
clusterChecksMetadataComp clusterchecksmetadata.Component,
278280
_ metadatarunner.Component,
@@ -427,6 +429,10 @@ func start(log log.Component,
427429
if config.GetBool("admission_controller.auto_instrumentation.enabled") || config.GetBool("apm_config.instrumentation.enabled") {
428430
products = append(products, state.ProductGradualRollout)
429431
}
432+
// Add private action runner product if enabled
433+
if config.GetBool("privateactionrunner.enabled") {
434+
products = append(products, state.ProductActionPlatformRunnerKeys)
435+
}
430436

431437
if len(products) > 0 {
432438
var err error
@@ -544,6 +550,17 @@ func start(log log.Component,
544550
appsec.Cleanup(mainCtx, log, config, le.Subscribe)
545551
}
546552

553+
if config.GetBool("privateactionrunner.enabled") {
554+
drain, err := startPrivateActionRunner(mainCtx, config, hostnameGetter, rcClient, log)
555+
if err != nil {
556+
log.Errorf("Cannot start private action runner: %v", err)
557+
} else {
558+
defer drain()
559+
}
560+
} else {
561+
log.Info("Private action runner is disabled")
562+
}
563+
547564
if config.GetBool("admission_controller.enabled") {
548565
if config.GetBool("admission_controller.auto_instrumentation.patcher.enabled") {
549566
patchCtx := admissionpatch.ControllerContext{
@@ -666,6 +683,31 @@ func setupClusterCheck(ctx context.Context, ac autodiscovery.Component, tagger t
666683
return handler, nil
667684
}
668685

686+
func startPrivateActionRunner(
687+
ctx context.Context,
688+
config config.Component,
689+
hostnameGetter hostnameinterface.Component,
690+
rcClient *rcclient.Client,
691+
log log.Component,
692+
) (func(), error) {
693+
if rcClient == nil {
694+
return nil, errors.New("Remote config is disabled or failed to initialize, remote config is a required dependency for private action runner")
695+
}
696+
app, err := privateactionrunner.NewPrivateActionRunner(ctx, config, hostnameGetter, rcClient, log)
697+
if err != nil {
698+
return nil, err
699+
}
700+
err = app.Start(ctx)
701+
if err != nil {
702+
return nil, err
703+
}
704+
return func() {
705+
if err := app.Stop(context.Background()); err != nil {
706+
log.Errorf("Error stopping private action runner: %v", err)
707+
}
708+
}, nil
709+
}
710+
669711
func initializeRemoteConfigClient(rcService rccomp.Component, config config.Component, clusterName, clusterID string, products ...string) (*rcclient.Client, error) {
670712
if clusterName == "" {
671713
pkglog.Warn("cluster-name won't be set for remote-config client")

0 commit comments

Comments
 (0)