Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix proxy restart EAB issue #829

Merged
merged 2 commits into from
Oct 21, 2024

Conversation

paulgb
Copy link
Member

@paulgb paulgb commented Oct 21, 2024

Although ACME accounts are essentially disposable, it's better to re-use them where possible, in particular when dealing with EAB (as we do with Google Certificate Manager), where an account can only be created once per EAB key set.

To date, we have done this eagerly by creating the ACME account when the Plane proxy process starts. The problem with this approach is that it creates an unnecessary point of failure when the ACME account fails to create but the proxy is otherwise ready to go.

This moves account creation into the refresh loop, but makes it lazy such that it only happens once per instance and then is remembered for future certificate refreshes. This way, if we start the proxy with a valid certificate already in place, it won't attempt to fetch the account immediately.

Copy link

vercel bot commented Oct 21, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
plane ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 21, 2024 8:57pm

Copy link
Contributor

coderabbitai bot commented Oct 21, 2024

📝 Walkthrough

Walkthrough

The pull request introduces significant changes to the CertManager and CertWatcher structures within the plane/src/proxy/cert_manager.rs file, particularly in managing ACME certificate requests. The CertManager struct now includes an acme_config field of type Option<AcmeConfig>, replacing the previous acme_account field, marking a transition from an account-centric to a configuration-centric approach. The new method has been updated to accept an acme_config parameter, eliminating the initialization of an ACME account and instead focusing on storing the configuration directly. The set_request_sender method has been modified to utilize the acme_config, which is now passed to the refresh_loop function. Additionally, the refresh_loop_step function has been refactored to manage account creation using a mutable reference to an Option<Arc<Account>>. The overall changes streamline the handling of ACME configurations and account management, emphasizing configuration objects over direct account references, while also removing the previous acme_account logic.

Possibly related PRs

  • Fix private key parsing and add fallback on ACME #827: The changes in the CertManager::new method regarding error handling during certificate loading are directly related to the modifications in the new method of CertManager in the main PR, as both involve the initialization process of the CertManager and handling of certificates.

Suggested reviewers

  • rolyatmax

🪧 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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ef3fa13 and af701a3.

📒 Files selected for processing (1)
  • plane/src/proxy/cert_manager.rs (7 hunks)
🧰 Additional context used
🪛 ast-grep
plane/src/proxy/cert_manager.rs

[warning] 272-273: Dangerously accepting invalid TLS
Context: reqwest::Client::builder()
.danger_accept_invalid_certs(true)
Note: [CWE-295]: Improper Certificate [REFERENCES]
- https://docs.rs/reqwest/latest/reqwest/struct.ClientBuilder.html#method.danger_accept_invalid_hostnames
- https://docs.rs/reqwest/latest/reqwest/struct.ClientBuilder.html#method.danger_accept_invalid_certs

🔇 Additional comments (1)
plane/src/proxy/cert_manager.rs (1)

190-203: Verify the handling when acme_config is None

In the set_request_sender method, the refresh loop is initiated only if acme_config is Some. If it's None, the certificate renewal process will not start, which may affect the application's ability to obtain or refresh certificates.

Ensure that the application can function correctly without the certificate refresh loop when acme_config is None. If this is intended, consider documenting this behavior to avoid confusion.

plane/src/proxy/cert_manager.rs Show resolved Hide resolved
@paulgb paulgb merged commit 1c20be4 into main Oct 21, 2024
7 checks passed
@paulgb paulgb deleted the paul/dis-2809-proxies-unable-to-restart-after-oomkilled branch October 21, 2024 23:48
@coderabbitai coderabbitai bot mentioned this pull request Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants