Repository navigation
feat: support recursive DAG discovery - #2462
Conversation
📝 WalkthroughWalkthroughThe change adds optional recursive DAG discovery under ChangesRecursive DAG discovery
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant ConfigLoader
participant DAGStore
participant EntryReader
participant FileWatcher
participant API
ConfigLoader->>DAGStore: configure recursive discovery
ConfigLoader->>EntryReader: configure recursive scheduling
DAGStore->>DAGStore: scan and catalog nested DAG files
FileWatcher->>EntryReader: report file or directory changes
EntryReader->>DAGStore: reload discovered DAG metadata
EntryReader-->>EntryReader: emit deterministic schedule events
API->>DAGStore: resolve DAG by filename
DAGStore-->>API: return nested DAG details and path
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
internal/persis/file/dag/store_test.go (1)
153-161: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAdd a nested cursor-pagination case to the recursive search test.
This test calls
SearchCursoronce withLimit: 10, so it never exercises a returned cursor. The cursor skip logic inStorage.SearchCursorcompares file stems, while recursive discovery orders entries by relative path. A test that setsLimit: 1over nested DAGs whose stem order differs from their path order would cover that interaction.Example: create
a/zebra.yamlandb/apple.yaml, both matching the query, then page withLimit: 1and assert that both DAGs are returned across the two pages.This relates to the pagination concern raised in
internal/persis/file/dag/store.go.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/persis/file/dag/store_test.go` around lines 153 - 161, Extend the recursive search test around SearchCursor to create nested matching DAGs whose filename stem order differs from relative-path order, such as a/zebra.yaml and b/apple.yaml. Use Limit: 1, assert the first page returns one item and a cursor, then request the next page with that cursor and assert the remaining DAG is returned, covering Storage.SearchCursor pagination across nested paths.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/persis/file/dag/catalog.go`:
- Around line 23-31: The loadCatalog flow should cache the constructed catalog
keyed by the discovery inputs baseDir, searchPaths, and recursive, reusing it
across recursive lookup paths such as locateDAG, List, SearchCursor, LabelList,
and metadata/spec operations. Add cache reuse and ensure invalidation occurs
only after writes or base-config state changes, while preserving fresh scan
error handling when the cache is invalid or absent.
In `@internal/persis/file/dag/store.go`:
- Around line 752-762: Align SearchCursor pagination with the catalog’s
iteration order: update the filtering in the search loop around entryStem and
cursor.FileName to compare the same FilePath-based key used to sort
catalog.entries, or change catalog.newCatalog ordering to stem order
consistently. Ensure subsequent pages cannot skip entries when directory paths
and stems sort differently.
In `@internal/service/scheduler/entryreader_internal_test.go`:
- Around line 301-307: Update the os.WriteFile call creating the test DAG at
firstPath to use 0600 permissions instead of 0644, matching the repository’s
secure test-file permission convention.
In `@internal/service/scheduler/entryreader.go`:
- Around line 412-433: Update syncWatches to compute watcher additions and
removals without mutating watchedDirs, then acquire er.lock while applying all
watchedDirs changes; preserve existing watcher error handling and removal
behavior. Also guard the watchedDirs write in initRecursive with er.lock for
consistent synchronization with readers. Run the Go test suite with gotestsum
and race detection.
---
Nitpick comments:
In `@internal/persis/file/dag/store_test.go`:
- Around line 153-161: Extend the recursive search test around SearchCursor to
create nested matching DAGs whose filename stem order differs from relative-path
order, such as a/zebra.yaml and b/apple.yaml. Use Limit: 1, assert the first
page returns one item and a cursor, then request the next page with that cursor
and assert the remaining DAG is returned, covering Storage.SearchCursor
pagination across nested paths.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 45efacc9-c967-4039-9935-9f1d962c62da
📒 Files selected for processing (20)
README.mdinternal/cmd/process/scheduler.gointernal/cmn/config/config.gointernal/cmn/config/definition.gointernal/cmn/config/loader.gointernal/cmn/config/loader_test.gointernal/dagdiscovery/scan.gointernal/dagdiscovery/scan_test.gointernal/intg/distr/fixtures_test.gointernal/persis/file/dag/catalog.gointernal/persis/file/dag/dagindex/dagindex.gointernal/persis/file/dag/store.gointernal/persis/file/dag/store_test.gointernal/persis/file/dag_store.gointernal/service/frontend/api/v1/dags_test.gointernal/service/scheduler/entryreader.gointernal/service/scheduler/entryreader_internal_test.gointernal/service/scheduler/manger_test.gointernal/test/helper.gointernal/test/scheduler.go
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
Summary
Configuration
The same setting is available through
DAGU_DAG_DISCOVERY_RECURSIVE.Testing
Closes #2400
Summary by cubic
Adds opt-in recursive DAG discovery under
paths.dags_dir, with the scheduler watching nested directories and emitting add/update/delete events. Duplicate file stems or DAG names are excluded and surfaced in API/list/search results. Closes #2400.New Features
dag_discovery.recursive: trueorDAGU_DAG_DISCOVERY_RECURSIVE=true.workspaces/, dot-directories, and symlinked entries (supports a symlinked root).team/service/dag) are supported; nested paths resolve transparently.NewEntryReadernow takes arecursiveflag; index entries and loading use normalized relative paths;paths.alt_dags_dirremains lookup-only.dag_discovery.recursive.Migration
Written for commit c74544e. Summary will update on new commits.
Summary by CodeRabbit
New Features
dag_discovery.recursiveorDAGU_DAG_DISCOVERY_RECURSIVE.Bug Fixes
Documentation