From 4d28e66d9561015ec1b62d4b70eaba83722c192d Mon Sep 17 00:00:00 2001 From: warber Date: Tue, 3 Oct 2023 16:04:27 +0200 Subject: [PATCH] fix: use retries in case app-detection-rule could not be deployed Signed-off-by: Bernd Warmuth --- pkg/client/dtclient/config_client.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/client/dtclient/config_client.go b/pkg/client/dtclient/config_client.go index eab569bd2e..e0ccfd26ef 100644 --- a/pkg/client/dtclient/config_client.go +++ b/pkg/client/dtclient/config_client.go @@ -322,6 +322,7 @@ func isApplicationNotReadyYet(resp rest.Response, theApi api.API) bool { return isCalculatedMetricsError(resp, theApi) || isSyntheticMonitorServerError(resp, theApi) || isApplicationAPIError(resp, theApi) || + isApplicationRule5xx(resp, theApi) || strings.Contains(string(resp.Body), "Unknown application(s)") } @@ -341,6 +342,13 @@ func isApplicationAPIError(resp rest.Response, theApi api.API) bool { (resp.Is5xxError() || resp.StatusCode == http.StatusConflict || resp.StatusCode == http.StatusNotFound) } +// Special case (workaround): +// Sometimes, the API returns 500 Internal Server Error e.g. when an application referenced by +// an application detection rule is not fully "ready" yet. +func isApplicationRule5xx(resp rest.Response, theApi api.API) bool { + return theApi.ID == "app-detection-rule" && resp.Is5xxError() +} + func isCredentialNotReadyYet(resp rest.Response) bool { s := string(resp.Body) return strings.Contains(s, "credential-vault") &&