Skip to content

Conversation

@beagles
Copy link
Collaborator

@beagles beagles commented Oct 14, 2025

No description provided.

beagles and others added 3 commits October 13, 2025 19:09
- 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]>
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 14, 2025

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 14, 2025

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@beagles
Copy link
Collaborator Author

beagles commented Oct 14, 2025

/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]>
@beagles beagles force-pushed the refactor-experiments branch from c1c46ee to 8f2bb6c Compare October 14, 2025 15:50
@beagles
Copy link
Collaborator Author

beagles commented Oct 14, 2025

/test all

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 14, 2025

@beagles: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/functional 8f2bb6c link true /test functional
ci/prow/precommit-check 8f2bb6c link true /test precommit-check

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant