🐛 webhook: clarify CertDir default and wrap serving-cert load error#3500
🐛 webhook: clarify CertDir default and wrap serving-cert load error#3500alliasgher wants to merge 1 commit intokubernetes-sigs:mainfrom
Conversation
The CertDir default — <temp-dir>/k8s-webhook-server/serving-certs — is driven by os.TempDir(), which on non-Linux systems (and Linux systems with TMPDIR set) is not /tmp. When a user misplaces the serving cert, certwatcher.New returns a bare "no such file or directory" error with no hint that the path is webhook-specific and no pointer to the option they need to set. - Expand the CertDir doc comment to describe the defaulting behavior and recommend operators set it explicitly (typically to the path of a mounted Secret) rather than rely on the temp-dir default. - Wrap the certwatcher.New error so the resulting message names the paths that were attempted, includes the CertDir / CertName / KeyName values, and points at webhook.Server.Options.CertDir as the place to fix things. Fixes kubernetes-sigs#900 Signed-off-by: alliasgher <alliasgher123@gmail.com>
|
Welcome @alliasgher! |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: alliasgher The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @alliasgher. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/ok-to-test |
|
/retest |
|
@alliasgher: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Summary
Addresses the two small, agreed-upon asks from #900:
Before
```
open /tmp/k8s-webhook-server/serving-certs/tls.crt: no such file or directory
```
After
```
failed to load serving cert from "/tmp/k8s-webhook-server/serving-certs/tls.crt" / "/tmp/k8s-webhook-server/serving-certs/tls.key" — did you mount the certificate files at webhook.Server.Options.CertDir? (CertDir="/tmp/k8s-webhook-server/serving-certs", CertName="tls.crt", KeyName="tls.key"): open /tmp/k8s-webhook-server/serving-certs/tls.crt: no such file or directory
```
Fixes #900
Tests
`go build ./pkg/webhook/...` and `go vet ./pkg/webhook/...` pass. No behavior change except the added context on the error path.