Skip to content

wait for client cert to become ready before getting etcd client - #269

Merged
Andrei Kvapil (kvaps) merged 1 commit into
mainfrom
chore/less-flaky-tests
Oct 15, 2024
Merged

Andrei Kvapil (kvaps) merged 1 commit into
mainfrom
chore/less-flaky-tests

Conversation

@lllamnyp

@lllamnyp Timofei Larkin (lllamnyp) commented Oct 14, 2024 •

Copy link
Copy Markdown
Member

The test of etcd cluster with TLS and auth config fails frequently, because the client certificate does not get created, before the etcd cluster is up and running. This PR adds a step to wait for the client cert to become ready, before executing the rest of the tests.

Summary by CodeRabbit

  • New Features

    • Reduced RSA private key sizes for various certificates to enhance security.
    • Added a new end-to-end test case to ensure readiness of TLS client certificates before proceeding with cluster operations.
  • Bug Fixes

    • Improved test reliability by ensuring TLS certificates are ready before stateful set readiness checks.

@coderabbitai

coderabbitai Bot commented Oct 14, 2024 •

Copy link
Copy Markdown
Contributor

Walkthrough

The changes in this pull request involve modifications to a Kubernetes manifest file for an EtcdCluster, specifically reducing the RSA private key sizes for various certificates from 4096 to 2048 bits. Additionally, a new test case is introduced in the end-to-end test suite to ensure that the client certificate is ready before proceeding with the readiness check of the etcd cluster. The overall structure of the resources remains consistent, with no other changes to metadata or organization.

Changes

File Path Change Summary
examples/manifests/etcdcluster-with-external-certificates.yaml Reduced RSA private key sizes from 4096 to 2048 bits for multiple certificates (ca-certificate-peer, ca-certificate-server, ca-certificate-client, server-certificate, peer-certificate, client-certificate). No changes to structure or metadata.
test/e2e/e2e_test.go Added a new test case that waits for the readiness of the client certificate before proceeding with the stateful set readiness check. No other changes to the test structure.

Poem

🐰 In the meadow where the clusters grow,
Certificates dance with a gentle glow.
Key sizes trimmed, now light as a breeze,
Ready they stand, with such graceful ease.
Hopping along, we celebrate this cheer,
For a secure future, we hold dear! 🌼✨


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.

@github-actions github-actions Bot added the chore label Oct 14, 2024

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (7)
examples/manifests/etcdcluster-with-external-certificates.yaml (6)

47-47: Approved: RSA key size reduction for ca-certificate-peer

The change from 4096 to 2048 bits for the RSA private key is acceptable. While this slightly reduces the theoretical security strength, 2048-bit RSA keys are still considered secure for most applications as of 2024. This change may improve performance, especially in resource-constrained environments.

Consider documenting this change and the rationale behind it in your project's security policy or documentation.


99-99: Approved: RSA key size reduction for ca-certificate-client

The change from 4096 to 2048 bits for the RSA private key is consistent with the previous certificate changes and is acceptable.

Given that this change affects all CA certificates (peer, server, and client), it's recommended to conduct a security review to ensure this change aligns with your organization's security policies and risk tolerance.


165-165: Approved: RSA key size reduction for server-certificate

The change from 4096 to 2048 bits for the RSA private key is consistent with the previous changes and is acceptable.

Note that this certificate has a rotation policy set to "Always". With the reduced key size, consider reviewing and potentially adjusting the rotation frequency to maintain an appropriate balance between security and performance.


200-200: Approved: RSA key size reduction for peer-certificate

The change from 4096 to 2048 bits for the RSA private key is consistent with the previous changes and is acceptable.

As this certificate is used for both server and client authentication in peer communication, monitor the performance impact of this change, especially during certificate rotation operations. Consider setting up metrics to track the duration of TLS handshakes and overall cluster communication latency.


219-219: Approved with caution: RSA key size reduction for client-certificate

The change from 4096 to 2048 bits for the RSA private key is consistent with the previous changes and is acceptable from a technical standpoint.

However, given that this client certificate has the common name "root", which implies high privileges, extra caution is warranted:

  1. Ensure that the reduced key size doesn't conflict with any specific security requirements for root-level access.
  2. Review the access controls and policies associated with this certificate to ensure they align with the principle of least privilege.
  3. Consider implementing additional monitoring and alerting for the usage of this certificate, given its potentially elevated privileges.

Line range hint 1-221: Summary: Consistent RSA key size reduction across all certificates

The changes in this PR consistently reduce the RSA private key size from 4096 to 2048 bits across all certificate resources in the EtcdCluster configuration. This change aligns with the PR objectives of potentially improving performance, especially in resource-constrained environments.

Key points:

  1. The change is consistently applied to all CA, server, peer, and client certificates.
  2. 2048-bit RSA keys are still considered secure for most applications as of 2024.
  3. This change may improve performance, particularly during TLS handshakes and certificate operations.

Recommendations:

  1. Document this change in your project's security policy and architecture documentation.
  2. Conduct a thorough security review to ensure alignment with your organization's security policies and risk tolerance.
  3. Implement monitoring to track the performance impact of this change, especially during certificate rotation operations.
  4. Review and potentially adjust certificate rotation frequencies in light of the reduced key sizes.
  5. Pay special attention to the "root" client certificate and ensure its usage aligns with the principle of least privilege.

Consider creating a follow-up task to evaluate the real-world performance improvements gained from this change and to reassess the security implications after a defined period of operation with the new key sizes.

test/e2e/e2e_test.go (1)

225-235: LGTM! Consider enhancing error handling and success message.

The addition of this Eventually block effectively addresses the PR objective by ensuring the client certificate is ready before proceeding with the etcd cluster readiness check. This should improve the reliability of the test.

Some minor suggestions for improvement:

  1. Consider adding more detailed error handling to aid in debugging if the wait fails. For example:
Eventually(func() error {
    cmd := exec.Command("kubectl", "wait",
        "certificate/client-certificate",
        "--for", "condition=Ready",
        "--namespace", namespace,
        "--timeout", "5m",
    )
    output, err := utils.Run(cmd)
    if err != nil {
        return fmt.Errorf("failed to wait for client certificate: %v, output: %s", err, output)
    }
    return nil
}, time.Second*20, time.Second*2).Should(Succeed(), "client certificate should become ready within 20 seconds")
  1. Update the success message to be more descriptive, e.g., "wait for client certificate to become ready".
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between e00e6cb and 18c420a.

📒 Files selected for processing (2)
  • examples/manifests/etcdcluster-with-external-certificates.yaml (6 hunks)
  • test/e2e/e2e_test.go (1 hunks)
🧰 Additional context used

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants