fix: git sync is not pulling full folders, no longer deploy on creation of sync#2239
Merged
fix: git sync is not pulling full folders, no longer deploy on creation of sync#2239
Conversation
Member
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Member
Author
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Contributor
|
Container images for this PR have been built successfully!
Built from commit 48bc996 |
5d755e2 to
ca2f548
Compare
ca2f548 to
eb5f627
Compare
eb5f627 to
48bc996
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Checklist
mainbranchWhat This PR Implements
Fixes: #2224
Changes Made
Testing Done
./scripts/development/dev.sh startjust lint all)just test backendAI Tool Used (if applicable)
AI Tool:
Assistance Level:
What AI helped with:
I reviewed and edited all AI-generated output:
I ran all required tests and manually verified changes:
Additional Context
Disclaimer Greptiles Reviews use AI, make sure to check over its work.
To better help train Greptile on our codebase, if the comment is useful and valid Like the comment, if its not helpful or invalid Dislike
To have Greptile Re-Review the changes, mention
greptileai.Greptile Summary
[Linus Torvalds Mode] Someone actually read their previous review comments — I'm as shocked as you are. This PR fixes two real problems: the directory sync was only pulling the compose file instead of the full directory tree, and a newly-created sync was unconditionally triggering a redeploy even before any containers existed to redeploy. Both bugs traced back to missing abstractions and a lack of change-detection logic that this PR now introduces via a staging-area pattern.
What changed:
prepareSyncSourceis extracted fromPerformSync, and the deferred cleanup is now correctly registered before the error check — fixing the repo-dir leak on compose-file-not-found paths flagged in a previous reviewstageDirectorySyncInternal) copies the live project to a temp dir, applies removals, writes the new repo files, validates the compose tree, and only then atomically promotes the stage to the live path with a backup/rollbackdirectorySyncContentsChangedInternalcompares repo content against the live project directory to gate redeployments; a new project isStoppedsoredeployIfRunningAfterSyncno-ops correctlyupdateDirectorySyncProjectInternalnow removes the backup after a confirmed DB update — fixing the backup-deleted-before-DB-write ordering bug from a prior review threadWalkDirectoryusesfs.WalkDiroveros.OpenRoot(syncDir).FS()to recursively traverse the full directory tree, fixing the "not pulling full folders" root causeRemaining concern:
createDirectorySyncProjectInternal, three sequential DB writes (Create, twoUpdates) operate with no wrapping transaction. A failure on the second or third write leaves an orphanedProjectrow in the database that will cause duplicate projects on the next sync run — worth fixing before this sees heavy use.Confidence Score: 5/5
[Linus Torvalds Mode] Congratulations, the author actually addressed prior review feedback — color me reluctantly impressed. The two P1s from previous rounds (leaked repo dir and backup-deleted-before-DB-write) are fixed, the
Internalsuffix convention is now followed on all new package-level helpers, and the staging logic is structurally sound. Safe to merge; the one remaining DB partial-failure scenario is a low-probability P2.Normally I'd be sharpening my red pen right now, but the previously flagged critical issues are genuinely resolved. The only remaining finding is a low-probability DB split-brain during project creation (three sequential writes, no transaction) that degrades gracefully — the sync retries and creates a new project, leaving an orphaned row. That's P2, not a blocker. By the scoring guidance, all-P2 lands at 5/5.
Stare the hardest at
createDirectorySyncProjectInternal(~line 1130) ingitops_sync_service.go— the transaction-less triple DB write is the only spot that can silently corrupt state under a partial failure.Prompt To Fix All With AI
Reviews (3): Last reviewed commit: "fix: git sync is not pulling full folder..." | Re-trigger Greptile
Context used:
What: Code should p... (source)
Senior Go developer with deep expert... (source)