From e2168d21c7afb2d75b57e17882058f23cea14054 Mon Sep 17 00:00:00 2001 From: Matt Hook Date: Tue, 7 Feb 2023 23:13:52 +1300 Subject: [PATCH] guard around kube actions for endpoint inspect (#8430) --- .../handler/endpoints/endpoint_inspect.go | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/api/http/handler/endpoints/endpoint_inspect.go b/api/http/handler/endpoints/endpoint_inspect.go index 82691236d..4546e4499 100644 --- a/api/http/handler/endpoints/endpoint_inspect.go +++ b/api/http/handler/endpoints/endpoint_inspect.go @@ -52,22 +52,24 @@ func (handler *Handler) endpointInspect(w http.ResponseWriter, r *http.Request) } } - isServerMetricsDetected := endpoint.Kubernetes.Flags.IsServerMetricsDetected - if endpointutils.IsKubernetesEndpoint(endpoint) && !isServerMetricsDetected && handler.K8sClientFactory != nil { - endpointutils.InitialMetricsDetection( - endpoint, - handler.DataStore.Endpoint(), - handler.K8sClientFactory, - ) - } + if endpointutils.IsKubernetesEndpoint(endpoint) { + isServerMetricsDetected := endpoint.Kubernetes.Flags.IsServerMetricsDetected + if !isServerMetricsDetected && handler.K8sClientFactory != nil { + endpointutils.InitialMetricsDetection( + endpoint, + handler.DataStore.Endpoint(), + handler.K8sClientFactory, + ) + } - isServerStorageDetected := endpoint.Kubernetes.Flags.IsServerStorageDetected - if !isServerStorageDetected && handler.K8sClientFactory != nil { - endpointutils.InitialStorageDetection( - endpoint, - handler.DataStore.Endpoint(), - handler.K8sClientFactory, - ) + isServerStorageDetected := endpoint.Kubernetes.Flags.IsServerStorageDetected + if !isServerStorageDetected && handler.K8sClientFactory != nil { + endpointutils.InitialStorageDetection( + endpoint, + handler.DataStore.Endpoint(), + handler.K8sClientFactory, + ) + } } return response.JSON(w, endpoint)