Push all GW origin artifacts to CP on connection#2757
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (19)
📝 WalkthroughWalkthroughChangesArtifact reconciliation
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Gateway
participant ControlPlaneSync
participant ArtifactStorage
participant ArtifactImporter
participant DeploymentRepository
Gateway->>ControlPlaneSync: Reconnect and start full reconciliation
ControlPlaneSync->>ArtifactStorage: Get all gateway-originated artifacts
ArtifactStorage-->>ControlPlaneSync: Artifact metadata
ControlPlaneSync->>ArtifactImporter: Import artifact with deploymentRevision
ArtifactImporter->>DeploymentRepository: Read latest gateway-scoped revision
DeploymentRepository-->>ArtifactImporter: Stored revision
ArtifactImporter->>ArtifactImporter: Skip duplicate or create deployment
Suggested reviewers: 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain modules listed in go.work or their selected dependencies" 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 |
Purpose
When a gateway reconnects to a different control plane, to a control plane whose database was purged/restored, or re-registers as a different gateway, the AI artifacts it created (REST APIs, LLM Providers, LLM Provider Templates, LLM Proxies, MCP Proxies) were never re-synced. Once an artifact had synced successfully its
cp_sync_statuslatched to success, and the reconnect push only ever offered pending/failed artifacts — so the new/empty control plane never received them. The gateway keeps no record of which control plane it synced to, so "success" effectively meant "synced once, to someone."This PR makes the gateway repopulate any control plane it connects to, while keeping already-synced control planes free of duplicate deployments.
Approach
The revision is stored as a string in metadata, so it round-trips exactly regardless of timestamp column precision across SQLite/PostgreSQL/SQL Server.
Changes
Gateway (data plane)
Control plane (platform-api)