Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions cmd/cluster-agent/subcommands/start/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ import (
integrations "github.com/DataDog/datadog-agent/comp/logs/integrations/def"
metadatarunner "github.com/DataDog/datadog-agent/comp/metadata/runner"
metadatarunnerimpl "github.com/DataDog/datadog-agent/comp/metadata/runner/runnerimpl"
privateactionrunner "github.com/DataDog/datadog-agent/comp/privateactionrunner/impl"
rccomp "github.com/DataDog/datadog-agent/comp/remote-config/rcservice"
"github.com/DataDog/datadog-agent/comp/remote-config/rcservice/rcserviceimpl"
"github.com/DataDog/datadog-agent/comp/remote-config/rctelemetryreporter/rctelemetryreporterimpl"
Expand Down Expand Up @@ -273,6 +274,7 @@ func start(log log.Component,
ipc ipc.Component,
diagnoseComp diagnose.Component,
dcametadataComp dcametadata.Component,
hostnameGetter hostnameinterface.Component,

clusterChecksMetadataComp clusterchecksmetadata.Component,
_ metadatarunner.Component,
Expand Down Expand Up @@ -427,6 +429,10 @@ func start(log log.Component,
if config.GetBool("admission_controller.auto_instrumentation.enabled") || config.GetBool("apm_config.instrumentation.enabled") {
products = append(products, state.ProductGradualRollout)
}
// Add private action runner product if enabled
if config.GetBool("privateactionrunner.enabled") {
products = append(products, state.ProductActionPlatformRunnerKeys)
}

if len(products) > 0 {
var err error
Expand Down Expand Up @@ -544,6 +550,17 @@ func start(log log.Component,
appsec.Cleanup(mainCtx, log, config, le.Subscribe)
}

if config.GetBool("privateactionrunner.enabled") {
drain, err := startPrivateActionRunner(mainCtx, config, hostnameGetter, rcClient, log)
if err != nil {
log.Errorf("Cannot start private action runner: %v", err)
} else {
defer drain()
}
} else {
log.Info("Private action runner is disabled")
}

if config.GetBool("admission_controller.enabled") {
if config.GetBool("admission_controller.auto_instrumentation.patcher.enabled") {
patchCtx := admissionpatch.ControllerContext{
Expand Down Expand Up @@ -666,6 +683,31 @@ func setupClusterCheck(ctx context.Context, ac autodiscovery.Component, tagger t
return handler, nil
}

func startPrivateActionRunner(
ctx context.Context,
config config.Component,
hostnameGetter hostnameinterface.Component,
rcClient *rcclient.Client,
log log.Component,
) (func(), error) {
if rcClient == nil {
return nil, errors.New("Remote config is disabled or failed to initialize, remote config is a required dependency for private action runner")
}
app, err := privateactionrunner.NewPrivateActionRunner(ctx, config, hostnameGetter, rcClient, log)
if err != nil {
return nil, err
}
err = app.Start(ctx)
if err != nil {
return nil, err
}
return func() {
if err := app.Stop(context.Background()); err != nil {
log.Errorf("Error stopping private action runner: %v", err)
}
}, nil
}

func initializeRemoteConfigClient(rcService rccomp.Component, config config.Component, clusterName, clusterID string, products ...string) (*rcclient.Client, error) {
if clusterName == "" {
pkglog.Warn("cluster-name won't be set for remote-config client")
Expand Down
Loading