backend: Pass a PassiveClock to operation controllers#5062
Conversation
4a7a048 to
752d59a
Compare
There was a problem hiding this comment.
Pull request overview
This PR refactors backend operation controllers to consistently use an injected k8s.io/utils/clock.PassiveClock for timestamps, removing the need for a package-level RealClock in operationcontrollers/utils.go and improving testability/consistency.
Changes:
- Plumb a
PassiveClockthrough operation controller constructors and store it on controller structs. - Update shared operation controller utilities (
UpdateOperationStatus,patchOperation, polling helpers, delete completion) to accept/use the injected clock instead of a global clock. - Update backend wiring and integration/test callsites to pass a real clock where needed.
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| test-integration/utils/integrationutils/utils.go | Passes RealClock{} into UpdateOperationStatus after signature change. |
| backend/pkg/controllers/operationcontrollers/utils.go | Removes global clock and threads PassiveClock through status update / patch / poll / delete helpers. |
| backend/pkg/controllers/operationcontrollers/operation_revoke_credentials_test.go | Sets controller clock in unit test fixture. |
| backend/pkg/controllers/operationcontrollers/operation_revoke_credentials.go | Adds clock field + constructor param; uses it when patching operation status. |
| backend/pkg/controllers/operationcontrollers/operation_request_credential_test.go | Sets controller clock in unit test fixture. |
| backend/pkg/controllers/operationcontrollers/operation_request_credential.go | Adds clock field + constructor param; uses it when patching operation status. |
| backend/pkg/controllers/operationcontrollers/operation_node_pool_update_test.go | Sets controller clock in unit test fixture. |
| backend/pkg/controllers/operationcontrollers/operation_node_pool_update.go | Adds clock field + constructor param; passes clock into polling helper. |
| backend/pkg/controllers/operationcontrollers/operation_node_pool_delete_test.go | Sets controller clock in unit test fixture. |
| backend/pkg/controllers/operationcontrollers/operation_node_pool_delete.go | Adds clock field + constructor param; uses it for delete completion + status updates. |
| backend/pkg/controllers/operationcontrollers/operation_node_pool_create_test.go | Sets controller clock in unit test fixture. |
| backend/pkg/controllers/operationcontrollers/operation_node_pool_create.go | Adds clock field + constructor param; passes clock into polling helper. |
| backend/pkg/controllers/operationcontrollers/operation_external_auth_update_test.go | Sets controller clock in unit test fixture. |
| backend/pkg/controllers/operationcontrollers/operation_external_auth_update.go | Adds clock field + constructor param; passes clock into polling helper. |
| backend/pkg/controllers/operationcontrollers/operation_external_auth_delete_test.go | Sets controller clock in unit test fixture. |
| backend/pkg/controllers/operationcontrollers/operation_external_auth_delete.go | Adds clock field + constructor param; uses it for delete completion. |
| backend/pkg/controllers/operationcontrollers/operation_external_auth_create_test.go | Sets controller clock in unit test fixture. |
| backend/pkg/controllers/operationcontrollers/operation_external_auth_create.go | Adds clock field + constructor param; passes clock into polling helper. |
| backend/pkg/controllers/operationcontrollers/operation_cluster_update_test.go | Sets controller clock in unit test fixture. |
| backend/pkg/controllers/operationcontrollers/operation_cluster_update.go | Adds clock field + constructor param; uses it for operation status updates. |
| backend/pkg/controllers/operationcontrollers/operation_cluster_delete.go | Updates constructor to accept clock; uses it for billing deletion timestamp + delete completion + status updates. |
| backend/pkg/controllers/operationcontrollers/operation_cluster_create_test.go | Sets controller clock in unit test fixture. |
| backend/pkg/controllers/operationcontrollers/operation_cluster_create.go | Adds clock field + constructor param; uses it for operation status updates. |
| backend/pkg/app/backend.go | Introduces a backend-level PassiveClock and passes it into controller constructors (instead of instantiating RealClock{} per call). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
/retest |
|
/lgtm |
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.
752d59a to
2ccddc0
Compare
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mbarnes, tmstff The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
PR needs rebase. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
Moving these changes to #5393 since our forking policy changed and there's too many merge conflicts here. |
What
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.Why
Light refactoring for controller consistency.
Testing
Existing unit and integration tests should suffice.