Skip to content

fix(cacert): make the comments match the reconciler - #4064

Merged
Aleksei Sviridkin (lexfrei) merged 1 commit into
mainfrom
fix/cacert-comments
Sep 4, 2026
Merged

Aleksei Sviridkin (lexfrei) merged 1 commit into
mainfrom
fix/cacert-comments

Conversation

@lexfrei

@lexfrei Aleksei Sviridkin (lexfrei) commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does

Comments in the CA-extraction package claim guards the code does not have. No behaviour change; one test is renamed to match the property it pins.

  • ManagedLabel said the reconciler only ever writes over a Secret carrying that label. It does not. isOurProjection decides that from the Secret type and the owner reference, and never looks at the label, which any writer in the namespace can strip.
  • managedByCozystackLabel said the reconciler never writes it. It deletes it whenever the selectors digest changes, which is what gets the projection re-admitted by the lineage webhook.
  • projectionSuffix said the dotted canonical name cannot collide with an operator-owned object. A release the apps API created cannot carry a dot, since application names are DNS-1035 labels and release.prefix is restricted to ^[a-z0-9-]*$. The guarantee stops there: the controller reads the release from the helm.toolkit.fluxcd.io/name label, where a dot is legal, so a hand-written HelmRelease sits outside it. On the validated path the dot can only come from the suffix an operator or chart appends, which nothing validates at all, and since a canonical name ends in .tenant-ca and carries that one dot, a suffix ending in .tenant-ca is the only one that reaches a canonical name. The comment says all of that now.
  • The test pinning that name claimed the property for any engine suffix, in its doc and in its own name, while its loop samples only dot-free ones. It is now TestProjectionNameCannotCollideWithADotFreeEngineSuffix, and its doc says what the loop covers.

Screenshots

Not a UI change.

Downstream repositories

Comments and one test name in two Go files. No package, values key, schema field, CRD, metric, release asset or hack/ target changes, so nothing in the trigger map fires.

Release note

NONE

Summary by CodeRabbit

  • Documentation

    • Clarified certificate reconciliation behavior, including label handling, projection naming, and source certificate scenarios.
    • Documented naming guarantees and their API boundaries more precisely.
  • Tests

    • Updated test descriptions and failure messaging to clarify coverage for dot-free engine suffixes.

@coderabbitai

coderabbitai Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: e468ce54-3803-4924-b08c-04039c9297b6

📥 Commits

Reviewing files that changed from the base of the PR and between e94fcf8 and 9ea4a96.

📒 Files selected for processing (2)
  • internal/controller/cacert/reconciler.go
  • internal/controller/cacert/reconciler_test.go

Included review availability: Your plan provides up to 8 included reviews per hour; 5 remain after this review.


📝 Walkthrough

Walkthrough

The change updates CA reconciler documentation comments and renames one test to define its collision property more precisely. No functional code or test logic changes.

Changes

CA reconciler documentation

Layer / File(s) Summary
Clarify reconciler comments and test coverage
internal/controller/cacert/reconciler.go, internal/controller/cacert/reconciler_test.go
Comments clarify label handling, projection naming constraints, canonical-name cases, and collision coverage. The test name and failure message now specify dot-free engine suffixes.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Merge Risk: ⚪ Minimal · up to 9ea4a

This change clarifies CA reconciler ownership and naming documentation and makes the collision test’s dot-free suffix scope explicit. Runtime behavior and test execution remain unchanged, with no current merge-readiness risk identified.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately identifies the main change: updating cacert comments to match reconciler behavior. It is concise and specific.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/cacert-comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comments in the CA-extraction package described guards the code does
not have.

ManagedLabel: the anti-clobber decision is made by isOurProjection,
from the Secret type and an owner reference back to the sentinel, not
from the marker, which no decision keys on beyond the drift check.

managedByCozystackLabel: the reconciler does mutate it. It deletes the
label on a selectors-digest change, which is what hands the projection
back to the lineage webhook for a fresh verdict.

projectionSuffix: the projection name is kept clear of engine CA
Secrets by a dot, and a release name cannot carry one, but the suffix
an operator appends can and nothing validates it. A suffix ending in
".tenant-ca" is the only one that reaches a canonical name.

TestProjectionNameCannotCollideWithADotFreeEngineSuffix: both its doc
and its name claimed the property for any engine suffix while the loop
samples only dot-free ones, which is the same overstatement one file
over.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <[email protected]>
@github-actions github-actions Bot added area/uncategorized PR auto-labeler could not map title scope to a known area/*; please review kind/bug Categorizes issue or PR as related to a bug size/M This PR changes 30-99 lines, ignoring generated files labels Sep 3, 2026
@lexfrei
Aleksei Sviridkin (lexfrei) marked this pull request as ready for review September 3, 2026 21:46

@kvaps Andrei Kvapil (kvaps) 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.

LGTM. I checked both factual claims against the code rather than reading the diff for plausibility, because a comment fix is only worth merging if the new comment is true.

isOurProjection decides on two things — s.Type != corev1.SecretTypeOpaque and an owner reference naming this TenantProjection — and never reads ManagedLabel. So the old claim that the reconciler "only ever writes over a Secret bearing this label" was false, and the replacement is accurate about where the decision actually lives.

delete(existing.Labels, managedByCozystackLabel) is there, guarded so only a selector change reaches it, with the reasoning that a data rotation cannot change the webhook's verdict and re-admitting on one would be pure load. The old "the reconciler never writes it" was false in the other direction.

The projectionSuffix rewrite is the one I would have wanted most. The old text asserted collision impossibility outright; the new text says where the guarantee comes from and — more usefully — where it stops: the release name is read from the helm.toolkit.fluxcd.io/name label, where a dot is legal, so a hand-written HelmRelease is outside the DNS-1035 argument, and the suffix an operator or chart appends is validated by nothing. Naming that the guarantee holds on the validated path and not beyond it is what makes the comment usable by whoever next considers "tidying" the dot.

Renaming the test to TestProjectionNameCannotCollideWithADotFreeEngineSuffix is the right call too: the loop only ever sampled dot-free suffixes, so the old name promised a property the test did not check — the same class of overclaim as the comments, and the more dangerous one, because a test name is what people trust when they skim.

A comment that overstates a guard is worse than no comment: it is what a reader relies on when deciding whether a change is safe. Worth having.

@lexfrei
Aleksei Sviridkin (lexfrei) merged commit 18d02d8 into main Sep 4, 2026
79 of 80 checks passed
@lexfrei
Aleksei Sviridkin (lexfrei) deleted the fix/cacert-comments branch September 4, 2026 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/uncategorized PR auto-labeler could not map title scope to a known area/*; please review kind/bug Categorizes issue or PR as related to a bug size/M This PR changes 30-99 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants