Skip to content

chore(cloudflare): migrate customhostname to v5#5891

Merged
k8s-ci-robot merged 20 commits intokubernetes-sigs:masterfrom
AndrewCharlesHay:andrewcharleshay/cloudflare-migration-v5
Jan 14, 2026
Merged

chore(cloudflare): migrate customhostname to v5#5891
k8s-ci-robot merged 20 commits intokubernetes-sigs:masterfrom
AndrewCharlesHay:andrewcharleshay/cloudflare-migration-v5

Conversation

@AndrewCharlesHay
Copy link
Copy Markdown
Contributor

@AndrewCharlesHay AndrewCharlesHay commented Oct 6, 2025

What does it do ?

Migrate customhostname to v5

Motivation

Closes #5540

More

  • Yes, this PR title follows Conventional Commits
  • Yes, I added unit tests
  • Yes, I updated end user documentation accordingly

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Oct 6, 2025
@k8s-ci-robot k8s-ci-robot added the provider Issues or PRs related to a provider label Oct 6, 2025
@k8s-ci-robot k8s-ci-robot requested a review from szuecs October 6, 2025 21:49
@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Oct 6, 2025
@coveralls
Copy link
Copy Markdown

coveralls commented Oct 6, 2025

Pull Request Test Coverage Report for Build 20995964271

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 1012 unchanged lines in 43 files lost coverage.
  • Overall coverage increased (+0.4%) to 79.084%

Files with Coverage Reduction New Missed Lines %
utils.go 1 96.0%
apis/externaldns/types.go 1 99.62%
empty.go 2 75.0%
fake.go 2 96.23%
source.go 2 72.22%
gateway_udproute.go 2 92.59%
gateway_grpcroute.go 2 92.59%
gateway_tlsroute.go 2 92.59%
gateway_httproute.go 2 92.59%
gateway_tcproute.go 2 92.59%
Totals Coverage Status
Change from base Build 20455488225: 0.4%
Covered Lines: 16032
Relevant Lines: 20272

💛 - Coveralls

@AndrewCharlesHay AndrewCharlesHay changed the title Andrewcharleshay/cloudflare migration v5 chore(cloudflare): migrate customhostname to v5 Oct 7, 2025
@mloiseleur
Copy link
Copy Markdown
Collaborator

@vflaux @mrozentsvayg Any comment on this PR ? Do you think you can review it ?

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

@vflaux: changing LGTM is restricted to collaborators

Details

In response to this:

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.

@AndrewCharlesHay
Copy link
Copy Markdown
Contributor Author

How did broken tests get merged in?

@vflaux
Copy link
Copy Markdown
Contributor

vflaux commented Oct 13, 2025

How did broken tests get merged in?

This should be fixed, see #5896.

@AndrewCharlesHay
Copy link
Copy Markdown
Contributor Author

/retest

@AndrewCharlesHay
Copy link
Copy Markdown
Contributor Author

@vflaux everything look good now?

Copy link
Copy Markdown
Contributor

@vflaux vflaux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've not review all the new tests yet.
Looks like IA generated, some clearly improve test coverage, others seems less relevant. 😄

@AndrewCharlesHay
Copy link
Copy Markdown
Contributor Author

The tests just fail because of rate limits to coveralls

@szuecs
Copy link
Copy Markdown
Contributor

szuecs commented Oct 31, 2025

Did you @AndrewCharlesHay address comments by @vflaux ?

Cleaning up things that are not useful is always great for maintaining the software.

@AndrewCharlesHay
Copy link
Copy Markdown
Contributor Author

@szuecs yep all updated

@mloiseleur
Copy link
Copy Markdown
Collaborator

@AndrewCharlesHay Would you please rebase ?

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 8, 2025
@AndrewCharlesHay AndrewCharlesHay force-pushed the andrewcharleshay/cloudflare-migration-v5 branch from e0eb277 to bcad628 Compare November 10, 2025 15:43
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 10, 2025
@mloiseleur
Copy link
Copy Markdown
Collaborator

@vflaux @szuecs Anything left on your side ?

Comment on lines +3860 to +3895
func TestSubmitChangesEdgeCases(t *testing.T) {
ctx := context.Background()

t.Run("EmptyChanges", func(t *testing.T) {
client := NewMockCloudFlareClient()
provider := &CloudFlareProvider{
Client: client,
}

err := provider.submitChanges(ctx, []*cloudFlareChange{})
assert.NoError(t, err, "Empty changes should not error")
})

t.Run("DryRun", func(t *testing.T) {
client := NewMockCloudFlareClient()
provider := &CloudFlareProvider{
Client: client,
DryRun: true,
}

changes := []*cloudFlareChange{
{
Action: cloudFlareCreate,
ResourceRecord: dns.RecordResponse{
Name: "test.bar.com",
Type: "A",
Content: "1.2.3.4",
},
},
}

err := provider.submitChanges(ctx, changes)
assert.NoError(t, err, "Dry run should not error")
assert.Empty(t, client.Actions, "Dry run should not execute actions")
})
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This don't increase test coverage.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been addressed by the v5 test migration. Verification is included in the updated cloudflare_test.go.

Comment on lines +3898 to +3951
func TestGroupByNameAndTypeWithCustomHostnames(t *testing.T) {
provider := &CloudFlareProvider{}

t.Run("WithCustomHostnames", func(t *testing.T) {
records := DNSRecordsMap{
DNSRecordIndex{Name: "origin.example.com", Type: "A", Content: "1.2.3.4"}: {
ID: "rec1",
Name: "origin.example.com",
Type: "A",
Content: "1.2.3.4",
TTL: 300,
},
}

customHostnames := CustomHostnamesMap{
CustomHostnameIndex{Hostname: "custom1.example.com"}: {
ID: "ch1",
Hostname: "custom1.example.com",
CustomOriginServer: "origin.example.com",
},
CustomHostnameIndex{Hostname: "custom2.example.com"}: {
ID: "ch2",
Hostname: "custom2.example.com",
CustomOriginServer: "origin.example.com",
},
}

endpoints := provider.groupByNameAndTypeWithCustomHostnames(records, customHostnames)
require.Len(t, endpoints, 1)

customHostnamesProp, ok := endpoints[0].GetProviderSpecificProperty(annotations.CloudflareCustomHostnameKey)
assert.True(t, ok)
assert.Contains(t, customHostnamesProp, "custom1.example.com")
assert.Contains(t, customHostnamesProp, "custom2.example.com")
})

t.Run("WithoutCustomHostnames", func(t *testing.T) {
records := DNSRecordsMap{
DNSRecordIndex{Name: "example.com", Type: "A", Content: "1.2.3.4"}: {
ID: "rec1",
Name: "example.com",
Type: "A",
Content: "1.2.3.4",
TTL: 300,
},
}

endpoints := provider.groupByNameAndTypeWithCustomHostnames(records, nil)
require.Len(t, endpoints, 1)

_, ok := endpoints[0].GetProviderSpecificProperty(annotations.CloudflareCustomHostnameKey)
assert.False(t, ok, "Should not have custom hostname when none exist")
})
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This don't increase test coverage.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been addressed by the v5 test migration. Verification is included in the updated cloudflare_test.go.

Comment on lines +4142 to +4176
func TestBuildCustomHostnameSSLParams(t *testing.T) {
ssl := &CustomHostnameSSL{
Type: "dv",
Method: "http",
BundleMethod: "ubiquitous",
CertificateAuthority: "lets_encrypt",
Settings: CustomHostnameSSLSettings{MinTLSVersion: "1.2"},
}

params := custom_hostnames.CustomHostnameNewParamsSSL{}
if ssl.Method != "" {
params.Method = cloudflare.F(custom_hostnames.DCVMethod(ssl.Method))
}
if ssl.Type != "" {
params.Type = cloudflare.F(custom_hostnames.DomainValidationType(ssl.Type))
}
if ssl.BundleMethod != "" {
params.BundleMethod = cloudflare.F(custom_hostnames.BundleMethod(ssl.BundleMethod))
}
if ssl.CertificateAuthority != "" && ssl.CertificateAuthority != "none" {
params.CertificateAuthority = cloudflare.F(cloudflare.CertificateCA(ssl.CertificateAuthority))
}
if ssl.Settings.MinTLSVersion != "" {
params.Settings = cloudflare.F(custom_hostnames.CustomHostnameNewParamsSSLSettings{
MinTLSVersion: cloudflare.F(custom_hostnames.CustomHostnameNewParamsSSLSettingsMinTLSVersion(ssl.Settings.MinTLSVersion)),
})
}

// Assert all fields are set as expected
require.Equal(t, custom_hostnames.DCVMethod("http"), params.Method.Value)
require.Equal(t, custom_hostnames.DomainValidationType("dv"), params.Type.Value)
require.Equal(t, custom_hostnames.BundleMethod("ubiquitous"), params.BundleMethod.Value)
require.Equal(t, cloudflare.CertificateCA("lets_encrypt"), params.CertificateAuthority.Value)
require.Equal(t, custom_hostnames.CustomHostnameNewParamsSSLSettingsMinTLSVersion("1.2"), params.Settings.Value.MinTLSVersion.Value)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This don't test anything.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been addressed by the v5 test migration. Verification is included in the updated cloudflare_test.go.

…handling

- Replace all cloudflarev0.Error usages with cloudflare.Error in tests
- Remove unused cloudflarev0 import
- Fix getDNSRecordsMap to use PerPage configuration
- Add early return in convertCloudflareError for structured v5 errors
- Update TestConvertCloudflareError to handle v5 error types safely
- Remove ErrorCodes field from error structs (not in v5 SDK)

Signed-off-by: Andrew Hay <andrew.hay@benchmarkanalytics.com>
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jan 6, 2026
Signed-off-by: Andrew Hay <andrew.hay@benchmarkanalytics.com>
@AndrewCharlesHay
Copy link
Copy Markdown
Contributor Author

@vflaux I believe I've addressed your previous concerns regarding test coverage and relevance. The tests have been updated to fully support the v5 SDK migration, including the new CustomHostname structures. Please let me know if there are any remaining specific scenarios you think are missing coverage.

Copy link
Copy Markdown
Contributor

@vflaux vflaux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the additional change requests.

Could you also move back TestGroupByNameAndTypeWithCustomHostnames_MX, TestProviderPropertiesIdempotency & ExampleDomain to their original location to minimize the diff noise?

After that, we should be good.

AndrewCharlesHay and others added 6 commits January 13, 2026 10:14
Co-authored-by: vflaux <38909103+vflaux@users.noreply.github.com>
Co-authored-by: vflaux <38909103+vflaux@users.noreply.github.com>
Co-authored-by: vflaux <38909103+vflaux@users.noreply.github.com>
Co-authored-by: vflaux <38909103+vflaux@users.noreply.github.com>
- Remove SDK migration status section from cloudflare.md (per vflaux and ivankatliarchuk)
- Add newCloudflareError() helper for proper v5 SDK error testing
- Move ExampleDomain, TestGroupByNameAndTypeWithCustomHostnames_MX, and
  TestProviderPropertiesIdempotency back to original locations to minimize diff
Co-authored-by: vflaux <38909103+vflaux@users.noreply.github.com>
@ivankatliarchuk
Copy link
Copy Markdown
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 14, 2026
Co-authored-by: vflaux <38909103+vflaux@users.noreply.github.com>
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 14, 2026
@vflaux
Copy link
Copy Markdown
Contributor

vflaux commented Jan 14, 2026

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 14, 2026
@mrozentsvayg
Copy link
Copy Markdown
Contributor

Running d9921ef build in our stage environment for about a week now.
No issues so far.

Until merged, this PR is effectively blocking further development of the Cloudflare provider. For example, I have a new feature/extension pending (Origin SNI Override), but it doesn't make sense to implement it on top of the older API.

If there are no further concerns to address, it would be great to get this merged.

@ivankatliarchuk
Copy link
Copy Markdown
Member

/approve

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ivankatliarchuk

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

The pull request process is described 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 the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 14, 2026
@k8s-ci-robot k8s-ci-robot merged commit 3dd839a into kubernetes-sigs:master Jan 14, 2026
18 checks passed
ivankatliarchuk added a commit to gofogo/k8s-sigs-external-dns-fork that referenced this pull request Jan 16, 2026
* master: (25 commits)
  feat(event): standardize event messages and add resource kind lookup for events (kubernetes-sigs#6101)
  refactor(informers): unify cache sync functions using generics (kubernetes-sigs#6102)
  fix(fqdn): support kind and api version (kubernetes-sigs#6097)
  test(fqdn): cover sources without any fqdn tests (kubernetes-sigs#6094)
  chore(tools): CRD generation script moved and add validation workflow (kubernetes-sigs#6079)
  fix(metrics): add CNAME to known record types (kubernetes-sigs#6115)
  chore(cloudflare): migrate customhostname to v5 (kubernetes-sigs#5891)
  test(provider/exoscale): improved the test coverage for exoscale provider from 62.8% to 80.4%  (kubernetes-sigs#6112)
  feat(source): gateway api hostname source annotation (kubernetes-sigs#5959)
  test: cover pkg/events/fake package (kubernetes-sigs#6096)
  refactor(controller): controller no longer responsible for SingletonClientGenerator creation (kubernetes-sigs#6077)
  refactor(source): standardize FQDN template accross sources (kubernetes-sigs#6093)
  feat(coredns): rename ownerId and ownedBy to owner (kubernetes-sigs#6032)
  docs: fix typo in README (The are → There are) (kubernetes-sigs#6095)
  refactor(aws): abstract provider-specific boolean parsing (kubernetes-sigs#6078)
  refactor(api): deduplicate addKnownTypes (kubernetes-sigs#6087)
  fix(api): rollback changes for omitempty (kubernetes-sigs#6086)
  chore(deps): bump renovatebot/github-action (kubernetes-sigs#6080)
  fix(aws): enable AWS API validation for routing policies without setIdentifier (kubernetes-sigs#6082)
  chore(aws): document and test behavior for ALB and NLB (kubernetes-sigs#6063)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. chart cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. docs kustomize Issues or PRs related to kustomize installation lgtm "Looks good to me", indicates that a PR is ready to be merged. provider Issues or PRs related to a provider scripts Issues or PRs related to internal scripts 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.

cloudflare: bump library to v5

8 participants