Skip to content

Remove dead nil checks in single-concern reconcilers - #998

Merged
winiciusallan merged 2 commits into
k-orc:mainfrom
shiftstack:cleanup-nil-checks-single-concern-reconcilers
Oct 16, 2026
Merged

winiciusallan merged 2 commits into
k-orc:mainfrom
shiftstack:cleanup-nil-checks-single-concern-reconcilers

Conversation

@mandre

@mandre mandre commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator

The generic reconciler only calls GetResourceReconcilers for managed resources, and CEL validation on the CRD ensures that spec.resource is always set for managed resources. The nil checks for spec.resource in single-concern reconcilers are therefore unreachable.

@github-actions github-actions Bot added the semver:patch No API change label Oct 16, 2026
@mandre
mandre force-pushed the cleanup-nil-checks-single-concern-reconcilers branch from 1be8c11 to 1caf10f Compare October 16, 2026 07:34

@winiciusallan winiciusallan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Turns out that we also have same code in CreateResources e.g. here and here.

Wondering about the reason... maybe the scaffold-controller didn't exist and this was a way to guard against missing validations.

Would you like to remove them in a follow-up or here?

@mandre

mandre commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator Author

Turns out that we also have same code in CreateResources e.g. here and here.

Oh, that's right. I'll remove those too.

Wondering about the reason... maybe the scaffold-controller didn't exist and this was a way to guard against missing validations.

This is historical. We didn't have the generic controller, or scaffolding at first, and everything was written by hand. Assumptions that were true before no longer hold.

Would you like to remove them in a follow-up or here?

I'll do it here.

The generic reconciler only calls `GetResourceReconcilers` for managed
resources, and CEL validation on the CRD ensures that `spec.resource` is
always set for managed resources. The nil checks for `spec.resource` in
single-concern reconcilers are therefore unreachable.

Also remove unit tests that exercised the now-impossible nil resource
path.
The generic reconciler guards against unmanaged resources at
`resource_actions.go:133` before reaching `CreateResource` at line 150.
Only managed resources reach this path, and CEL validation on the CRD
ensures that `spec.resource` is always set for managed resources. The
nil checks are therefore unreachable.

Also remove the corresponding nil checks from the scaffold template.
@mandre
mandre force-pushed the cleanup-nil-checks-single-concern-reconcilers branch from 1caf10f to adf6163 Compare October 16, 2026 13:23

@winiciusallan winiciusallan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice!

@winiciusallan
winiciusallan added this pull request to the merge queue Oct 16, 2026
Merged via the queue into k-orc:main with commit 716aaaf Oct 16, 2026
10 checks passed
@winiciusallan
winiciusallan deleted the cleanup-nil-checks-single-concern-reconcilers branch October 16, 2026 14:22
zunken1337 added a commit to zunken1337/openstack-resource-controller that referenced this pull request Oct 22, 2026
Available follows the recordset's Designate status (ACTIVE), polling
otherwise, and status.resource.status shows it. Adoption also requires
the same records. The zone is required in CreateResource and fetched
in the adoption and import methods instead of in newActuator. Remove
the spec.resource nil checks (k-orc#997, k-orc#998).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

semver:patch No API change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants