Skip to content

refactor(linode): reduce ApplyChanges cyclomatic complexity - #6867

Closed
mmontes11 wants to merge 2 commits into
kubernetes-sigs:masterfrom
mmontes11:feature-linode-applychanges
Closed

mmontes11 wants to merge 2 commits into
kubernetes-sigs:masterfrom
mmontes11:feature-linode-applychanges

Conversation

@mmontes11

Copy link
Copy Markdown
Contributor

What does it do ?

Decomposes the Linode provider ApplyChanges into small helpers: zoneLookup
(zone ID/name maps), fetchRecordsByZone (existing record fetch), and one
generate* pair per change kind — generateCreates/createEndpoint,
generateUpdates/updateEndpoint/endpointTargetChanges,
generateDeletes/deleteEndpoint — which append into a shared
*LinodeChanges. ApplyChanges keeps only the fetch, the three generation
steps and submitChanges.

Cyclomatic complexity of ApplyChanges drops from 25 to 6 (helpers are all
cc <= 5); the record diffing logic is unchanged.

Motivation

The function mixed zone/record fetching with three per-endpoint
create/update/delete generation loops, each of which had its own matching and
logging branches, making the update path (which can also emit creates and
deletes) hard to follow.

More

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

New test: TestLinodeApplyChangesUnsupportedRecordType pins the
convertRecordType error path (previously untested) — an unsupported type
aborts ApplyChanges with the same error.

Signed-off-by: Martin Montes <martin11lrx@gmail.com>
@kubernetes-prow

Copy link
Copy Markdown
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 szuecs 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

@kubernetes-prow
kubernetes-prow Bot requested review from mloiseleur and u-kai October 27, 2026 17:52
@kubernetes-prow kubernetes-prow Bot added provider Issues or PRs related to a provider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 27, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

Hi @mmontes11. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

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.

@kubernetes-prow kubernetes-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 27, 2026
@mloiseleur

Copy link
Copy Markdown
Collaborator

@mmontes11 Are you able to test this PR, e2e ?

Comment thread provider/linode/linode.go Resolved
Comment thread provider/linode/linode.go Resolved
@mloiseleur

Copy link
Copy Markdown
Collaborator

@mmontes11 We may drop entirely this provider, JSY. see #6877

@mmontes11

mmontes11 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor Author

@mloiseleur Thanks again for you in-depth review. I don't have a Linode account by hand to test the full e2e changes, I was relying on your extensive test suite to validate the changes. I'm open to leave this open until someone (maybe the community?) is able to test this e2e.

We may drop entirely this provider, JSY. see #6877

I can imagine the maintenance burden, reusing the same webhook provider will certainly help.

@linux-foundation-easycla

linux-foundation-easycla Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

@kubernetes-prow kubernetes-prow Bot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. and removed cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Oct 28, 2026
Consolidate generateCreates/generateUpdates/generateDeletes into a
single forEachEndpoint iterator and drop the unreachable empty-slice
branches. Helpers take the zone directly instead of a string zone ID,
and name-restating doc comments on unexported helpers are removed.

Signed-off-by: Martin Montes <martin11lrx@gmail.com>
@mmontes11
mmontes11 force-pushed the feature-linode-applychanges branch from f1146a7 to 982238b Compare October 28, 2026 16:03
@kubernetes-prow kubernetes-prow Bot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Oct 28, 2026
@mmontes11

Copy link
Copy Markdown
Contributor Author

Review comments addressed:

  • Consolidated generateCreates/generateUpdates/generateDeletes into a single forEachEndpoint iterator (using the suggested signature); the per-endpoint helpers keep their existing logic.
  • Dropped the now-dead len(...) == 0 "Skipping Zone" branches (unreachable: endpointsByZone never inserts empty slices) and the string zoneID parameter — log fields use zone.ID directly.
  • Removed the name-restating doc comments on the unexported helpers, keeping only the endpointTargetChanges note that it removes the handled records from the map.

Verified locally: go test -race ./provider/linode/... passes, golangci-lint clean.

@mmontes11
mmontes11 requested a review from mloiseleur October 28, 2026 16:41
@mloiseleur

Copy link
Copy Markdown
Collaborator

no need to go further on this PR if we drop this provider
/hold

@kubernetes-prow kubernetes-prow Bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Oct 28, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

PR needs rebase.

Details

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.

@mloiseleur

Copy link
Copy Markdown
Collaborator

linode provider has been removed.
/close

@kubernetes-prow kubernetes-prow Bot closed this Oct 29, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

@mloiseleur: Closed this PR.

Details

In response to this:

linode provider has been removed.
/close

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.

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. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. provider Issues or PRs related to a provider size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants