-
Notifications
You must be signed in to change notification settings - Fork 32
Refactor experiments #392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Refactor experiments #392
Conversation
- Extract findWorkerListObjects to return ObjectMeta instead of full objects - Create generic createRequestsFromObjectUpdates helper function - Add requestsForObjectUpdates method for cleaner watch setup - Refactor existing findObjectsForSrc to use new helper - Add comprehensive godoc comments to all new functions - Add TODO/NOTE comments for future validation and enhancement work This reduces code duplication and improves memory efficiency by only keeping ObjectMeta for reconcile requests. The pattern can be extended to other controllers in the operator.
This change introduces a new shared helper pattern for all controllers to reduce code duplication and improve maintainability. A new watch_helpers.go file provides a generic CreateRequestsFromObjectUpdates function that encapsulates the common pattern used across all seven designate controllers when handling watched resource updates. Each controller now implements a lightweight findXXXListObjects function specific to its type and a requestsForObjectUpdates method that leverages the shared helper. This approach returns only ObjectMeta instead of full objects, improving memory efficiency. The old findObjectsForSrc methods have been completely removed across all controllers, eliminating 222 lines of duplicated code. All watch handlers now consistently use the new requestsForObjectUpdates method, providing a uniform pattern that's easier to understand, maintain, and extend. The refactoring covers DesignateAPI (with TLS field support), DesignateCentral, DesignateProducer, DesignateMdns, DesignateBackendbind9, DesignateUnbound, and DesignateWorker controllers. This is purely a refactoring change with no functional differences. All controllers pass fmt, vet, and linter checks. The net result is 38 fewer lines of code with significantly improved consistency and maintainability that can serve as a template for other operators in the openstack-k8s-operators ecosystem. Co-authored-by: Cursor <[email protected]>
|
Skipping CI for Draft Pull Request. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: beagles The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/test all |
- Add watch_helpers_test.go with 16 test cases (Ginkgo + traditional Go) - Cover all scenarios: success, edge, real-world usage, and error handling - Achieve 88.9% code coverage for watch_helpers.go - Include test documentation and summaries in README_WATCH_HELPERS_TESTS.md, WATCH_HELPERS_TESTS.md, and TESTING_SUMMARY.md Co-authored-by: Cursor AI <[email protected]>
c1c46ee to
8f2bb6c
Compare
|
/test all |
|
@beagles: The following tests failed, say
Full PR test history. Your PR dashboard. Instructions 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. I understand the commands that are listed here. |
No description provided.