Skip to content

fix(controlplane): enforce cache-invalidating project repo and wire bootstrap licenser#2704

Merged
mekilis merged 1 commit into
mainfrom
oksmart/project-cache-invalidation-and-bootstrap-fix
Jul 7, 2026
Merged

fix(controlplane): enforce cache-invalidating project repo and wire bootstrap licenser#2704
mekilis merged 1 commit into
mainfrom
oksmart/project-cache-invalidation-and-bootstrap-fix

Conversation

@mekilis

@mekilis mekilis commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Wires the API layer's ProjectRepo through a single cached repository (ensureAPIRepositories) so every write path invalidates the projects:<id> cache key. Previously several handlers built their own uncached repo via projects.New(...), so project config updates made through the API were served stale for up to the cache TTL. All handler call sites (project.go, organisation.go, endpoint.go, security.go, subscription.go, ingest.go) now consume the shared repo via h.projectRepo(), and cmd/utils/circuit_breakers.go wraps its repo in the same cache when available. Introduced cached.DefaultProjectTTL so the API and dataplane worker share one TTL constant.
  • Fixes a nil-pointer panic in convoy bootstrap: the command constructed CreateOrganisationService without the Licenser, so organisation creation crashed. The licenser is now passed through, and the service guards against a nil licenser with a clear error instead of panicking.

Test plan

  • go build ./...
  • Unit tests for api, api/handlers, services, datastore/cached pass, including new tests: cached-vs-plain repo wiring in ensureAPIRepositories, shared repo usage in createProjectService, and nil-licenser error in CreateOrganisationService
  • go vet and golangci-lint clean on touched packages

Note

Medium Risk
Touches many API write/read paths and project config caching; incorrect wiring could still serve stale config, but changes are narrowly scoped to repo injection and invalidation.

Overview
Fixes stale project config when the API or dataplane read projects:<id> from cache: startup now wraps ProjectRepo in CachedProjectRepository when a cache exists, and handlers/ingest/CLI paths stop building uncached projects.New(...) repos and use the shared wired instance (h.projectRepo() or a.A.ProjectRepo) so updates invalidate the cache key. Adds cached.DefaultProjectTTL (5m) for API wiring, dataplane worker, and the circuit-breakers CLI.

Also fixes convoy bootstrap: passes Licenser into CreateOrganisationService and returns a clear error if Licenser is nil instead of panicking on org limit checks.

Regression tests cover cached vs plain repo wiring, createProjectService repo reuse, and nil licenser behavior.

Reviewed by Cursor Bugbot for commit 5a10d25. Bugbot is set up for automated code reviews on this repo. Configure here.

…ootstrap licenser

wire the api layer's ProjectRepo through a single cached repository so
every write path invalidates the projects:<id> cache key. previously
several handlers constructed their own uncached repo, so config updates
via the api were served stale for up to the cache ttl.

also pass the licenser into CreateOrganisationService from the bootstrap
command; it was omitted and caused a nil-pointer panic on convoy
bootstrap, and guard the service against a nil licenser with a clear
error.
@mekilis mekilis merged commit 5c771be into main Jul 7, 2026
35 checks passed
@mekilis mekilis deleted the oksmart/project-cache-invalidation-and-bootstrap-fix branch July 7, 2026 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant