From 72e4137b0a098c2337c223cd47e2789aa736c099 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Mon, 9 Mar 2026 20:03:08 +0400 Subject: [PATCH] fix: return 404 (not 502) when function Service is gone (DNS no such host) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- internal/api/handler/invoke.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/api/handler/invoke.go b/internal/api/handler/invoke.go index 797cab3..7aa641f 100644 --- a/internal/api/handler/invoke.go +++ b/internal/api/handler/invoke.go @@ -59,6 +59,12 @@ func (h *Handler) InvokeFunction(w http.ResponseWriter, r *http.Request) { resp, err := httpClient.Do(proxyReq) 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) writeJSON(w, http.StatusBadGateway, errResp("function unreachable: "+err.Error())) return