Commit 4d6bd6b
committed
fix: map proxy errors to correct HTTP status codes
Previously, the apiserver-network-proxy returned a blanket 503 (Service
Unavailable) status for all backend connection failures, which was
incorrect for a proxy server. Additionally, HTTP CONNECT mode would send
200 OK immediately after hijacking, preventing proper error reporting
but also violating HTTP CONNECT protocol
This commit:
- Adds mapDialErrorToHTTPStatus() to map TCP/network errors to appropriate
HTTP status codes:
* 502 Bad Gateway: connection refused, DNS failures, network unreachable
* 503 Service Unavailable: resource exhaustion (too many open files)
* 504 Gateway Timeout: I/O timeouts, deadline exceeded
- Delays sending "200 Connection Established" until after successful
backend connection in HTTP CONNECT mode
- Ensures proper HTTP/1.1 protocol version in error responses
- Preserves original error messages in response body for debugging
Signed-off-by: Imran Pochi <[email protected]>1 parent 3737fb2 commit 4d6bd6b
2 files changed
+76
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
111 | 158 | | |
112 | 159 | | |
113 | 160 | | |
| |||
122 | 169 | | |
123 | 170 | | |
124 | 171 | | |
125 | | - | |
126 | | - | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
127 | 178 | | |
128 | | - | |
| 179 | + | |
| 180 | + | |
129 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
130 | 187 | | |
131 | 188 | | |
132 | 189 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | 63 | | |
72 | 64 | | |
73 | 65 | | |
| |||
110 | 102 | | |
111 | 103 | | |
112 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
113 | 108 | | |
114 | 109 | | |
115 | 110 | | |
116 | 111 | | |
117 | | - | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
118 | 116 | | |
119 | 117 | | |
120 | 118 | | |
| |||
125 | 123 | | |
126 | 124 | | |
127 | 125 | | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
128 | 135 | | |
129 | 136 | | |
130 | 137 | | |
| |||
0 commit comments