fix: return 404 (not 502) when function Service is gone (DNS no such host)
After trigger/function destroy the Service is deleted, DNS lookup fails with 'no such host'. Previously InvokeFunction returned 502 which kept the test script retrying for 120s. Now returns 404 — endpoint removed, test passes. Operator: naeel/sless-operator:v0.1.18
This commit is contained in:
@@ -59,6 +59,12 @@ func (h *Handler) InvokeFunction(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
resp, err := httpClient.Do(proxyReq)
|
resp, err := httpClient.Do(proxyReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
// "no such host" — Service не существует (функция удалена), возвращаем 404.
|
||||||
|
// Это отличается от временной сетевой ошибки: NXDOMAIN строго означает отсутствие записи.
|
||||||
|
if strings.Contains(err.Error(), "no such host") {
|
||||||
|
writeJSON(w, http.StatusNotFound, errResp("function not found"))
|
||||||
|
return
|
||||||
|
}
|
||||||
h.Log.Error("invoke: function unreachable", "err", err, "ns", ns, "fn", name, "target", target)
|
h.Log.Error("invoke: function unreachable", "err", err, "ns", ns, "fn", name, "target", target)
|
||||||
writeJSON(w, http.StatusBadGateway, errResp("function unreachable: "+err.Error()))
|
writeJSON(w, http.StatusBadGateway, errResp("function unreachable: "+err.Error()))
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user