Skip to content

Commit 6d729b5

Browse files
committed
feat: enable default base dag retry policy
1 parent 1e905dc commit 6d729b5

4 files changed

Lines changed: 30 additions & 6 deletions

File tree

internal/core/spec/loader_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,6 +1435,26 @@ steps:
14351435
require.Equal(t, 600*time.Second, dag.Steps[0].Timeout)
14361436
})
14371437

1438+
t.Run("BaseConfigDAGRetryPolicy", func(t *testing.T) {
1439+
t.Parallel()
1440+
1441+
base := createTempYAMLFile(t, `
1442+
retry_policy:
1443+
limit: 1
1444+
interval_sec: 60
1445+
`)
1446+
child := createTempYAMLFile(t, `
1447+
steps:
1448+
- name: step1
1449+
command: echo "test"
1450+
`)
1451+
dag, err := spec.Load(context.Background(), child, spec.WithBaseConfig(base))
1452+
require.NoError(t, err)
1453+
require.NotNil(t, dag.RetryPolicy)
1454+
require.Equal(t, 1, dag.RetryPolicy.Limit)
1455+
require.Equal(t, 60*time.Second, dag.RetryPolicy.Interval)
1456+
})
1457+
14381458
t.Run("UnknownKeyInDefaults", func(t *testing.T) {
14391459
t.Parallel()
14401460

internal/persis/filebaseconfig/default_base_config.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ max_output_size: 1048576 # 1MB (bytes)
4646
# Duration string: e.g. "6h", "24h", "2d12h". Empty = no catchup (missed runs discarded).
4747
catchup_window: "6h"
4848
49+
# Retry the entire DAG after a terminal failure.
50+
# This absorbs transient infrastructure or dependency failures by default.
51+
# Override or disable per DAG if the workflow is intentionally non-idempotent.
52+
retry_policy:
53+
limit: 1
54+
interval_sec: 60
55+
4956
# -- Shell --
5057
# Shell interpreter for command steps.
5158
# Default resolution order: $DAGU_DEFAULT_SHELL -> $SHELL -> sh

internal/persis/filebaseconfig/store_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ func TestInitialize(t *testing.T) {
126126
assert.Contains(t, string(data), "Base DAG Configuration")
127127
assert.Contains(t, string(data), "catchup_window")
128128
assert.Contains(t, string(data), "hist_retention_days")
129+
assert.Contains(t, string(data), "\nretry_policy:\n limit: 1\n interval_sec: 60\n")
129130
})
130131

131132
t.Run("skips when file already exists", func(t *testing.T) {

internal/service/scheduler/retry_scanner_test.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package scheduler
66
import (
77
"context"
88
"errors"
9+
"slices"
910
"testing"
1011
"time"
1112

@@ -516,12 +517,7 @@ func cloneRetryStatus(status *exec.DAGRunStatus) *exec.DAGRunStatus {
516517
}
517518

518519
func containsStatus(statuses []core.Status, want core.Status) bool {
519-
for _, status := range statuses {
520-
if status == want {
521-
return true
522-
}
523-
}
524-
return false
520+
return slices.Contains(statuses, want)
525521
}
526522

527523
func withRetryCount(status *exec.DAGRunStatus, retryCount int) *exec.DAGRunStatus {

0 commit comments

Comments
 (0)