Skip to content

Commit eae352d

Browse files
committed
[ACTP] make executor idle timeout authoritative
1 parent cd40040 commit eae352d

2 files changed

Lines changed: 21 additions & 8 deletions

File tree

comp/privateactionrunner/impl/privateactionrunner.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ func (p *PrivateActionRunner) startExecutor(ctx context.Context) error {
323323
}
324324
serveOpts := executor.ServeOptions{
325325
DrainTimeout: drainTimeout,
326-
IdleTimeout: executorIdleTimeout(p.coreConfig),
326+
IdleTimeout: executorIdleTimeout(p.coreConfig.GetInt(privateactionrunner.PARIdleTimeoutSeconds)),
327327
OnIdleTimeout: func() {
328328
p.logger.Info("Private action runner executor idle timeout elapsed; shutting down")
329329
if err := p.shutdowner.Shutdown(); err != nil {
@@ -345,15 +345,11 @@ func (p *PrivateActionRunner) startExecutor(ctx context.Context) error {
345345
return nil
346346
}
347347

348-
// Keep self-termination behind the control plane's normal idle stop.
349-
const executorIdleTimeoutFactor = 3
350-
351-
func executorIdleTimeout(cfg model.Reader) time.Duration {
352-
idle := cfg.GetInt(privateactionrunner.PARIdleTimeoutSeconds)
353-
if idle <= 0 {
348+
func executorIdleTimeout(idleSeconds int) time.Duration {
349+
if idleSeconds <= 0 {
354350
return 0
355351
}
356-
return time.Duration(idle) * executorIdleTimeoutFactor * time.Second
352+
return time.Duration(idleSeconds) * time.Second
357353
}
358354

359355
// StopExecutor gracefully stops the executor gRPC server and releases resources.

comp/privateactionrunner/impl/privateactionrunner_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,29 @@ import (
99
"context"
1010
"errors"
1111
"testing"
12+
"time"
1213

1314
"github.com/DataDog/datadog-go/v5/statsd"
1415
"github.com/stretchr/testify/assert"
1516
"github.com/stretchr/testify/require"
1617
)
1718

19+
func TestExecutorIdleTimeout(t *testing.T) {
20+
for _, tt := range []struct {
21+
name string
22+
idleSeconds int
23+
want time.Duration
24+
}{
25+
{name: "disabled", idleSeconds: 0, want: 0},
26+
{name: "negative is disabled", idleSeconds: -1, want: 0},
27+
{name: "uses configured duration", idleSeconds: 60, want: time.Minute},
28+
} {
29+
t.Run(tt.name, func(t *testing.T) {
30+
assert.Equal(t, tt.want, executorIdleTimeout(tt.idleSeconds))
31+
})
32+
}
33+
}
34+
1835
func TestStopCleansUpMetricsClient(t *testing.T) {
1936
tests := []struct {
2037
name string

0 commit comments

Comments
 (0)