From 5a121ff7e2874e81150ddcd522a0326e4194f613 Mon Sep 17 00:00:00 2001 From: thomasgouveia Date: Fri, 26 May 2023 11:48:05 +0000 Subject: [PATCH] fix(controller): healthcheck for instances Healthcheck was not successful as we did not check the response code returned by the instance. Signed-off-by: thomasgouveia --- controller/api/handlers/invoke-function.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controller/api/handlers/invoke-function.go b/controller/api/handlers/invoke-function.go index 4c1e55e..2eaa4f3 100644 --- a/controller/api/handlers/invoke-function.go +++ b/controller/api/handlers/invoke-function.go @@ -60,7 +60,7 @@ func InvokeFunctionHandler(s state.State, orch orchestration.Orchestrator) gin.H healthcheck := instance.Endpoint.String() + "/_/health" for i := 0; i < maxHealthcheckRetries; i++ { log.Debugf("Performing healthcheck request on Alpha: %s", healthcheck) - if _, err := http.Get(healthcheck); err != nil { + if res, err := http.Get(healthcheck); err != nil || res.StatusCode != http.StatusOK { if i == maxHealthcheckRetries-1 { log.Errorf("failed to perform healthcheck on Alpha: %v", err) c.JSON(http.StatusServiceUnavailable, makeApiError(ErrFunctionCantBeMarkedAsHealthy))