From b1c3bfbb03dad681bb81d1cf4e313b260d9b1ae1 Mon Sep 17 00:00:00 2001 From: Periklis Tsirakidis Date: Thu, 17 Dec 2020 17:15:46 +0100 Subject: [PATCH] Bug 1907758: Fix update replica count for logging indices only --- pkg/elasticsearch/client.go | 5 +++++ pkg/elasticsearch/replicas.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/elasticsearch/client.go b/pkg/elasticsearch/client.go index c3ff122a9..142d51067 100644 --- a/pkg/elasticsearch/client.go +++ b/pkg/elasticsearch/client.go @@ -179,6 +179,7 @@ func sendEsRequest(cluster, namespace string, payload *EsRequest, client k8sclie // TODO: eventually remove after all ES images have been updated to use SA token auth for EO? if resp.StatusCode == http.StatusForbidden || resp.StatusCode == http.StatusUnauthorized { + log.Info("failed sending payload using bearer token", "method", payload.Method, "url", payload.URI) // if we get a 401 that means that we couldn't read from the token and provided // no header. // if we get a 403 that means the ES cluster doesn't allow us to use @@ -252,6 +253,10 @@ func sendRequestWithMTlsClient(clusterName, namespace string, payload *EsRequest resp, err := httpClient.Do(request) if resp != nil { + if resp.StatusCode == http.StatusForbidden || resp.StatusCode == http.StatusUnauthorized { + log.Info("failed sending payload using mTLS PKI", "method", payload.Method, "url", payload.URI) + } + payload.StatusCode = resp.StatusCode if payload.RawResponseBody, err = getRawBody(resp.Body); err != nil { log.Error(err, "failed to get raw response body") diff --git a/pkg/elasticsearch/replicas.go b/pkg/elasticsearch/replicas.go index 2d9374f3b..bc183afae 100644 --- a/pkg/elasticsearch/replicas.go +++ b/pkg/elasticsearch/replicas.go @@ -55,7 +55,7 @@ func (ec *esClient) updateAllIndexReplicas(replicaCount int32) (bool, error) { func (ec *esClient) GetIndexReplicaCounts() (map[string]interface{}, error) { payload := &EsRequest{ Method: http.MethodGet, - URI: "*/_settings/index.number_of_replicas", + URI: "app-*,infra-*,audit-*/_settings/index.number_of_replicas", } ec.fnSendEsRequest(ec.cluster, ec.namespace, payload, ec.k8sClient)