refactor: Pass a PassiveClock to operation controllers#5393
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors backend operation controllers and shared operation-controller utilities to accept a k8s.io/utils/clock.PassiveClock from the caller, allowing controller code to avoid relying on a package-level real clock and improving consistency/injectability.
Changes:
- Updated operation-controller helper functions (
UpdateOperationStatus,patchOperation, polling helpers, delete completion helper) to accept aPassiveClockand use it for transition timestamps. - Updated operation controllers (cluster/nodepool/externalauth/credential controllers and dispatchers) to store and pass a
PassiveClockvia their constructors. - Updated backend wiring and integration/test helpers to pass a real clock instance where needed.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test-integration/utils/integrationutils/utils.go | Updates integration helper to call UpdateOperationStatus with a real clock. |
| backend/pkg/controllers/operationcontrollers/utils.go | Removes local clock usage and threads PassiveClock through status/update helpers. |
| backend/pkg/controllers/operationcontrollers/operation_revoke_credentials.go | Adds a PassiveClock field and threads it into patchOperation. |
| backend/pkg/controllers/operationcontrollers/operation_revoke_credentials_test.go | Wires a real clock into the controller under test. |
| backend/pkg/controllers/operationcontrollers/operation_request_credential.go | Adds a PassiveClock field and threads it into patchOperation. |
| backend/pkg/controllers/operationcontrollers/operation_request_credential_test.go | Wires a real clock into the controller under test. |
| backend/pkg/controllers/operationcontrollers/operation_node_pool_update.go | Adds a PassiveClock field and passes it into nodepool polling helper. |
| backend/pkg/controllers/operationcontrollers/operation_node_pool_update_test.go | Wires a real clock into the controller under test. |
| backend/pkg/controllers/operationcontrollers/operation_node_pool_delete.go | Adds a PassiveClock field and threads it into status/delete helpers. |
| backend/pkg/controllers/operationcontrollers/operation_node_pool_delete_test.go | Wires a real clock into the controller under test. |
| backend/pkg/controllers/operationcontrollers/operation_node_pool_create.go | Adds a PassiveClock field and passes it into nodepool polling helper. |
| backend/pkg/controllers/operationcontrollers/operation_node_pool_create_test.go | Wires a real clock into the controller under test. |
| backend/pkg/controllers/operationcontrollers/operation_external_auth_update.go | Adds a PassiveClock field and passes it into externalauth polling helper. |
| backend/pkg/controllers/operationcontrollers/operation_external_auth_update_test.go | Wires a real clock into the controller under test. |
| backend/pkg/controllers/operationcontrollers/operation_external_auth_delete.go | Adds a PassiveClock field and threads it into delete completion helper. |
| backend/pkg/controllers/operationcontrollers/operation_external_auth_delete_test.go | Wires a real clock into the controller under test. |
| backend/pkg/controllers/operationcontrollers/operation_external_auth_create.go | Adds a PassiveClock field and passes it into externalauth polling helper. |
| backend/pkg/controllers/operationcontrollers/operation_external_auth_create_test.go | Wires a real clock into the controller under test. |
| backend/pkg/controllers/operationcontrollers/operation_cluster_update.go | Accepts/injects PassiveClock and uses it when updating operation status. |
| backend/pkg/controllers/operationcontrollers/operation_cluster_delete.go | Accepts/injects PassiveClock and uses it for billing deletion timestamps and op updates. |
| backend/pkg/controllers/operationcontrollers/operation_cluster_create.go | Accepts/injects PassiveClock and uses it when updating operation status. |
| backend/pkg/controllers/operationcontrollers/operation_cluster_create_test.go | Wires a real clock into the controller under test. |
| backend/pkg/app/backend.go | Threads a backend-level PassiveClock into controller construction. |
This allows the RealClock instance in utils.go to be dropped since all the operation controllers now possess a PassiveClock interface to pass to utility functions.
a3d57e2 to
efee20c
Compare
|
/lgtm |
|
This makes some nice test improvement options. /approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: deads2k, mbarnes, tmstff The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Supersedes #5062 since we changed our forking policy.
What
Light refactoring for controller consistency.
Why
This allows the RealClock instance in utils.go to be dropped since all the operation controllers now possess a
PassiveClockinterface to pass to utility functions.Testing
Existing unit and integration tests should suffice.
PR Checklist