Redesign DB Draft and Proposed Pushing - #1146
Conversation
✅ Deploy Preview for kpt-porch ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
d437b16 to
6afc5e9
Compare
Signed-off-by: Rendre Greyling <rendre.greyling@nokia.com>
Signed-off-by: Rendre Greyling <rendre.greyling@nokia.com>
Signed-off-by: Rendre Greyling <rendre.greyling@nokia.com>
6afc5e9 to
b80b9cb
Compare
Signed-off-by: Rendre Greyling <rendre.greyling@nokia.com>
Signed-off-by: Rendre Greyling <rendre.greyling@nokia.com>
Signed-off-by: Rendre Greyling <rendre.greyling@nokia.com>
932eefd to
854ca6e
Compare
There was a problem hiding this comment.
Pull request overview
Refactors the DB-cache “push drafts/proposed to Git” behavior so draft/proposed revisions are pushed during repository sync (triggered by the Repository controller), reducing repeated pushes and avoiding prior race/deletion behaviors. It also adds DB markers and expanded test coverage (unit + E2E) to validate the new sync-driven push semantics.
Changes:
- Move draft/proposed push-to-git behavior to DB repo sync, introducing
last_pushed_db_updatedto detect when DB content needs pushing. - Replace the old engine push implementation with DB-cache-specific push helpers for published and draft/proposed revisions.
- Add extensive E2E coverage for DB↔Git sync edge cases and update deployment/scripts to wire the controller flag.
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| test/e2e/suiteutils/suite.go | Adds configurable Gitea credentials/host to E2E suite initialization. |
| test/e2e/suiteutils/suite_utils.go | Adds filtered PR lookup helpers and repo sync trigger/wait helpers for tests. |
| test/e2e/suiteutils/gitea_test_utils.go | Expands Gitea test utilities (repo CRUD, branch/tag helpers, content commits). |
| test/e2e/api/db_git_sync_test.go | New E2E suite covering DB-cache sync-driven draft/proposed/published Git behavior. |
| scripts/create-deployment-blueprint.sh | Enables push-drafts-to-git flags for both porch-server and controllers. |
| pkg/externalrepo/fake/repository.go | Makes fake UpdatePackageRevision return a usable draft object. |
| pkg/externalrepo/fake/repository_test.go | Updates expectations for fake UpdatePackageRevision behavior. |
| pkg/engine/pushpr.go | Removes legacy engine push implementation. |
| pkg/cache/dbcache/util.go | Adds push state helpers, keyed locking utilities, and push marker helpers. |
| pkg/cache/dbcache/util_test.go | Adds unit tests for new util helpers. |
| pkg/cache/dbcache/dbreposync.go | Reworks cached-only handling and adds sync-time push enqueueing for draft/proposed. |
| pkg/cache/dbcache/dbreposync_test.go | Updates/extends repo-sync unit tests for new cached-only + push behavior. |
| pkg/cache/dbcache/dbrepository.go | Removes git PR cache and adds locking + task handling changes for DB repo ops. |
| pkg/cache/dbcache/dbrepository_test.go | Updates repository tests to match new DB-cache push model. |
| pkg/cache/dbcache/dbpushtogit.go | Adds DB-cache push implementation for published and draft/proposed revisions. |
| pkg/cache/dbcache/dbpushtogit_test.go | Updates tests to use the new DB-cache push functions. |
| pkg/cache/dbcache/dbpackagerevisionsql.go | Adds last_pushed_db_updated column handling + marker update helper. |
| pkg/cache/dbcache/dbpackagerevision.go | Adds push markers to dbPackageRevision and routes publish through new push logic. |
| pkg/cache/dbcache/dbpackagerevision_test.go | Updates publish flow tests for new push implementation. |
| make/deploy.mk | Adds DB_PUSH_DRAFTS_TO_GIT variable and enables it for kind v1alpha2 target. |
| deployments/porch/9-controllers.yaml | Adds controller arg for --repositories.push-drafts-to-git. |
| deployments/porch/3-porch-postgres-bundle.yaml | Adds last_pushed_db_updated column to bundled schema. |
| api/sql/porch-db.sql | Adds last_pushed_db_updated column to base DB schema. |
| api/sql/porch-db-1.6.4-1.6.0.sql | Adds downgrade migration (drop last_pushed_db_updated). |
| api/sql/porch-db-1.6.0-1.6.4.sql | Adds upgrade migration (add last_pushed_db_updated). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| func (s *repositorySync) enqueuePush(ctx context.Context, pr *dbPackageRevision) { | ||
| pushCtx := context.WithoutCancel(ctx) | ||
| go PushDraftPackageRevision(pushCtx, s.repo.Key(), pr) | ||
| } |
There was a problem hiding this comment.
Whilst this is true, the volume expected for these pushes is very low. Fix would be to put this in a worker pool and limit the number of parallel pushes introducing more cmd args.
I would prefer to hold off on this now as there is a common worker pool implementation in the works and would rather use that.
Signed-off-by: Rendre Greyling <rendre.greyling@nokia.com>
|



Description
The previous implementation of pushing draft and proposed package revisions mimicked the CR cache by pushing a draft and proposed package revision after every update. This resulted in a Package Revision being pushed at minimum 4 times from creation to Published state. Many further issues were present such as race conditions, unwanted deletions of Package Revisions and increased load on the external Git instance. The design was quite terrible and unstable - I can say this since I implemented the feature :)
This new implementation completely removes this logic and moves the push logic for draft and proposed Package Revisions to the sync process in the DB cache (which is triggered by the Repository controller).
Reasoning of this change:
Related Issue(s)
Related to: #1143
Usage
Set the
db-push-drafts-to-gitflag in the repository controller and porch-server to true.Type of Change
Checklist
AI Disclosure
composer 2.5 for UT generation and assistance with e2e tests.