Commit 792aba2
authored
fix(active-checks): use HTTP/1.1 for health check probes with automatic version negotiation (#176)
* fix(active-checks): use HTTP/1.1 for health check probes
Previously, active health check probes sent HTTP/1.0 requests, which
caused upstream servers that only support HTTP/1.1 to respond with
426 Upgrade Required, incorrectly marking healthy targets as unhealthy.
Switch the default probe request from HTTP/1.0 to HTTP/1.1 with
Connection: close header. HTTP/1.1 is backward-compatible with all
servers that accept HTTP/1.0, so this change requires no configuration
updates from users.
Refactored run_single_check() into focused helpers:
- build_http_headers(): builds and caches serialized header string
- establish_connection(): TCP connect + optional TLS handshake
- probe_http(): sends HTTP/1.1 GET and reports result
FTI-7389
Signed-off-by: Walker Zhao <walker.zhao@konghq.com>
* fix(active-checks): use HTTP/1.1 for health check probes with auto-fallback
Previously, active health check probes sent HTTP/1.0 requests. Upstream
servers that only support HTTP/1.1 would respond with 426 (Upgrade
Required), which is not in the default healthy/unhealthy status lists,
causing health checks to silently become no-ops for those targets.
Switch the default probe request from HTTP/1.0 to HTTP/1.1 with a
Connection: close header. Add bidirectional version auto-detection in
run_single_check() that automatically negotiates the HTTP version:
- On 505 (HTTP Version Not Supported): retry with the other version
- On 426 (Upgrade Required) while using HTTP/1.0: retry with HTTP/1.1
- On any non-healthy status with no cached version: retry with the
other version to handle non-standard server implementations
The working HTTP version is cached per-target in memory to avoid
repeated retries. The cache self-heals when servers change their
supported HTTP version.
Refactored run_single_check() into focused helpers:
- build_http_headers(): builds and caches serialized header string
- establish_connection(): TCP connect + optional TLS handshake
- probe_http(): sends HTTP request and returns status code
FTI-7389
Signed-off-by: Walker Zhao <walker.zhao@konghq.com>
* refactor(active-checks): extract negotiate_http_version() and simplify retry logic
Extract the HTTP version negotiation logic from run_single_check() into
a dedicated negotiate_http_version() local function, reducing
run_single_check() from ~85 lines to ~20 lines with flat control flow.
Remove the unknown-status retry trigger and http_version_locked flag,
keeping only 3 clear retry triggers: 505, 426-on-1.0, and
non-healthy-with-no-cache. Unknown status codes are silently ignored
by report_http_status(), matching the original behavior.
Fix bad status line handling: probe_http() now returns 0 instead of
nil for malformed HTTP responses, preserving the original behavior
where report_http_status() treats 0 as unhealthy. Previously, the
refactor caused these to be silently ignored.
FTI-7389
Signed-off-by: Walker Zhao <walker.zhao@konghq.com>
* fix(active-checks): narrow version negotiation retry to only 505 and 426 status codes
Remove overly broad trigger that retried on any non-healthy status for
uncached targets, which caused unnecessary retry connections for
genuinely unhealthy servers (e.g., 500). Now only standard HTTP version
negotiation codes (505 HTTP Version Not Supported, 426 Upgrade Required)
trigger a retry, gated on `not is_healthy` to respect user-configured
healthy status lists while preserving self-healing for cached targets.
Signed-off-by: Walker Zhao <walker.zhao@konghq.com>
---------
Signed-off-by: Walker Zhao <walker.zhao@konghq.com>1 parent 1566027 commit 792aba2
File tree
5 files changed
+1330
-79
lines changed- lib/resty
- t
- with_resty-events
- with_worker-events
5 files changed
+1330
-79
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
985 | 985 | | |
986 | 986 | | |
987 | 987 | | |
988 | | - | |
989 | | - | |
990 | | - | |
991 | | - | |
992 | | - | |
993 | | - | |
994 | | - | |
995 | | - | |
996 | | - | |
997 | | - | |
998 | | - | |
999 | | - | |
1000 | | - | |
1001 | | - | |
1002 | | - | |
1003 | | - | |
1004 | | - | |
1005 | | - | |
1006 | | - | |
1007 | | - | |
1008 | | - | |
1009 | | - | |
1010 | | - | |
1011 | | - | |
1012 | | - | |
1013 | | - | |
1014 | | - | |
1015 | | - | |
1016 | | - | |
1017 | | - | |
1018 | | - | |
1019 | | - | |
1020 | | - | |
1021 | | - | |
1022 | | - | |
1023 | | - | |
1024 | | - | |
1025 | | - | |
1026 | | - | |
1027 | | - | |
1028 | | - | |
1029 | | - | |
1030 | | - | |
1031 | | - | |
1032 | | - | |
1033 | | - | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
1034 | 993 | | |
1035 | 994 | | |
1036 | 995 | | |
1037 | 996 | | |
1038 | | - | |
1039 | | - | |
1040 | | - | |
1041 | | - | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
1042 | 1000 | | |
1043 | 1001 | | |
1044 | 1002 | | |
| |||
1065 | 1023 | | |
1066 | 1024 | | |
1067 | 1025 | | |
1068 | | - | |
1069 | 1026 | | |
1070 | 1027 | | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
1071 | 1089 | | |
1072 | | - | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
1073 | 1099 | | |
1074 | 1100 | | |
1075 | | - | |
1076 | | - | |
| 1101 | + | |
1077 | 1102 | | |
1078 | 1103 | | |
1079 | 1104 | | |
1080 | 1105 | | |
1081 | | - | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
1082 | 1109 | | |
1083 | | - | |
| 1110 | + | |
1084 | 1111 | | |
1085 | 1112 | | |
1086 | 1113 | | |
| |||
1089 | 1116 | | |
1090 | 1117 | | |
1091 | 1118 | | |
1092 | | - | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
1093 | 1122 | | |
1094 | | - | |
| 1123 | + | |
1095 | 1124 | | |
1096 | 1125 | | |
1097 | 1126 | | |
| |||
1102 | 1131 | | |
1103 | 1132 | | |
1104 | 1133 | | |
1105 | | - | |
| 1134 | + | |
1106 | 1135 | | |
1107 | 1136 | | |
1108 | 1137 | | |
1109 | 1138 | | |
1110 | 1139 | | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
1111 | 1229 | | |
1112 | 1230 | | |
1113 | 1231 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
83 | | - | |
| 82 | + | |
84 | 83 | | |
| 84 | + | |
| 85 | + | |
85 | 86 | | |
86 | 87 | | |
87 | 88 | | |
| |||
128 | 129 | | |
129 | 130 | | |
130 | 131 | | |
131 | | - | |
132 | | - | |
| 132 | + | |
133 | 133 | | |
| 134 | + | |
| 135 | + | |
134 | 136 | | |
135 | 137 | | |
136 | 138 | | |
| |||
176 | 178 | | |
177 | 179 | | |
178 | 180 | | |
179 | | - | |
180 | | - | |
| 181 | + | |
181 | 182 | | |
| 183 | + | |
| 184 | + | |
182 | 185 | | |
183 | 186 | | |
184 | 187 | | |
| |||
225 | 228 | | |
226 | 229 | | |
227 | 230 | | |
228 | | - | |
229 | | - | |
| 231 | + | |
230 | 232 | | |
| 233 | + | |
| 234 | + | |
231 | 235 | | |
232 | 236 | | |
233 | 237 | | |
| |||
274 | 278 | | |
275 | 279 | | |
276 | 280 | | |
277 | | - | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
278 | 284 | | |
279 | 285 | | |
280 | | - | |
| |||
0 commit comments