Skip to content

fix keycloak secrets drift - #509

Merged
Andrei Kvapil (kvaps) merged 1 commit into
mainfrom
bugfix/fix-draft
Dec 4, 2024
Merged

Andrei Kvapil (kvaps) merged 1 commit into
mainfrom
bugfix/fix-draft

Conversation

@kvaps

Copy link
Copy Markdown
Member

No description provided.

@dosubot dosubot Bot added the size/XS This PR changes 0-9 lines, ignoring generated files label Dec 4, 2024
@coderabbitai

coderabbitai Bot commented Dec 4, 2024 •

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

Andrei Kvapil (@kvaps) has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 17 minutes and 2 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between d43b8fd and 7b0c93a.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@dosubot dosubot Bot added the kind/bug Categorizes issue or PR as related to a bug label Dec 4, 2024
@kvaps
Andrei Kvapil (kvaps) merged commit 6272cd7 into main Dec 4, 2024
@kvaps
Andrei Kvapil (kvaps) deleted the bugfix/fix-draft branch December 4, 2024 18:44
klinch0 pushed a commit to klinch0/cozystack that referenced this pull request Dec 5, 2024
Aleksei Sviridkin (lexfrei) added a commit that referenced this pull request May 1, 2026
…ions

Address the only round-4 code blocker: per-listener Certificates
created during an HTTP-01 phase are not deleted when the operator
flips certMode to dns01, and the wildcard Certificate created in
DNS-01 mode is not deleted when the operator flips back to http01.
Both cases leak a `cert-manager.io/Certificate` plus its backing
`Secret`, count against LE rate limits indefinitely, and confuse
listeners with stale TLS material.

reconciler.go changes:

- reconcilePerListenerCertificates no longer early-returns when
  certMode != http01. The provisioning branch is gated on http01,
  but the GC loop runs unconditionally with desiredNames empty in
  dns01 mode → every per-listener cert from a prior http01 reconcile
  is deleted.

- reconcileWildcardCertificate runs in both modes too. In dns01
  mode it provisions / updates the wildcard cert (unchanged
  behaviour). In http01 mode it now Get-and-Delete-if-owned the
  wildcard cert if a stale one exists from a previous dns01 phase.

Tests:

- TestReconcile_CertModeTransitionHTTP01ToDNS01CleansPerListenerCerts:
  bootstraps a TenantGateway in http01 with one attached HTTPRoute,
  asserts the per-listener cert exists, flips certMode to dns01 +
  fills DNS01.Cloudflare config, runs Reconcile again, asserts the
  per-listener cert is gone.

- TestReconcile_CertModeTransitionDNS01ToHTTP01CleansWildcardCert:
  bootstraps in dns01 with cloudflare config, asserts the wildcard
  cert exists, flips to http01, asserts the wildcard cert is gone.

Round-4 review's other concerns are non-code or out of scope for
this PR:

- Documentation PR (cozystack/website #509) is stale relative to
  this code's seven-layer security model. Tracked as a separate
  follow-up under the docs repo; will be updated as part of the
  PR landing dance.
- VAP apiVersions tightening (drop v1beta1 from gateway-hostname
  policy, widen route-hostname policy if HTTPRoute is served at
  multiple versions) — defer to a follow-up VAP-hardening PR.
- Spec-drift Kubernetes Event when controller overwrites Gateway
  edits — UX nice-to-have, not a correctness gap.
- Double conversion in pkg/registry/apps/application/rest.go
  Delete path — pre-existing code outside this PR's surface.

`make test-controllers` clean. `make helm-unit-tests` clean.

Assisted-By: Claude <[email protected]>
Signed-off-by: Aleksei Sviridkin <[email protected]>
Aleksei Sviridkin (lexfrei) added a commit that referenced this pull request May 1, 2026
…ions

Address the only round-4 code blocker: per-listener Certificates
created during an HTTP-01 phase are not deleted when the operator
flips certMode to dns01, and the wildcard Certificate created in
DNS-01 mode is not deleted when the operator flips back to http01.
Both cases leak a `cert-manager.io/Certificate` plus its backing
`Secret`, count against LE rate limits indefinitely, and confuse
listeners with stale TLS material.

reconciler.go changes:

- reconcilePerListenerCertificates no longer early-returns when
  certMode != http01. The provisioning branch is gated on http01,
  but the GC loop runs unconditionally with desiredNames empty in
  dns01 mode → every per-listener cert from a prior http01 reconcile
  is deleted.

- reconcileWildcardCertificate runs in both modes too. In dns01
  mode it provisions / updates the wildcard cert (unchanged
  behaviour). In http01 mode it now Get-and-Delete-if-owned the
  wildcard cert if a stale one exists from a previous dns01 phase.

Tests:

- TestReconcile_CertModeTransitionHTTP01ToDNS01CleansPerListenerCerts:
  bootstraps a TenantGateway in http01 with one attached HTTPRoute,
  asserts the per-listener cert exists, flips certMode to dns01 +
  fills DNS01.Cloudflare config, runs Reconcile again, asserts the
  per-listener cert is gone.

- TestReconcile_CertModeTransitionDNS01ToHTTP01CleansWildcardCert:
  bootstraps in dns01 with cloudflare config, asserts the wildcard
  cert exists, flips to http01, asserts the wildcard cert is gone.

Round-4 review's other concerns are non-code or out of scope for
this PR:

- Documentation PR (cozystack/website #509) is stale relative to
  this code's seven-layer security model. Tracked as a separate
  follow-up under the docs repo; will be updated as part of the
  PR landing dance.
- VAP apiVersions tightening (drop v1beta1 from gateway-hostname
  policy, widen route-hostname policy if HTTPRoute is served at
  multiple versions) — defer to a follow-up VAP-hardening PR.
- Spec-drift Kubernetes Event when controller overwrites Gateway
  edits — UX nice-to-have, not a correctness gap.
- Double conversion in pkg/registry/apps/application/rest.go
  Delete path — pre-existing code outside this PR's surface.

`make test-controllers` clean. `make helm-unit-tests` clean.

Assisted-By: Claude <[email protected]>
Signed-off-by: Aleksei Sviridkin <[email protected]>
Aleksei Sviridkin (lexfrei) added a commit that referenced this pull request May 2, 2026
…ions

Address the only round-4 code blocker: per-listener Certificates
created during an HTTP-01 phase are not deleted when the operator
flips certMode to dns01, and the wildcard Certificate created in
DNS-01 mode is not deleted when the operator flips back to http01.
Both cases leak a `cert-manager.io/Certificate` plus its backing
`Secret`, count against LE rate limits indefinitely, and confuse
listeners with stale TLS material.

reconciler.go changes:

- reconcilePerListenerCertificates no longer early-returns when
  certMode != http01. The provisioning branch is gated on http01,
  but the GC loop runs unconditionally with desiredNames empty in
  dns01 mode → every per-listener cert from a prior http01 reconcile
  is deleted.

- reconcileWildcardCertificate runs in both modes too. In dns01
  mode it provisions / updates the wildcard cert (unchanged
  behaviour). In http01 mode it now Get-and-Delete-if-owned the
  wildcard cert if a stale one exists from a previous dns01 phase.

Tests:

- TestReconcile_CertModeTransitionHTTP01ToDNS01CleansPerListenerCerts:
  bootstraps a TenantGateway in http01 with one attached HTTPRoute,
  asserts the per-listener cert exists, flips certMode to dns01 +
  fills DNS01.Cloudflare config, runs Reconcile again, asserts the
  per-listener cert is gone.

- TestReconcile_CertModeTransitionDNS01ToHTTP01CleansWildcardCert:
  bootstraps in dns01 with cloudflare config, asserts the wildcard
  cert exists, flips to http01, asserts the wildcard cert is gone.

Round-4 review's other concerns are non-code or out of scope for
this PR:

- Documentation PR (cozystack/website #509) is stale relative to
  this code's seven-layer security model. Tracked as a separate
  follow-up under the docs repo; will be updated as part of the
  PR landing dance.
- VAP apiVersions tightening (drop v1beta1 from gateway-hostname
  policy, widen route-hostname policy if HTTPRoute is served at
  multiple versions) — defer to a follow-up VAP-hardening PR.
- Spec-drift Kubernetes Event when controller overwrites Gateway
  edits — UX nice-to-have, not a correctness gap.
- Double conversion in pkg/registry/apps/application/rest.go
  Delete path — pre-existing code outside this PR's surface.

`make test-controllers` clean. `make helm-unit-tests` clean.

Assisted-By: Claude <[email protected]>
Signed-off-by: Aleksei Sviridkin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Categorizes issue or PR as related to a bug size/XS This PR changes 0-9 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant