feat: add support for safe start#391
Draft
fernandezcuesta wants to merge 3 commits into
Draft
Conversation
Signed-off-by: Jesús Fernández <7312236+fernandezcuesta@users.noreply.github.com>
e7e1d21 to
0245e0b
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds “safe-start” support to provider-sql by introducing a common, gated controller setup helper and refactoring all managed resource controllers to register their setup behind a CRD-availability gate, deferring controller creation until the corresponding CRDs exist.
Changes:
- Introduces
pkg/controller/setup.Setupto centralize managed reconciler/controller creation behindo.Gate.Register. - Refactors all cluster and namespaced SQL controllers to use the new gated setup helper.
- Wires up the CRD gate in
cmd/provider/main.goand declares thesafe-startcapability in the package metadata.
Reviewed changes
Copilot reviewed 28 out of 28 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/controller/setup/setup.go | Adds a shared gated controller setup helper used by all managed controllers. |
| pkg/controller/namespaced/postgresql/schema/reconciler.go | Switches Schema controller setup to the shared gated setup helper. |
| pkg/controller/namespaced/postgresql/role/reconciler.go | Switches Role controller setup to the shared gated setup helper. |
| pkg/controller/namespaced/postgresql/grant/reconciler.go | Switches Grant controller setup to the shared gated setup helper. |
| pkg/controller/namespaced/postgresql/extension/reconciler.go | Switches Extension controller setup to the shared gated setup helper. |
| pkg/controller/namespaced/postgresql/default_privileges/reconciler.go | Switches DefaultPrivileges controller setup to the shared gated setup helper. |
| pkg/controller/namespaced/postgresql/database/reconciler.go | Switches Database controller setup to the shared gated setup helper. |
| pkg/controller/namespaced/mysql/user/reconciler.go | Switches User controller setup to the shared gated setup helper. |
| pkg/controller/namespaced/mysql/grant/reconciler.go | Switches Grant controller setup to the shared gated setup helper. |
| pkg/controller/namespaced/mysql/database/reconciler.go | Switches Database controller setup to the shared gated setup helper. |
| pkg/controller/namespaced/mssql/user/reconciler.go | Switches User controller setup to the shared gated setup helper. |
| pkg/controller/namespaced/mssql/grant/reconciler.go | Switches Grant controller setup to the shared gated setup helper. |
| pkg/controller/namespaced/mssql/database/reconciler.go | Switches Database controller setup to the shared gated setup helper. |
| pkg/controller/cluster/postgresql/schema/reconciler.go | Switches Schema controller setup to the shared gated setup helper. |
| pkg/controller/cluster/postgresql/role/reconciler.go | Switches Role controller setup to the shared gated setup helper. |
| pkg/controller/cluster/postgresql/grant/reconciler.go | Switches Grant controller setup to the shared gated setup helper. |
| pkg/controller/cluster/postgresql/extension/reconciler.go | Switches Extension controller setup to the shared gated setup helper. |
| pkg/controller/cluster/postgresql/default_privileges/reconciler.go | Switches DefaultPrivileges controller setup to the shared gated setup helper. |
| pkg/controller/cluster/postgresql/database/reconciler.go | Switches Database controller setup to the shared gated setup helper. |
| pkg/controller/cluster/mysql/user/reconciler.go | Switches User controller setup to the shared gated setup helper. |
| pkg/controller/cluster/mysql/grant/reconciler.go | Switches Grant controller setup to the shared gated setup helper. |
| pkg/controller/cluster/mysql/database/reconciler.go | Switches Database controller setup to the shared gated setup helper. |
| pkg/controller/cluster/mssql/user/reconciler.go | Switches User controller setup to the shared gated setup helper. |
| pkg/controller/cluster/mssql/grant/reconciler.go | Switches Grant controller setup to the shared gated setup helper. |
| pkg/controller/cluster/mssql/database/reconciler.go | Switches Database controller setup to the shared gated setup helper. |
| package/crossplane.yaml | Declares the provider’s safe-start capability. |
| go.mod | Promotes k8s.io/apiextensions-apiserver to a direct dependency for CRD gating types. |
| cmd/provider/main.go | Initializes the GVK gate, adds CRD types to scheme, and sets up the CRD gate controller. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+46
to
+48
| func Setup(mgr ctrl.Manager, o xpcontroller.Options, cfg ControllerConfig) error { | ||
| o.Gate.Register(func() { | ||
| name := managed.ControllerName(cfg.GVK.GroupKind().String()) |
Collaborator
Author
|
Duplicate of #287 |
Signed-off-by: Jesús Fernández <7312236+fernandezcuesta@users.noreply.github.com>
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.
Add safe start support for provider-sql by wrapping the Setup method into a gated setup, now common to all
Setups.Fix: #390