-
Notifications
You must be signed in to change notification settings - Fork 139
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Summary
Currently, when ApplicationDefinition resources change, cozystack-controller triggers a full restart of the cozystack-api pod by patching the pod template annotation. This causes:
- Race condition at startup — if CRD doesn't exist yet, apiserver waits up to 30 minutes
- Downtime — full process restart on every CRD change
- External dependency — relies on controller to manage apiserver lifecycle
Proposal
Implement hot reload inside apiserver following the pattern from apiextensions-apiserver:
- apiserver watches
ApplicationDefinitiondirectly via controller-runtime informer - On changes, atomically updates REST handlers using
atomic.Value - Updates OpenAPI schema dynamically via
OpenAPIVersionedService.UpdateSpec() - No process restart required
Implementation outline
- Create
DynamicResourceHandlerwith atomic storage for REST handlers - Create
HotReloadControllerthat watches CRD and computes diffs - Remove blocking retry loop in
Complete()— start with empty config - Remove restart logic from
cozystackresource_controller.go
Benefits
- Zero downtime on CRD changes
- Faster startup (no waiting for CRD)
- Simpler architecture (no external restart trigger)
- Better resilience
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request