From ca87ee091ed2c2248b11bcdcd65252672a4149e0 Mon Sep 17 00:00:00 2001 From: Peter Brachwitz Date: Tue, 20 Oct 2020 15:45:13 +0200 Subject: [PATCH 1/2] Remove unnecessary metrics from _nodes ES API request The operator is not using any information from the jvm or settings metrics filter. --- pkg/controller/elasticsearch/client/client_test.go | 3 +-- pkg/controller/elasticsearch/client/model.go | 6 ------ pkg/controller/elasticsearch/client/v6.go | 4 ++-- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/pkg/controller/elasticsearch/client/client_test.go b/pkg/controller/elasticsearch/client/client_test.go index 74d8d7db9a..d50f92a035 100644 --- a/pkg/controller/elasticsearch/client/client_test.go +++ b/pkg/controller/elasticsearch/client/client_test.go @@ -303,7 +303,7 @@ func TestAPIError_Error(t *testing.T) { } func TestClientGetNodes(t *testing.T) { - expectedPath := "/_nodes/_all/jvm,settings" + expectedPath := "/_nodes/_all/no-metrics" testClient := NewMockClient(version.MustParse("6.8.0"), func(req *http.Request) *http.Response { require.Equal(t, expectedPath, req.URL.Path) return &http.Response{ @@ -318,7 +318,6 @@ func TestClientGetNodes(t *testing.T) { require.Equal(t, 3, len(resp.Nodes)) require.Contains(t, resp.Nodes, "iXqjbgPYThO-6S7reL5_HA") require.ElementsMatch(t, []string{"master", "data", "ingest"}, resp.Nodes["iXqjbgPYThO-6S7reL5_HA"].Roles) - require.Equal(t, 2130051072, resp.Nodes["iXqjbgPYThO-6S7reL5_HA"].JVM.Mem.HeapMaxInBytes) } func TestClientGetNodesStats(t *testing.T) { diff --git a/pkg/controller/elasticsearch/client/model.go b/pkg/controller/elasticsearch/client/model.go index 41c089074c..15f5901291 100644 --- a/pkg/controller/elasticsearch/client/model.go +++ b/pkg/controller/elasticsearch/client/model.go @@ -79,12 +79,6 @@ type Node struct { Name string `json:"name"` Version string `json:"version"` Roles []string `json:"roles"` - JVM struct { - StartTimeInMillis int64 `json:"start_time_in_millis"` - Mem struct { - HeapMaxInBytes int `json:"heap_max_in_bytes"` - } `json:"mem"` - } `json:"jvm"` } func (n Node) isV7OrAbove() (bool, error) { diff --git a/pkg/controller/elasticsearch/client/v6.go b/pkg/controller/elasticsearch/client/v6.go index c1f9755228..f7bbcf14e3 100644 --- a/pkg/controller/elasticsearch/client/v6.go +++ b/pkg/controller/elasticsearch/client/v6.go @@ -94,8 +94,8 @@ func (c *clientV6) ReloadSecureSettings(ctx context.Context) error { func (c *clientV6) GetNodes(ctx context.Context) (Nodes, error) { var nodes Nodes - // restrict call to basic node info only - err := c.get(ctx, "/_nodes/_all/jvm,settings", &nodes) + // restrict call to minimal node information with a non-existing metric filter + err := c.get(ctx, "/_nodes/_all/no-metrics", &nodes) return nodes, err } From 678f301ee6df3b3e1deae8b7b49b8ce5d1bec015 Mon Sep 17 00:00:00 2001 From: Peter Brachwitz Date: Sun, 25 Oct 2020 15:06:29 +0100 Subject: [PATCH 2/2] Update pkg/controller/elasticsearch/client/v6.go Co-authored-by: Anya Sabo --- pkg/controller/elasticsearch/client/v6.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/controller/elasticsearch/client/v6.go b/pkg/controller/elasticsearch/client/v6.go index f7bbcf14e3..94d72f4678 100644 --- a/pkg/controller/elasticsearch/client/v6.go +++ b/pkg/controller/elasticsearch/client/v6.go @@ -94,7 +94,7 @@ func (c *clientV6) ReloadSecureSettings(ctx context.Context) error { func (c *clientV6) GetNodes(ctx context.Context) (Nodes, error) { var nodes Nodes - // restrict call to minimal node information with a non-existing metric filter + // restrict call to minimal node information with a non-existent metric filter err := c.get(ctx, "/_nodes/_all/no-metrics", &nodes) return nodes, err }