Commit b543944
committed
feat: add diagnostic hint log when driver cannot reach kube-apiserver 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 #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>1 parent 267a614 commit b543944
2 files changed
Lines changed: 103 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| |||
160 | 162 | | |
161 | 163 | | |
162 | 164 | | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
163 | 168 | | |
164 | 169 | | |
165 | 170 | | |
| |||
190 | 195 | | |
191 | 196 | | |
192 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
193 | 201 | | |
194 | 202 | | |
195 | 203 | | |
| |||
229 | 237 | | |
230 | 238 | | |
231 | 239 | | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
0 commit comments