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

Better error for invalid certificate. #2852

Conversation

meowjesty
Copy link
Member

@meowjesty meowjesty commented Oct 16, 2024

Improves the error logs, should be more specific now in case of an InvalidCertificate.

@meowjesty meowjesty linked an issue Oct 16, 2024 that may be closed by this pull request
Copy link
Contributor

@Razz4780 Razz4780 left a comment

Choose a reason for hiding this comment

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

I'd move detecting invalid cert error to CliError. It offers better support for help messages/fix instructions. See CliError::KubeAuthExecFailed and CliError::auth_exec_error_or. I'd inject new logic into this function

@meowjesty
Copy link
Member Author

Moved the error.

This error feels like it's nested deep into some boxes, and I'm not sure how to reproduce the issue to get the error, that's why I'm a bit unsure on how to go about downcast. Do you know how to get an invalid cert error, so I can change it to downcast instead of checking if error contains a string?

mirrord/kube/src/error.rs Outdated Show resolved Hide resolved
mirrord/cli/src/error.rs Outdated Show resolved Hide resolved
mirrord/cli/src/error.rs Outdated Show resolved Hide resolved
@Razz4780
Copy link
Contributor

Razz4780 commented Oct 17, 2024

Moved the error.

This error feels like it's nested deep into some boxes, and I'm not sure how to reproduce the issue to get the error, that's why I'm a bit unsure on how to go about downcast. Do you know how to get an invalid cert error, so I can change it to downcast instead of checking if error contains a string?

I'd try something like this in the test:

  1. Setup an HTTPS server (responds with whatever on all paths) with a randomly generated self-signed certificate
  2. Pass its address as cluster_url in kube::Config
  3. Create a kube client and try listing pods

Copy link
Contributor

@Razz4780 Razz4780 left a comment

Choose a reason for hiding this comment

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

I'd generate the test cert at runtime, but file is also fine by me

mirrord/cli/src/error.rs Outdated Show resolved Hide resolved
@meowjesty meowjesty added this pull request to the merge queue Oct 21, 2024
Merged via the queue into metalbear-co:main with commit 62e7b19 Oct 21, 2024
17 checks passed
@meowjesty meowjesty deleted the issue/2824/better-error-for-invalid-certificate branch October 21, 2024 18:06
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.

Detect invalid certificate error and print better message
2 participants