Skip to content

refactor(crd): replace raw REST client with controller-runtime client#6176

Open
ivankatliarchuk wants to merge 1 commit intokubernetes-sigs:masterfrom
gofogo:chore-crd-source-refresh
Open

refactor(crd): replace raw REST client with controller-runtime client#6176
ivankatliarchuk wants to merge 1 commit intokubernetes-sigs:masterfrom
gofogo:chore-crd-source-refresh

Conversation

@ivankatliarchuk
Copy link
Member

@ivankatliarchuk ivankatliarchuk commented Feb 8, 2026

What does it do ?

  • replaced rest.Interface with client.Client + cache.Cache, deleted NewCRDClientForAPIVersionKind, List, watch, UpdateStatus, as supported by runtime interface out of the box
  • rewrote buildCRDSource to create cache-backed controller-runtime client scoped to DNSEndpoint
  • Added Indexing - Pre-filter objects when indexed, O(1) lookup
  • replaced fake.RESTClient + HTTP mocking with fake.NewClientBuilder()

Motivation

Controller-runtime client provides all required functionality. Rest approach is very custom

Problems with REST Client Approach

  • Client-Side Filtering - Fetched everything, filtered in memory
  • Manual REST Construction - String-based resource names, error-prone, hard to add features
  • No Caching - Every sync made full API calls (every 1 minute)
  • Complex Setup - 40+ lines just to create a REST client
  • Manual Goroutine Management - Easy to leak resources

Controller-Runtime Approach

  • Built-in Caching - Zero API calls during Endpoints(), ~99% load reduction
  • Type-Safe Client - &apiv1alpha1.DNSEndpoint{} vs string "dnsendpoints"
  • Server-Side Filtering - Label/namespace filters applied at cache level
  • Indexing - Pre-filter objects when indexed, O(1) lookup
  • Managed Lifecycle - Context-based shutdown, no goroutine leaks

Relates

  1. CRD Source Status field is lacking  #2092
  2. Defining a path to Beta for DNSEndpoint API #5243
  3. Add Record Creation Status to Source Object #6030

More

  • Yes, this PR title follows Conventional Commits
  • Yes, I added unit tests
  • Yes, I updated end user documentation accordingly
┌──────────┬───────┐
│ Category │ Lines │
├──────────┼───────┤
│ Non-test │ +125  │
├──────────┼───────┤
│ Test     │ +408  │
├──────────┼───────┤
│ Ratio    │ 1:3.2│
└──────────┴───────┘

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign ivankatliarchuk for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details 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

@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Feb 8, 2026
@coveralls
Copy link

coveralls commented Feb 8, 2026

Pull Request Test Coverage Report for Build 21798993330

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 45 unchanged lines in 4 files lost coverage.
  • Overall coverage decreased (-0.02%) to 79.142%

Files with Coverage Reduction New Missed Lines %
informers/informers.go 3 92.31%
informers/indexers.go 6 88.24%
crd.go 14 48.31%
store.go 22 50.6%
Totals Coverage Status
Change from base Build 21559764040: -0.02%
Covered Lines: 16001
Relevant Lines: 20218

💛 - Coveralls

@ivankatliarchuk ivankatliarchuk force-pushed the chore-crd-source-refresh branch 2 times, most recently from a1c0f06 to d9dd511 Compare February 8, 2026 12:26
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
@ivankatliarchuk ivankatliarchuk force-pushed the chore-crd-source-refresh branch from d9dd511 to 0a361d6 Compare February 8, 2026 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. source

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants