chore: test update dependency#6802
Conversation
📝 WalkthroughWalkthroughRefactors shift Apply operations to use the embedded Applicator and pass raw client.Client where required. Updates finalizer and selector constructors to accept client.Client. Adjusts watch error handler to include context. Adapts controller constructor function signature. Minor test generic cleanup. No new features introduced. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Reconciler
participant Client as ClientApplicator
participant Appl as Applicator (APIPatching/Updating)
participant K8s as Kubernetes API
Reconciler->>Client: Reconcile()
note right of Reconciler: Changed: use Client.Applicator.Apply(...)
Reconciler->>Appl: Apply(obj, constraints, predicates)
alt Success
Appl->>K8s: PATCH/Apply
K8s-->>Appl: 2xx
Appl-->>Reconciler: nil
else IsNotAllowed
Appl-->>Reconciler: resource.IsNotAllowed
Reconciler-->>Reconciler: treat as no-op
else Conflict
Appl-->>Reconciler: Conflict error
Reconciler-->>Reconciler: requeue
else Other error
Appl-->>Reconciler: error
Reconciler-->>Reconciler: wrap and record event
end
note over Reconciler,K8s: Finalizer/selector constructors now accept client.Client
sequenceDiagram
autonumber
participant Engine as Engine.Start
participant CO as ControllerOptions.nc
participant KCtrl as kcontroller
participant Ctrl as Controller
Engine->>CO: nc(name, mgr, options)
note right of CO: Changed: wrapper ignores mgr
CO->>KCtrl: NewUnmanaged(name, options)
KCtrl-->>CO: Controller
CO-->>Engine: Controller
Engine->>Ctrl: Start(ctx)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Thanks for the refactor sweep—it’s cohesive and contained. Any downstream packages expected to adopt client.Client and Applicator directly next, or is this the final migration step? Pre-merge checks (3 passed, 1 inconclusive)❌ Failed checks (1 inconclusive)
✅ Passed checks (3 passed)
Pre-merge checks❌ Failed checks (1 inconclusive)
✅ Passed checks (3 passed)
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 |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
cmd/crossplane/core/core.go (1)
343-349: Fix reversed errors.Is arguments in watch error handler.errors.Is expects (err, target). Current order prevents EOF short-circuit and adds noisy logs.
Apply this diff:
- DefaultWatchErrorHandler: func(_ context.Context, _ *kcache.Reflector, err error) { - if errors.Is(io.EOF, err) { + DefaultWatchErrorHandler: func(_ context.Context, _ *kcache.Reflector, err error) { + if errors.Is(err, io.EOF) { // Watch closed normally. return } log.Debug("Watch error - probably due to CRD being uninstalled", "error", err) },
🧹 Nitpick comments (11)
cmd/crossplane/core/core.go (1)
343-349: Optionally ignore canceled/timeouts to reduce noise.Consider treating context cancellation/timeouts as benign as well.
Apply this diff after fixing the Is order:
DefaultWatchErrorHandler: func(_ context.Context, _ *kcache.Reflector, err error) { - if errors.Is(err, io.EOF) { + if errors.Is(err, io.EOF) || + errors.Is(err, context.Canceled) || + errors.Is(err, context.DeadlineExceeded) { // Watch ended normally or context done. return } log.Debug("Watch error - probably due to CRD being uninstalled", "error", err) },internal/controller/pkg/revision/reconciler.go (1)
122-128: Naming nit: option sets only the client, not the applicator.WithClientApplicator(ca) now assigns only ca.Client. That matches current usage (this reconciler never calls Apply), but the name can mislead tests/callers expecting Applicator injection.
Would you like a follow-up to add a new WithClient option and deprecate WithClientApplicator here for clarity?
internal/controller/pkg/runtime/runtime_function.go (3)
93-95: Add MustBeControllableBy to avoid adopting foreign ServicesDefensive guard to ensure we only mutate Services we control; aligns with other controllers.
- if err := h.client.Applicator.Apply(ctx, svc); err != nil { + if err := h.client.Applicator.Apply(ctx, svc, resource.MustBeControllableBy(pr.GetUID())); err != nil {Quick check: does build.Service already set OwnerReferences? If yes, this is belt-and-braces. Thanks!
106-108: Likewise guard Secret apply with MustBeControllableByConsistent ownership check on the TLS Secret.
- if err := h.client.Applicator.Apply(ctx, secServer); err != nil { + if err := h.client.Applicator.Apply(ctx, secServer, resource.MustBeControllableBy(pr.GetUID())); err != nil {
145-147: Guard Deployment apply with MustBeControllableByPrevents updating Deployments not controlled by this revision.
- if err := h.client.Applicator.Apply(ctx, d); err != nil { + if err := h.client.Applicator.Apply(ctx, d, resource.MustBeControllableBy(pr.GetUID())); err != nil {internal/engine/engine.go (1)
304-306: Small doc nit: clarify ignored mgr param in wrapperFuture readers may wonder why mgr is unused here after the API change.
- co := &ControllerOptions{nc: func(name string, mgr manager.Manager, options kcontroller.Options) (kcontroller.Controller, error) { + // controller-runtime >= v0.22: NewUnmanaged no longer requires a manager; mgr is intentionally ignored. + co := &ControllerOptions{nc: func(name string, mgr manager.Manager, options kcontroller.Options) (kcontroller.Controller, error) {internal/controller/pkg/runtime/runtime_provider.go (5)
89-91: Add MustBeControllableBy for Service applyAvoids mutating Services not owned by the ProviderRevision.
- if err := h.client.Applicator.Apply(ctx, svc); err != nil { + if err := h.client.Applicator.Apply(ctx, svc, resource.MustBeControllableBy(pr.GetUID())); err != nil {
102-105: Guard TLS client Secret apply with MustBeControllableBy- if err := h.client.Applicator.Apply(ctx, secClient); err != nil { + if err := h.client.Applicator.Apply(ctx, secClient, resource.MustBeControllableBy(pr.GetUID())); err != nil {
106-108: Guard TLS server Secret apply with MustBeControllableBy- if err := h.client.Applicator.Apply(ctx, secServer); err != nil { + if err := h.client.Applicator.Apply(ctx, secServer, resource.MustBeControllableBy(pr.GetUID())); err != nil {
146-148: Add MustBeControllableBy for Deployment applyConsistency with CRD/other apply sites and safer ownership semantics.
- if err := h.client.Applicator.Apply(ctx, d); err != nil { + if err := h.client.Applicator.Apply(ctx, d, resource.MustBeControllableBy(pr.GetUID())); err != nil {
288-289: Consider guarding ServiceAccount apply with MustBeControllableByIf SA is internally managed, add an ownership guard to avoid updates to external SAs. This would require threading the owner UID into applySA.
Would you like a small follow-up that refactors applySA to accept the owner UID and applies:
- func applySA(ctx context.Context, cl resource.ClientApplicator, sa *corev1.ServiceAccount) error { + func applySA(ctx context.Context, cl resource.ClientApplicator, ownerUID types.UID, sa *corev1.ServiceAccount) error { ... - return cl.Applicator.Apply(ctx, sa) + return cl.Applicator.Apply(ctx, sa, resource.MustBeControllableBy(ownerUID)) }and call with:
- if err := applySA(ctx, h.client, sa); err != nil { + if err := applySA(ctx, h.client, pr.GetUID(), sa); err != nil {
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
go.modis excluded by none and included by nonego.sumis excluded by!**/*.sumand included by none
📒 Files selected for processing (15)
cmd/crank/beta/validate/validate_test.go(3 hunks)cmd/crossplane/core/core.go(1 hunks)internal/controller/apiextensions/claim/connection.go(1 hunks)internal/controller/apiextensions/claim/syncer_csa.go(1 hunks)internal/controller/apiextensions/composite/reconciler.go(1 hunks)internal/controller/apiextensions/definition/reconciler.go(3 hunks)internal/controller/apiextensions/offered/reconciler.go(2 hunks)internal/controller/pkg/manager/reconciler.go(2 hunks)internal/controller/pkg/revision/reconciler.go(1 hunks)internal/controller/pkg/runtime/runtime_function.go(3 hunks)internal/controller/pkg/runtime/runtime_provider.go(4 hunks)internal/controller/rbac/definition/reconciler.go(1 hunks)internal/controller/rbac/provider/binding/reconciler.go(1 hunks)internal/controller/rbac/provider/roles/reconciler.go(1 hunks)internal/engine/engine.go(1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.go
⚙️ CodeRabbit configuration file
**/*.go: Enforce Crossplane-specific patterns: Use crossplane-runtime/pkg/errors
for wrapping. Check variable naming (short for local scope, descriptive
for wider scope). Ensure 'return early' pattern. Verify error scoping
(declare in conditionals when possible). For nolint directives, require
specific linter names and explanations. CRITICAL: Ensure all error
messages are meaningful to end users, not just developers - avoid
technical jargon, include context about what the user was trying to do,
and suggest next steps when possible.
Files:
internal/controller/rbac/provider/roles/reconciler.gointernal/controller/rbac/definition/reconciler.gointernal/controller/pkg/runtime/runtime_provider.gointernal/controller/rbac/provider/binding/reconciler.gointernal/controller/apiextensions/claim/connection.gocmd/crank/beta/validate/validate_test.gointernal/controller/pkg/revision/reconciler.gointernal/controller/apiextensions/claim/syncer_csa.gointernal/controller/apiextensions/composite/reconciler.gointernal/engine/engine.gocmd/crossplane/core/core.gointernal/controller/pkg/manager/reconciler.gointernal/controller/apiextensions/offered/reconciler.gointernal/controller/apiextensions/definition/reconciler.gointernal/controller/pkg/runtime/runtime_function.go
**/internal/controller/**
⚙️ CodeRabbit configuration file
**/internal/controller/**: Review controller logic for proper reconciliation patterns, error
handling, and resource management. Pay special attention to conditions
and events: Conditions must be actionable for users (not developers),
stable/deterministic, with proper Type/Reason/Message format. Events
only when something actually happens, with specific details about what
changed. No transient errors in conditions/events. All error messages
must be meaningful to end users - include context about what
resource/operation failed and why.
Files:
internal/controller/rbac/provider/roles/reconciler.gointernal/controller/rbac/definition/reconciler.gointernal/controller/pkg/runtime/runtime_provider.gointernal/controller/rbac/provider/binding/reconciler.gointernal/controller/apiextensions/claim/connection.gointernal/controller/pkg/revision/reconciler.gointernal/controller/apiextensions/claim/syncer_csa.gointernal/controller/apiextensions/composite/reconciler.gointernal/controller/pkg/manager/reconciler.gointernal/controller/apiextensions/offered/reconciler.gointernal/controller/apiextensions/definition/reconciler.gointernal/controller/pkg/runtime/runtime_function.go
**/*_test.go
⚙️ CodeRabbit configuration file
**/*_test.go: Enforce table-driven test structure: PascalCase test names (no
underscores), args/want pattern, use cmp.Diff with
cmpopts.EquateErrors() for error testing. Check for proper test case
naming and reason fields. Ensure no third-party test frameworks (no
Ginkgo, Gomega, Testify).
Files:
cmd/crank/beta/validate/validate_test.go
**/cmd/**
⚙️ CodeRabbit configuration file
**/cmd/**: Review CLI commands for proper flag handling, help text, and error
messages. Ensure commands follow Crossplane CLI conventions. Ask about
backward compatibility and user experience. CLI error messages must be
especially user-friendly - avoid internal error details, provide
actionable guidance.
Files:
cmd/crank/beta/validate/validate_test.gocmd/crossplane/core/core.go
🧬 Code graph analysis (7)
internal/controller/pkg/runtime/runtime_provider.go (1)
internal/initializer/tls.go (6)
NewTLSCertificateGenerator(108-121)RootCACertSecretName(53-53)TLSCertificateGeneratorWithOwner(85-89)TLSCertificateGeneratorWithServerSecretName(92-97)DNSNamesForService(379-385)TLSCertificateGeneratorWithClientSecretName(100-105)
internal/controller/pkg/revision/reconciler.go (4)
internal/controller/apiextensions/claim/reconciler.go (1)
client(179-197)internal/controller/pkg/resolver/reconciler.go (1)
client(145-156)internal/controller/apiextensions/composition/reconciler.go (1)
client(115-120)internal/controller/apiextensions/claim/reconciler_test.go (1)
client(47-52)
internal/controller/apiextensions/composite/reconciler.go (1)
internal/controller/apiextensions/composite/api.go (1)
NewAPIRevisionFetcher(150-152)
internal/engine/engine.go (1)
internal/controller/apiextensions/controller/options.go (1)
Options(28-36)
internal/controller/apiextensions/offered/reconciler.go (2)
internal/controller/apiextensions/claim/reconciler.go (2)
Finalizer(211-213)client(179-197)internal/controller/pkg/resolver/reconciler.go (1)
client(145-156)
internal/controller/apiextensions/definition/reconciler.go (2)
internal/controller/apiextensions/composite/api.go (1)
NewEnforcedCompositionSelector(330-332)internal/controller/apiextensions/composition/reconciler.go (2)
r(123-235)client(115-120)
internal/controller/pkg/runtime/runtime_function.go (1)
internal/initializer/tls.go (5)
NewTLSCertificateGenerator(108-121)RootCACertSecretName(53-53)TLSCertificateGeneratorWithServerSecretName(92-97)DNSNamesForService(379-385)TLSCertificateGeneratorWithOwner(85-89)
🔍 Remote MCP
.
This context validates that the PR addresses legitimate API compatibility requirements introduced by the controller-runtime upgrade, with the changes following expected migration patterns for such substantial version jumps.
🔇 Additional comments (16)
cmd/crank/beta/validate/validate_test.go (1)
277-279: Nice cleanup: rely on type inference for ptr.To(true).Using ptr.To(true) here is correct and idiomatic; keeping explicit ptr.Toint64 where needed for JSONSchemaProps MaxLength is also right.
Also applies to: 585-587, 831-832
internal/controller/rbac/provider/roles/reconciler.go (1)
286-290: Apply via embedded Applicator is correct.Routing through r.client.Applicator.Apply aligns with the injected APIUpdatingApplicator in NewReconciler; semantics unchanged.
internal/controller/apiextensions/claim/syncer_csa.go (1)
165-168: LGTM: switched to Applicator.Apply.Keeps AllowUpdateIf logic and existing error handling intact.
internal/controller/apiextensions/claim/connection.go (1)
83-92: LGTM: use Applicator.Apply for secret propagation.Predicate with cmpopts.EquateEmpty avoids no-op updates; IsNotAllowed path handled.
internal/controller/rbac/definition/reconciler.go (1)
189-193: LGTM: apply through Applicator for RBAC roles.Consistent with the controller’s ClientApplicator wiring and other RBAC controllers.
internal/controller/pkg/manager/reconciler.go (2)
485-495: LGTM: deactivate old revisions via Applicator.Apply.Matches APIPatchingApplicator semantics and existing conflict handling.
561-570: LGTM: create/update target revision via Applicator.Apply.OwnerRef + MustBeControllableBy preserved; error wrapping and events unchanged.
internal/controller/pkg/runtime/runtime_function.go (1)
112-113: LGTM: pass raw client to TLS generatorUsing h.client.Client matches the updated initializer.Run API.
internal/controller/rbac/provider/binding/reconciler.go (1)
223-223: LGTM: move to Applicator.ApplyMatches repo-wide migration and preserves AllowUpdateIf semantics.
internal/controller/pkg/runtime/runtime_provider.go (1)
113-115: LGTM: pass raw client to TLS generatorConsistent with initializer.Run expectations.
internal/controller/apiextensions/composite/reconciler.go (1)
431-432: LGTM: pass cached client directly to NewAPIRevisionFetcherMatches the updated constructor and reduces wrapper churn.
internal/controller/apiextensions/offered/reconciler.go (2)
225-225: LGTM: NewAPIFinalizer now uses client.ClientConstructor usage aligns with new signature.
435-436: LGTM: switch to Applicator.Apply for CRDConsistent with repo-wide Apply path and enables StoreCurrentRV usage above.
internal/controller/apiextensions/definition/reconciler.go (3)
261-261: LGTM: pass ca.Client to NewAPIFinalizerTracks the updated API surface.
474-474: LGTM: Applicator.Apply for CRDKeeps Apply semantics consistent and supports RV tracking.
535-538: LGTM: NewEnforcedCompositionSelector now takes client.ClientConstructor usage looks correct.
|
Crossplane does not currently have enough maintainers to address every issue and pull request. This pull request has been automatically marked as |
Description of your changes
This PR updates controller-runtime from v0.19.0 to v0.22.1 and integrates the updated crossplane-runtime from the fix/update-controller-runtime branch to maintain compatibility.
Changes made:
• Updated sigs.k8s.io/controller-runtime to v0.22.1 (latest version)
• Added replace directive to use updated crossplane-runtime fork, has to be removed ...
• Fixed API compatibility issues:
• Updated NewUnmanaged function wrapper for new signature
• Resolved ambiguous Apply method calls by using Applicator.Apply
• Fixed WatchErrorHandler signature to include context parameter
• Updated client interface usage throughout codebase
• Removed unnecessary type arguments in test files (linter warnings)
Testing:
• All builds pass successfully
• Unit tests pass (only 2 unrelated test failures remain)
• No breaking changes to public APIs
I have:
• [ ] Read and followed Crossplane's [contribution process].
• [ ] Run earthly +reviewable to ensure this PR is ready for review.
• [ ]
Added or updated unit tests.(No new functionality added)• [ ]
Added or updated e2e tests.(No new functionality added)• [ ]
Linked a PR or a [docs tracking issue] to [document this change].(Internal dependency update)• [ ]
Added backport release-x.y labels to auto-backport this PR.(Draft PR)• [ ]
Followed the [API promotion workflow] if this PR introduces, removes, or promotes an API.(No API changes)