Skip to content

feat: add diagnostic hint log when driver cannot reach kube-apiserver on startup - #2055

Open
pujitha24 wants to merge 1 commit into
kubernetes-sigs:mainfrom
pujitha24:auto/issue-1753
Open

feat: add diagnostic hint log when driver cannot reach kube-apiserver on startup#2055
pujitha24 wants to merge 1 commit into
kubernetes-sigs:mainfrom
pujitha24:auto/issue-1753

Conversation

@pujitha24

Copy link
Copy Markdown

/kind feature

What this PR does / why we need it:

Motivation:
When the driver fails to start because it cannot reach the kube-apiserver
(e.g. RESTMapper/discovery client construction in ctrl.NewManager, or cache
sync in mgr.Start failing due to DNS, connection refused, or timeouts), the
existing logs ("failed to start manager", "failed to run manager") give no
hint about the likely root cause. Issue #1753 reports exactly this: a driver
pod failed to initialize with only a generic wrapped error, with no guidance
that network connectivity to the kube-apiserver should be checked.

Approach:
Add an isNetworkError helper in cmd/secrets-store-csi-driver/main.go that
classifies an error as network-related if it unwraps to a net.Error (covers
*net.DNSError, *net.OpError, etc.) or its message contains one of a small
set of well-known connectivity failure substrings ("connection refused", "no
such host", "i/o timeout", "context deadline exceeded"). When this helper
returns true at the two manager-startup failure points, an additional
klog.ErrorS call logs: "the driver is unable to communicate with the
kube-apiserver, check network connectivity between the node and the
kube-apiserver". This mirrors the existing isMaxRecvMsgSizeError pattern in
pkg/secrets-store/provider_client.go.

This change is purely additive: it does not alter control flow, return
values, exit codes, or any existing log message. The original error is still
logged and returned/panicked exactly as before; only an extra diagnostic log
line is emitted when the error looks network-related. User-visible behavior
(pod restarts on manager start failure) is unchanged before/after this fix —
the benefit is a clearer, more actionable log line for operators debugging a
non-starting driver pod, not a change in recovery behavior.

Validation:

  • go build ./... passes.
  • go test ./cmd/... -v passes, including the new table-driven
    TestIsNetworkError covering nil errors, unrelated errors, wrapped
    net.DNSError, and each of the matched substring cases.
  • gofmt -l and go vet ./cmd/... report no issues.

Fixes #1753

Signed-off-by: Pujitha Paladugu 10557236+pujitha24@users.noreply.github.com

… on startup

/kind feature

**What this PR does / why we need it**:

Motivation:
When the driver fails to start because it cannot reach the kube-apiserver
(e.g. RESTMapper/discovery client construction in ctrl.NewManager, or cache
sync in mgr.Start failing due to DNS, connection refused, or timeouts), the
existing logs ("failed to start manager", "failed to run manager") give no
hint about the likely root cause. Issue kubernetes-sigs#1753 reports exactly this: a driver
pod failed to initialize with only a generic wrapped error, with no guidance
that network connectivity to the kube-apiserver should be checked.

Approach:
Add an `isNetworkError` helper in cmd/secrets-store-csi-driver/main.go that
classifies an error as network-related if it unwraps to a `net.Error` (covers
`*net.DNSError`, `*net.OpError`, etc.) or its message contains one of a small
set of well-known connectivity failure substrings ("connection refused", "no
such host", "i/o timeout", "context deadline exceeded"). When this helper
returns true at the two manager-startup failure points, an additional
klog.ErrorS call logs: "the driver is unable to communicate with the
kube-apiserver, check network connectivity between the node and the
kube-apiserver". This mirrors the existing isMaxRecvMsgSizeError pattern in
pkg/secrets-store/provider_client.go.

This change is purely additive: it does not alter control flow, return
values, exit codes, or any existing log message. The original error is still
logged and returned/panicked exactly as before; only an extra diagnostic log
line is emitted when the error looks network-related. User-visible behavior
(pod restarts on manager start failure) is unchanged before/after this fix —
the benefit is a clearer, more actionable log line for operators debugging a
non-starting driver pod, not a change in recovery behavior.

Validation:
- `go build ./...` passes.
- `go test ./cmd/... -v` passes, including the new table-driven
  TestIsNetworkError covering nil errors, unrelated errors, wrapped
  net.DNSError, and each of the matched substring cases.
- `gofmt -l` and `go vet ./cmd/...` report no issues.

Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 27, 2026 20:59
@kubernetes-prow kubernetes-prow Bot added do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. kind/feature Categorizes issue or PR as related to a new feature. labels Jul 27, 2026
@kubernetes-prow

Copy link
Copy Markdown

This issue is currently awaiting triage.

If secrets-store-csi-driver contributors determine this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Details

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

@kubernetes-prow kubernetes-prow Bot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Jul 27, 2026
@kubernetes-prow

Copy link
Copy Markdown

Welcome @pujitha24!

It looks like this is your first PR to kubernetes-sigs/secrets-store-csi-driver 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/secrets-store-csi-driver has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@kubernetes-prow kubernetes-prow Bot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 27, 2026
@kubernetes-prow

Copy link
Copy Markdown

Hi @pujitha24. 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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

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

@kubernetes-prow kubernetes-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 27, 2026
@kubernetes-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: pujitha24
Once this PR has been reviewed and has the lgtm label, please assign enj for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR improves startup troubleshooting by emitting an additional, actionable log hint when the driver appears unable to communicate with the kube-apiserver during manager initialization or startup, helping operators diagnose common node→apiserver connectivity failures.

Changes:

  • Added isNetworkError in cmd/secrets-store-csi-driver/main.go to classify likely kube-apiserver connectivity-related startup errors.
  • Emitted an extra klog.ErrorS hint at both manager construction and manager start failure points when isNetworkError matches.
  • Added a table-driven unit test for isNetworkError.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
cmd/secrets-store-csi-driver/main.go Adds network-error classification and an extra diagnostic hint log on manager startup failures.
cmd/secrets-store-csi-driver/main_test.go Adds unit tests covering isNetworkError classification behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +165 to +167
if isNetworkError(err) {
klog.ErrorS(err, "the driver is unable to communicate with the kube-apiserver, check network connectivity between the node and the kube-apiserver")
}
@enj enj added this to SIG Auth Jul 28, 2026
@enj enj moved this to Subprojects - Needs Triage in SIG Auth Jul 28, 2026
@kubernetes-prow kubernetes-prow Bot removed the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Better error reporting

3 participants