Skip to content

Commit 8824a00

Browse files
committed
[ACTP] wire split runner ownership
1 parent f0e4026 commit 8824a00

6 files changed

Lines changed: 50 additions & 7 deletions

File tree

cmd/privateactionrunner/subcommands/run/command.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func runPrivateActionRunner(ctx context.Context, confPath string, extraConfFiles
130130
}
131131

132132
err := fxutil.Run(fxOptions...)
133-
if errors.Is(err, privateactionrunner.ErrNotEnabled) {
133+
if errors.Is(err, privateactionrunner.ErrNotEnabled) || errors.Is(err, privateactionrunner.ErrSplitDeployment) {
134134
return nil
135135
}
136136
return err

comp/privateactionrunner/def/component.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,9 @@ import "errors"
1414
type Component interface {
1515
}
1616

17-
// ErrNotEnabled is returned when the private action runner is not enabled
1817
var ErrNotEnabled = errors.New("private action runner is not enabled")
18+
var ErrSplitDeployment = errors.New("private action runner is running in split deployment mode")
1919

20-
// Configuration keys for the private action runner.
21-
// Duplicated from pkg/config/setup/privateactionrunner.go because comp/
22-
// packages cannot import pkg/config/setup (depguard rule).
2320
const (
2421
PAREnabled = "private_action_runner.enabled"
2522
PARSelfEnroll = "private_action_runner.self_enroll"
@@ -32,4 +29,5 @@ const (
3229
PARIdleTimeoutSeconds = "private_action_runner.idle_timeout_seconds"
3330

3431
PARExecutorSocketPath = "private_action_runner.executor.socket_path"
32+
PARSplitEnabled = "private_action_runner.split_enabled"
3533
)

comp/privateactionrunner/impl/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ go_library(
2121
"//comp/networkpath/traceroute/def",
2222
"//comp/privateactionrunner/def",
2323
"//comp/remote-config/rcclient/def",
24+
"//pkg/config/env",
2425
"//pkg/config/model",
2526
"//pkg/config/utils",
2627
"//pkg/fleet/installer/telemetry",

comp/privateactionrunner/impl/privateactionrunner.go

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"errors"
1313
"fmt"
1414
"net/http"
15+
"runtime"
1516
"sync"
1617
"time"
1718

@@ -20,7 +21,7 @@ import (
2021

2122
"github.com/DataDog/datadog-agent/comp/core/config"
2223
"github.com/DataDog/datadog-agent/comp/core/hostname"
23-
"github.com/DataDog/datadog-agent/comp/core/hostname/hostnameinterface/def"
24+
hostnameinterface "github.com/DataDog/datadog-agent/comp/core/hostname/hostnameinterface/def"
2425
ipc "github.com/DataDog/datadog-agent/comp/core/ipc/def"
2526
log "github.com/DataDog/datadog-agent/comp/core/log/def"
2627
tagger "github.com/DataDog/datadog-agent/comp/core/tagger/def"
@@ -32,6 +33,7 @@ import (
3233
traceroute "github.com/DataDog/datadog-agent/comp/networkpath/traceroute/def"
3334
privateactionrunner "github.com/DataDog/datadog-agent/comp/privateactionrunner/def"
3435
rcclient "github.com/DataDog/datadog-agent/comp/remote-config/rcclient/def"
36+
configenv "github.com/DataDog/datadog-agent/pkg/config/env"
3537
"github.com/DataDog/datadog-agent/pkg/config/model"
3638
configutils "github.com/DataDog/datadog-agent/pkg/config/utils"
3739
"github.com/DataDog/datadog-agent/pkg/fleet/installer/telemetry"
@@ -60,6 +62,19 @@ func isEnabled(cfg config.Component) bool {
6062
return cfg.GetBool(privateactionrunner.PAREnabled)
6163
}
6264

65+
func splitDeploymentSupported(goos string, containerized bool) bool {
66+
if containerized {
67+
return false
68+
}
69+
70+
switch goos {
71+
case "linux", "windows":
72+
return true
73+
default:
74+
return false
75+
}
76+
}
77+
6378
// Requires defines the dependencies for the privateactionrunner component
6479
type Requires struct {
6580
Config config.Component
@@ -121,6 +136,14 @@ func NewComponent(reqs Requires) (Provides, error) {
121136
reqs.Log.Flush()
122137
return Provides{}, privateactionrunner.ErrNotEnabled
123138
}
139+
if reqs.Config.GetBool(privateactionrunner.PARSplitEnabled) {
140+
if splitDeploymentSupported(runtime.GOOS, configenv.IsContainerized()) {
141+
reqs.Log.Info("Split deployment is enabled; the monolithic PAR is standing down")
142+
reqs.Log.Flush()
143+
return Provides{}, privateactionrunner.ErrSplitDeployment
144+
}
145+
reqs.Log.Warn("Split deployment is not supported in this environment; continuing with the monolithic PAR")
146+
}
124147

125148
// The standalone runner sends metrics over a DogStatsD socket/UDP, built from
126149
// the Agent's configured endpoint (it runs alongside a node Agent listener).

comp/privateactionrunner/impl/privateactionrunner_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,27 @@ func TestGetRunnerConfigDiscardsCorruptIdentity(t *testing.T) {
7070
assert.Equal(t, urn, cfg.Urn)
7171
}
7272

73+
func TestSplitDeploymentSupported(t *testing.T) {
74+
tests := []struct {
75+
name string
76+
goos string
77+
containerized bool
78+
want bool
79+
}{
80+
{name: "linux host", goos: "linux", want: true},
81+
{name: "windows host", goos: "windows", want: true},
82+
{name: "linux container", goos: "linux", containerized: true},
83+
{name: "windows container", goos: "windows", containerized: true},
84+
{name: "unsupported host platform", goos: "darwin"},
85+
}
86+
87+
for _, tt := range tests {
88+
t.Run(tt.name, func(t *testing.T) {
89+
assert.Equal(t, tt.want, splitDeploymentSupported(tt.goos, tt.containerized))
90+
})
91+
}
92+
}
93+
7394
func TestStopCleansUpMetricsClient(t *testing.T) {
7495
tests := []struct {
7596
name string

pkg/config/schema/yaml/private_action_runner.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ properties:
195195
node_type: setting
196196
type: boolean
197197
default: false
198-
comment: Enables split runner mode.
198+
comment: Enables split runner mode on supported Linux and Windows hosts.
199199
urn:
200200
node_type: setting
201201
type: string

0 commit comments

Comments
 (0)