From 70a1424ffa6323e2775facdb74e6159995d0e034 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 00:38:00 +0100 Subject: [PATCH 1/4] build(deps): bump github.com/goreleaser/nfpm/v2 (#14464) Bumps the dependencies group in /tools with 1 update: [github.com/goreleaser/nfpm/v2](https://github.com/goreleaser/nfpm). Updates `github.com/goreleaser/nfpm/v2` from 2.40.0 to 2.41.0 - [Release notes](https://github.com/goreleaser/nfpm/releases) - [Changelog](https://github.com/goreleaser/nfpm/blob/main/.goreleaser.yml) - [Commits](https://github.com/goreleaser/nfpm/compare/v2.40.0...v2.41.0) --- updated-dependencies: - dependency-name: github.com/goreleaser/nfpm/v2 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: dependencies ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- tools/go.mod | 4 ++-- tools/go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/go.mod b/tools/go.mod index 8b7a7226c63..cde10f7ae18 100644 --- a/tools/go.mod +++ b/tools/go.mod @@ -7,7 +7,7 @@ require ( github.com/elastic/apm-tools v0.0.0-20230828065051-3f799314cc8b github.com/elastic/go-licenser v0.4.2 github.com/elastic/gobench v0.0.0-20220608141032-f30bc57e329c - github.com/goreleaser/nfpm/v2 v2.40.0 + github.com/goreleaser/nfpm/v2 v2.41.0 github.com/josephspurrier/goversioninfo v1.4.1 github.com/t-yuki/gocover-cobertura v0.0.0-20180217150009-aaee18c8195c github.com/terraform-docs/terraform-docs v0.19.0 @@ -76,7 +76,7 @@ require ( github.com/invopop/jsonschema v0.12.0 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect - github.com/klauspost/compress v1.17.10 // indirect + github.com/klauspost/compress v1.17.11 // indirect github.com/klauspost/pgzip v1.2.6 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/magiconair/properties v1.8.7 // indirect diff --git a/tools/go.sum b/tools/go.sum index 837f563f5b8..80dc5bd889f 100644 --- a/tools/go.sum +++ b/tools/go.sum @@ -135,8 +135,8 @@ github.com/goreleaser/chglog v0.6.1 h1:NZKiX8l0FTQPRzBgKST7knvNZmZ04f7PEGkN2wInf github.com/goreleaser/chglog v0.6.1/go.mod h1:Bnnfo07jMZkaAb0uRNASMZyOsX6ROW6X1qbXqN3guUo= github.com/goreleaser/fileglob v1.3.0 h1:/X6J7U8lbDpQtBvGcwwPS6OpzkNVlVEsFUVRx9+k+7I= github.com/goreleaser/fileglob v1.3.0/go.mod h1:Jx6BoXv3mbYkEzwm9THo7xbr5egkAraxkGorbJb4RxU= -github.com/goreleaser/nfpm/v2 v2.40.0 h1:M6WaaHeTCgNopUo9e8zgeHlOiN65LZAKqogzCJXBwYQ= -github.com/goreleaser/nfpm/v2 v2.40.0/go.mod h1:i9IfzvnHInDQohFs7iVHpWBoGaSDRp0+KG7KzNUXzns= +github.com/goreleaser/nfpm/v2 v2.41.0 h1:JyMzS/EwqaWbFs+7Z9oZ4Hkk4or00gUTqwm9Dgr8QYg= +github.com/goreleaser/nfpm/v2 v2.41.0/go.mod h1:VPc5kF5OgfA+BosV/A2aB+Vg34honjWvp0Vt8ogsSi0= github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k= github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= github.com/hashicorp/go-plugin v1.6.1 h1:P7MR2UP6gNKGPp+y7EZw2kOiq4IR9WiqLvp0XOsVdwI= @@ -172,8 +172,8 @@ github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7 github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= -github.com/klauspost/compress v1.17.10 h1:oXAz+Vh0PMUvJczoi+flxpnBEPxoER1IaAnU/NMPtT0= -github.com/klauspost/compress v1.17.10/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0= +github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc= +github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0= github.com/klauspost/pgzip v1.2.6 h1:8RXeL5crjEUFnR2/Sn6GJNWtSQ3Dk8pq4CL3jvdDyjU= github.com/klauspost/pgzip v1.2.6/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= From 182ee133d60869af2fb1201511e1b3cae9799df4 Mon Sep 17 00:00:00 2001 From: "elastic-observability-automation[bot]" <180520183+elastic-observability-automation[bot]@users.noreply.github.com> Date: Mon, 28 Oct 2024 23:50:08 +0000 Subject: [PATCH 2/4] [updatecli] Bump elastic stack version to 9.0.0-0bb510c0 (#14455) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: Update k8s stack yaml files Made with ❤️️ by updatecli * chore: Update docker-compose.yml Made with ❤️️ by updatecli --------- Co-authored-by: elastic-observability-automation[bot] <180520183+elastic-observability-automation[bot]@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- docker-compose.yml | 6 +++--- testing/infra/k8s/base/stack/apm-server.yaml | 2 +- testing/infra/k8s/base/stack/elasticsearch.yaml | 2 +- testing/infra/k8s/base/stack/kibana.yaml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index d4d8ec45416..c21178a10cb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,7 +11,7 @@ x-logging: &default-logging services: elasticsearch: # TODO: replace with a pinned version such as 9.0.0-aaaaaaaa-SNAPSHOT - image: docker.elastic.co/elasticsearch/elasticsearch:9.0.0-862b23c2-SNAPSHOT + image: docker.elastic.co/elasticsearch/elasticsearch:9.0.0-0bb510c0-SNAPSHOT ports: - 9200:9200 healthcheck: @@ -43,7 +43,7 @@ services: kibana: # TODO: replace with a pinned version such as 9.0.0-aaaaaaaa-SNAPSHOT - image: docker.elastic.co/kibana/kibana:9.0.0-862b23c2-SNAPSHOT + image: docker.elastic.co/kibana/kibana:9.0.0-0bb510c0-SNAPSHOT ports: - 5601:5601 healthcheck: @@ -63,7 +63,7 @@ services: metricbeat: # TODO: replace with a pinned version such as 9.0.0-aaaaaaaa-SNAPSHOT - image: docker.elastic.co/beats/metricbeat:9.0.0-862b23c2-SNAPSHOT + image: docker.elastic.co/beats/metricbeat:9.0.0-0bb510c0-SNAPSHOT environment: ELASTICSEARCH_HOSTS: '["http://elasticsearch:9200"]' ELASTICSEARCH_USERNAME: "${KIBANA_ES_USER:-admin}" diff --git a/testing/infra/k8s/base/stack/apm-server.yaml b/testing/infra/k8s/base/stack/apm-server.yaml index 8cd056b88e4..f1cb91a0a69 100644 --- a/testing/infra/k8s/base/stack/apm-server.yaml +++ b/testing/infra/k8s/base/stack/apm-server.yaml @@ -4,7 +4,7 @@ metadata: name: apm-server spec: # TODO: replace with a pinned version such as 9.0.0-aaaaaaaa-SNAPSHOT - version: 9.0.0-862b23c2-SNAPSHOT + version: 9.0.0-0bb510c0-SNAPSHOT count: 1 http: tls: diff --git a/testing/infra/k8s/base/stack/elasticsearch.yaml b/testing/infra/k8s/base/stack/elasticsearch.yaml index 5d9ba0ec6c0..845205ee40c 100644 --- a/testing/infra/k8s/base/stack/elasticsearch.yaml +++ b/testing/infra/k8s/base/stack/elasticsearch.yaml @@ -4,7 +4,7 @@ metadata: name: elasticsearch spec: # TODO: replace with a pinned version such as 9.0.0-aaaaaaaa-SNAPSHOT - version: 9.0.0-862b23c2-SNAPSHOT + version: 9.0.0-0bb510c0-SNAPSHOT auth: fileRealm: - secretName: elasticsearch-admin diff --git a/testing/infra/k8s/base/stack/kibana.yaml b/testing/infra/k8s/base/stack/kibana.yaml index c119b75fbe8..7333bb40ccf 100644 --- a/testing/infra/k8s/base/stack/kibana.yaml +++ b/testing/infra/k8s/base/stack/kibana.yaml @@ -4,7 +4,7 @@ metadata: name: kibana spec: # TODO: replace with a pinned version such as 9.0.0-aaaaaaaa-SNAPSHOT - version: 9.0.0-862b23c2-SNAPSHOT + version: 9.0.0-0bb510c0-SNAPSHOT count: 1 elasticsearchRef: name: elasticsearch From 2afc738efcbcbcbf0d2d807ecbdd1028adedf418 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 00:09:35 +0000 Subject: [PATCH 3/4] build(deps): bump the dependencies group in /systemtest with 2 updates (#14463) Bumps the dependencies group in /systemtest with 2 updates: [go.opentelemetry.io/collector/pdata](https://github.com/open-telemetry/opentelemetry-collector) and [go.opentelemetry.io/collector/semconv](https://github.com/open-telemetry/opentelemetry-collector). Updates `go.opentelemetry.io/collector/pdata` from 1.17.0 to 1.18.0 - [Release notes](https://github.com/open-telemetry/opentelemetry-collector/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-collector/blob/main/CHANGELOG-API.md) - [Commits](https://github.com/open-telemetry/opentelemetry-collector/compare/pdata/v1.17.0...pdata/v1.18.0) Updates `go.opentelemetry.io/collector/semconv` from 0.111.0 to 0.112.0 - [Release notes](https://github.com/open-telemetry/opentelemetry-collector/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-collector/blob/main/CHANGELOG-API.md) - [Commits](https://github.com/open-telemetry/opentelemetry-collector/compare/v0.111.0...v0.112.0) --- updated-dependencies: - dependency-name: go.opentelemetry.io/collector/pdata dependency-type: direct:production update-type: version-update:semver-minor dependency-group: dependencies - dependency-name: go.opentelemetry.io/collector/semconv dependency-type: direct:production update-type: version-update:semver-minor dependency-group: dependencies ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- systemtest/go.mod | 4 ++-- systemtest/go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/systemtest/go.mod b/systemtest/go.mod index fea21551317..ea9e3f54545 100644 --- a/systemtest/go.mod +++ b/systemtest/go.mod @@ -18,8 +18,8 @@ require ( github.com/tidwall/gjson v1.18.0 go.elastic.co/apm/v2 v2.6.2 go.elastic.co/fastjson v1.4.0 - go.opentelemetry.io/collector/pdata v1.17.0 - go.opentelemetry.io/collector/semconv v0.111.0 + go.opentelemetry.io/collector/pdata v1.18.0 + go.opentelemetry.io/collector/semconv v0.112.0 go.opentelemetry.io/otel v1.31.0 go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.31.0 go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.31.0 diff --git a/systemtest/go.sum b/systemtest/go.sum index 86ef6461e73..4a51ef141c9 100644 --- a/systemtest/go.sum +++ b/systemtest/go.sum @@ -176,10 +176,10 @@ go.elastic.co/apm/v2 v2.6.2 h1:VBplAxgbOgTv+Giw/FS91xJpHYw/q8fz/XKPvqC+7/o= go.elastic.co/apm/v2 v2.6.2/go.mod h1:33rOXgtHwbgZcDgi6I/GtCSMZQqgxkHC0IQT3gudKvo= go.elastic.co/fastjson v1.4.0 h1:a4BXUKXZHAzjVOPrqtEx2FDsIRBCMek01vCnrtyutWs= go.elastic.co/fastjson v1.4.0/go.mod h1:ZD5um63l0/8TIdddZbL2znD83FAr2IckYa3KR7VcdNA= -go.opentelemetry.io/collector/pdata v1.17.0 h1:z8cjjT2FThAehWu5fbF48OnZyK5q8xd1UhC4XszDo0w= -go.opentelemetry.io/collector/pdata v1.17.0/go.mod h1:yZaQ9KZAm/qie96LTygRKxOXMq0/54h8OW7330ycuvQ= -go.opentelemetry.io/collector/semconv v0.111.0 h1:ELleMtLBzeZ3xhfhYPmFcLc0hJMqRxhOB0eY60WLivw= -go.opentelemetry.io/collector/semconv v0.111.0/go.mod h1:zCJ5njhWpejR+A40kiEoeFm1xq1uzyZwMnRNX6/D82A= +go.opentelemetry.io/collector/pdata v1.18.0 h1:/yg2rO2dxqDM2p6GutsMCxXN6sKlXwyIz/ZYyUPONBg= +go.opentelemetry.io/collector/pdata v1.18.0/go.mod h1:Ox1YVLe87cZDB/TL30i4SUz1cA5s6AM6SpFMfY61ICs= +go.opentelemetry.io/collector/semconv v0.112.0 h1:JPQyvZhlNLVSuVI+FScONaiFygB7h7NTZceUEKIQUEc= +go.opentelemetry.io/collector/semconv v0.112.0/go.mod h1:zCJ5njhWpejR+A40kiEoeFm1xq1uzyZwMnRNX6/D82A= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.55.0 h1:ZIg3ZT/aQ7AfKqdwp7ECpOK6vHqquXXuyTjIO8ZdmPs= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.55.0/go.mod h1:DQAwmETtZV00skUwgD6+0U89g80NKsJE3DCKeLLPQMI= go.opentelemetry.io/otel v1.31.0 h1:NsJcKPIW0D0H3NgzPDHmo0WW6SptzPdqg/L1zsIm2hY= From 24d222293d898a43c8939de5a460cd54b0f9a64f Mon Sep 17 00:00:00 2001 From: Edoardo Tenani <526307+endorama@users.noreply.github.com> Date: Tue, 29 Oct 2024 11:51:50 +0100 Subject: [PATCH 4/4] Test retry behavior of elasticsearch wrapper client (#14433) * add es client retry test Test retry behaviour on our Elasticsearch client wrapper. We only want to retry on 429 status code, the test accounts for this specific behaviour and also verifies that other response code are not retried. * fix lint * remove unnecessary handlers * remove esMock struct Due to previous refactoring this is not needed anymore --- internal/elasticsearch/client_test.go | 91 +++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/internal/elasticsearch/client_test.go b/internal/elasticsearch/client_test.go index 4126c879031..301c7075e4c 100644 --- a/internal/elasticsearch/client_test.go +++ b/internal/elasticsearch/client_test.go @@ -18,6 +18,7 @@ package elasticsearch import ( + "bytes" "context" "fmt" "net/http" @@ -30,6 +31,7 @@ import ( apmVersion "github.com/elastic/apm-server/internal/version" esv8 "github.com/elastic/go-elasticsearch/v8" + "github.com/elastic/go-elasticsearch/v8/esapi" ) func TestClient(t *testing.T) { @@ -86,3 +88,92 @@ func TestClientCustomUserAgent(t *testing.T) { t.Fatal("timed out while waiting for request") } } + +func esMockHandler(responder http.HandlerFunc) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("X-Elastic-Product", "Elasticsearch") + + switch { + case r.Method == http.MethodPost && r.URL.Path == "/_bulk": + responder(w, r) + return + default: + http.Error(w, "unsupported request", 419) // Signal unexpected error + return + } + } +} + +func TestClientRetryableStatuses(t *testing.T) { + tests := []struct { + name string + responseStatusCode int + expectedStatusCode int + expectedRequestCount int + }{ + { + name: "retry 429 Too Many Requests", + responseStatusCode: http.StatusTooManyRequests, + expectedStatusCode: http.StatusOK, + expectedRequestCount: 2, + }, + { + name: "retry 502 Bad Gateway", + responseStatusCode: http.StatusBadGateway, + expectedStatusCode: http.StatusBadGateway, + expectedRequestCount: 1, + }, + { + name: "retry 503 Service Not Available", + responseStatusCode: http.StatusServiceUnavailable, + expectedStatusCode: http.StatusServiceUnavailable, + expectedRequestCount: 1, + }, + { + name: "retry 504 Gateway Timeout", + responseStatusCode: http.StatusGatewayTimeout, + expectedStatusCode: http.StatusGatewayTimeout, + expectedRequestCount: 1, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + maxRetries := 2 + count := 0 + handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if count < maxRetries { + count += 1 + http.Error(w, "", tt.responseStatusCode) + return + } + + w.WriteHeader(http.StatusOK) + }) + + es := esMockHandler(handler) + srv := httptest.NewServer(&es) + defer srv.Close() + + c := Config{ + Username: "test", + Password: "foobar", + Backoff: BackoffConfig{ + Init: 0, + Max: 0, + }, + MaxRetries: maxRetries, + Hosts: []string{srv.URL}, + } + client, err := NewClient(&c) + require.NoError(t, err) + + var buf bytes.Buffer + var res *esapi.Response + res, err = client.Bulk(bytes.NewReader(buf.Bytes())) + require.NoError(t, err) + assert.Equal(t, tt.expectedStatusCode, res.StatusCode) + assert.Equal(t, tt.expectedRequestCount, count) + }) + } +}