From 6a561870522af62e7bc9f3c1ca2294027537afe8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 14 Sep 2023 17:02:05 +0000 Subject: [PATCH 1/8] Bump github.com/elastic/go-elasticsearch/v8 from 8.8.2 to 8.9.0 (#3144) * Bump github.com/elastic/go-elasticsearch/v8 from 8.8.2 to 8.9.0 Bumps [github.com/elastic/go-elasticsearch/v8](https://github.com/elastic/go-elasticsearch) from 8.8.2 to 8.9.0. - [Release notes](https://github.com/elastic/go-elasticsearch/releases) - [Changelog](https://github.com/elastic/go-elasticsearch/blob/main/CHANGELOG.md) - [Commits](https://github.com/elastic/go-elasticsearch/compare/v8.8.2...v8.9.0) --- updated-dependencies: - dependency-name: github.com/elastic/go-elasticsearch/v8 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * Update NOTICE.txt --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- NOTICE.txt | 4 ++-- go.mod | 2 +- go.sum | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/NOTICE.txt b/NOTICE.txt index 9b6ace280ec..39dc228ec6f 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -2000,11 +2000,11 @@ Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-transpo -------------------------------------------------------------------------------- Dependency : github.com/elastic/go-elasticsearch/v8 -Version: v8.8.2 +Version: v8.9.0 Licence type (autodetected): Apache-2.0 -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/github.com/elastic/go-elasticsearch/v8@v8.8.2/LICENSE: +Contents of probable licence file $GOMODCACHE/github.com/elastic/go-elasticsearch/v8@v8.9.0/LICENSE: Apache License Version 2.0, January 2004 diff --git a/go.mod b/go.mod index b17a75c97bb..524372edc32 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/elastic/elastic-agent-libs v0.3.14 github.com/elastic/elastic-agent-system-metrics v0.6.1 github.com/elastic/elastic-transport-go/v8 v8.3.0 - github.com/elastic/go-elasticsearch/v8 v8.8.2 + github.com/elastic/go-elasticsearch/v8 v8.9.0 github.com/elastic/go-licenser v0.4.1 github.com/elastic/go-sysinfo v1.11.0 github.com/elastic/go-ucfg v0.8.6 diff --git a/go.sum b/go.sum index fca2d0318c9..a3ad67f82b4 100644 --- a/go.sum +++ b/go.sum @@ -785,12 +785,13 @@ github.com/elastic/elastic-agent-system-metrics v0.6.1 h1:LCN1lvQTkdUuU/rKlpKyVM github.com/elastic/elastic-agent-system-metrics v0.6.1/go.mod h1:Bj8XM/uNKm553blQHkGNEICRLGnVEtw8yttmV5vBngA= github.com/elastic/elastic-integration-corpus-generator-tool v0.5.0/go.mod h1:uf9N86y+UACGybdEhZLpwZ93XHWVhsYZAA4c2T2v6YM= github.com/elastic/elastic-package v0.77.0/go.mod h1:Xeqx0OOVnKBfFoSHsHmKI74RxgRGiDhU6yXEu8BkJJM= +github.com/elastic/elastic-transport-go/v8 v8.0.0-20230329154755-1a3c63de0db6/go.mod h1:87Tcz8IVNe6rVSLdBux1o/PEItLtyabHU3naC7IoqKI= github.com/elastic/elastic-transport-go/v8 v8.3.0 h1:DJGxovyQLXGr62e9nDMPSxRyWION0Bh6d9eCFBriiHo= github.com/elastic/elastic-transport-go/v8 v8.3.0/go.mod h1:87Tcz8IVNe6rVSLdBux1o/PEItLtyabHU3naC7IoqKI= github.com/elastic/go-elasticsearch/v7 v7.17.7/go.mod h1:OJ4wdbtDNk5g503kvlHLyErCgQwwzmDtaFC4XyOxXA4= github.com/elastic/go-elasticsearch/v8 v8.0.0-20210317102009-a9d74cec0186/go.mod h1:xe9a/L2aeOgFKKgrO3ibQTnMdpAeL0GC+5/HpGScSa4= -github.com/elastic/go-elasticsearch/v8 v8.8.2 h1:3ITzPlRNadzDnbLTnMRjrAN4j4G3LvFo5gCIWDPS6pY= -github.com/elastic/go-elasticsearch/v8 v8.8.2/go.mod h1:GU1BJHO7WeamP7UhuElYwzzHtvf9SDmeVpSSy9+o6Qg= +github.com/elastic/go-elasticsearch/v8 v8.9.0 h1:8xtmYjUkqtahl50E0Bg/wjKI7K63krJrrLipbNj/fCU= +github.com/elastic/go-elasticsearch/v8 v8.9.0/go.mod h1:NGmpvohKiRHXI0Sw4fuUGn6hYOmAXlyCphKpzVBiqDE= github.com/elastic/go-licenser v0.3.1/go.mod h1:D8eNQk70FOCVBl3smCGQt/lv7meBeQno2eI1S5apiHQ= github.com/elastic/go-licenser v0.4.0/go.mod h1:V56wHMpmdURfibNBggaSBfqgPxyT1Tldns1i87iTEvU= github.com/elastic/go-licenser v0.4.1 h1:1xDURsc8pL5zYT9R29425J3vkHdt4RT5TNEMeRN48x4= From 8d47b16841daee3a8e660e42036c0857cd08fb30 Mon Sep 17 00:00:00 2001 From: apmmachine <58790750+apmmachine@users.noreply.github.com> Date: Thu, 14 Sep 2023 15:03:24 -0400 Subject: [PATCH 2/8] [Automation] Bump Golang version to 1.20.8 (#3393) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: Update from dockerfiles Made with ❤️️ by updatecli * chore: Update version.asciidoc Made with ❤️️ by updatecli * chore: Update govulncheck.yml Made with ❤️️ by updatecli * chore: Update .golangci.yml Made with ❤️️ by updatecli * chore: Update .go-version Made with ❤️️ by updatecli * Add changelog fragment. --------- Co-authored-by: apmmachine Co-authored-by: Craig MacKenzie --- .github/workflows/govulncheck.yml | 2 +- .go-version | 2 +- .golangci.yml | 8 ++--- Dockerfile | 2 +- Dockerfile.skaffold | 2 +- .../1694700200-Upgrade-to-Go-1.20.8.yaml | 32 +++++++++++++++++++ version/docs/version.asciidoc | 2 +- 7 files changed, 41 insertions(+), 9 deletions(-) create mode 100644 changelog/fragments/1694700200-Upgrade-to-Go-1.20.8.yaml diff --git a/.github/workflows/govulncheck.yml b/.github/workflows/govulncheck.yml index 5c16a4e2c4c..4d8a0ba4ec1 100644 --- a/.github/workflows/govulncheck.yml +++ b/.github/workflows/govulncheck.yml @@ -13,5 +13,5 @@ jobs: - id: govulncheck uses: golang/govulncheck-action@v1 with: - go-version-input: 1.20.7 + go-version-input: 1.20.8 go-package: ./... diff --git a/.go-version b/.go-version index 8909929f6e7..95393fc7d4d 100644 --- a/.go-version +++ b/.go-version @@ -1 +1 @@ -1.20.7 +1.20.8 diff --git a/.golangci.yml b/.golangci.yml index 6af8ecba48c..a6f9f5de236 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -116,7 +116,7 @@ linters-settings: gosimple: # Select the Go version to target. The default is '1.13'. - go: "1.20.7" + go: "1.20.8" nakedret: # make an issue if func has more lines of code than this setting and it has naked returns; default is 30 @@ -136,17 +136,17 @@ linters-settings: staticcheck: # Select the Go version to target. The default is '1.13'. - go: "1.20.7" + go: "1.20.8" checks: ["all"] stylecheck: # Select the Go version to target. The default is '1.13'. - go: "1.20.7" + go: "1.20.8" checks: ["all"] unused: # Select the Go version to target. The default is '1.13'. - go: "1.20.7" + go: "1.20.8" gosec: excludes: diff --git a/Dockerfile b/Dockerfile index 9589d0bcbf5..d0c2edc9f94 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -ARG GO_VERSION=1.20.7 +ARG GO_VERSION=1.20.8 FROM circleci/golang:${GO_VERSION} diff --git a/Dockerfile.skaffold b/Dockerfile.skaffold index fad68dd0607..ca9300eb4de 100644 --- a/Dockerfile.skaffold +++ b/Dockerfile.skaffold @@ -1,4 +1,4 @@ -ARG GO_VERSION=1.20.7 +ARG GO_VERSION=1.20.8 ARG crossbuild_image="docker.elastic.co/beats-dev/golang-crossbuild" ARG AGENT_VERSION=8.9.0-SNAPSHOT ARG AGENT_IMAGE="docker.elastic.co/beats/elastic-agent" diff --git a/changelog/fragments/1694700200-Upgrade-to-Go-1.20.8.yaml b/changelog/fragments/1694700200-Upgrade-to-Go-1.20.8.yaml new file mode 100644 index 00000000000..211338b03db --- /dev/null +++ b/changelog/fragments/1694700200-Upgrade-to-Go-1.20.8.yaml @@ -0,0 +1,32 @@ +# Kind can be one of: +# - breaking-change: a change to previously-documented behavior +# - deprecation: functionality that is being removed in a later release +# - bug-fix: fixes a problem in a previous version +# - enhancement: extends functionality but does not break or fix existing behavior +# - feature: new functionality +# - known-issue: problems that we are aware of in a given version +# - security: impacts on the security of a product or a user’s deployment. +# - upgrade: important information for someone upgrading from a prior version +# - other: does not fit into any of the other categories +kind: security + +# Change summary; a 80ish characters long description of the change. +summary: Upgrade to Go 1.20.8. + +# Long description; in case the summary is not enough to describe the change +# this field accommodate a description without length limits. +# NOTE: This field will be rendered only for breaking-change and known-issue kinds at the moment. +#description: + +# Affected component; usually one of "elastic-agent", "fleet-server", "filebeat", "metricbeat", "auditbeat", "all", etc. +component: "elastic-agent" + +# PR URL; optional; the PR number that added the changeset. +# If not present is automatically filled by the tooling finding the PR where this changelog fragment has been added. +# NOTE: the tooling supports backports, so it's able to fill the original PR number instead of the backport PR number. +# Please provide it if you are adding a fragment for a different PR. +pr: https://github.com/elastic/elastic-agent/pull/3393 + +# Issue URL; optional; the GitHub issue related to this changeset (either closes or is part of). +# If not present is automatically filled by the tooling with the issue linked to the PR number. +#issue: https://github.com/owner/repo/1234 diff --git a/version/docs/version.asciidoc b/version/docs/version.asciidoc index 9eec013b4ed..fd0e915eae0 100644 --- a/version/docs/version.asciidoc +++ b/version/docs/version.asciidoc @@ -3,7 +3,7 @@ // FIXME: once elastic.co docs have been switched over to use `main`, remove // the `doc-site-branch` line below as well as any references to it in the code. :doc-site-branch: master -:go-version: 1.20.7 +:go-version: 1.20.8 :release-state: unreleased :python: 3.7 :docker: 1.12 From 2230a373d34f0db7dd92b0fd7dcd3478d79bcbda Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 14 Sep 2023 15:46:51 -0400 Subject: [PATCH 3/8] Bump github.com/elastic/go-sysinfo from 1.11.0 to 1.11.1 (#3257) * Bump github.com/elastic/go-sysinfo from 1.11.0 to 1.11.1 Bumps [github.com/elastic/go-sysinfo](https://github.com/elastic/go-sysinfo) from 1.11.0 to 1.11.1. - [Release notes](https://github.com/elastic/go-sysinfo/releases) - [Commits](https://github.com/elastic/go-sysinfo/compare/v1.11.0...v1.11.1) --- updated-dependencies: - dependency-name: github.com/elastic/go-sysinfo dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update NOTICE.txt --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- NOTICE.txt | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/NOTICE.txt b/NOTICE.txt index 39dc228ec6f..69c4908fd19 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -2423,11 +2423,11 @@ Contents of probable licence file $GOMODCACHE/github.com/elastic/go-licenser@v0. -------------------------------------------------------------------------------- Dependency : github.com/elastic/go-sysinfo -Version: v1.11.0 +Version: v1.11.1 Licence type (autodetected): Apache-2.0 -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/github.com/elastic/go-sysinfo@v1.11.0/LICENSE.txt: +Contents of probable licence file $GOMODCACHE/github.com/elastic/go-sysinfo@v1.11.1/LICENSE.txt: Apache License diff --git a/go.mod b/go.mod index 524372edc32..93d84762d94 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/elastic/elastic-transport-go/v8 v8.3.0 github.com/elastic/go-elasticsearch/v8 v8.9.0 github.com/elastic/go-licenser v0.4.1 - github.com/elastic/go-sysinfo v1.11.0 + github.com/elastic/go-sysinfo v1.11.1 github.com/elastic/go-ucfg v0.8.6 github.com/fatih/color v1.15.0 github.com/gofrs/flock v0.8.1 diff --git a/go.sum b/go.sum index a3ad67f82b4..448ddccd4f9 100644 --- a/go.sum +++ b/go.sum @@ -800,8 +800,8 @@ github.com/elastic/go-structform v0.0.10 h1:oy08o/Ih2hHTkNcRY/1HhaYvIp5z6t8si8gn github.com/elastic/go-structform v0.0.10/go.mod h1:CZWf9aIRYY5SuKSmOhtXScE5uQiLZNqAFnwKR4OrIM4= github.com/elastic/go-sysinfo v1.1.1/go.mod h1:i1ZYdU10oLNfRzq4vq62BEwD2fH8KaWh6eh0ikPT9F0= github.com/elastic/go-sysinfo v1.7.1/go.mod h1:i1ZYdU10oLNfRzq4vq62BEwD2fH8KaWh6eh0ikPT9F0= -github.com/elastic/go-sysinfo v1.11.0 h1:QW+6BF1oxBoAprH3w2yephF7xLkrrSXj7gl2xC2BM4w= -github.com/elastic/go-sysinfo v1.11.0/go.mod h1:6KQb31j0QeWBDF88jIdWSxE8cwoOB9tO4Y4osN7Q70E= +github.com/elastic/go-sysinfo v1.11.1 h1:g9mwl05njS4r69TisC+vwHWTSKywZFYYUu3so3T/Lao= +github.com/elastic/go-sysinfo v1.11.1/go.mod h1:6KQb31j0QeWBDF88jIdWSxE8cwoOB9tO4Y4osN7Q70E= github.com/elastic/go-ucfg v0.8.6 h1:stUeyh2goTgGX+/wb9gzKvTv0YB0231LTpKUgCKj4U0= github.com/elastic/go-ucfg v0.8.6/go.mod h1:4E8mPOLSUV9hQ7sgLEJ4bvt0KhMuDJa8joDT2QGAEKA= github.com/elastic/go-windows v1.0.0/go.mod h1:TsU0Nrp7/y3+VwE82FoZF8gC/XFg/Elz6CcloAxnPgU= From 616c36f0339ab898eb76fba9ec79f45e09d21d78 Mon Sep 17 00:00:00 2001 From: Pierre HILBERT Date: Sat, 16 Sep 2023 16:55:50 +0200 Subject: [PATCH 4/8] Skip TestRemovePath as not working as expected and we have an issue for it #3221 (#3424) --- internal/pkg/agent/install/uninstall_windows_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/internal/pkg/agent/install/uninstall_windows_test.go b/internal/pkg/agent/install/uninstall_windows_test.go index e029b471513..513a8a3f622 100644 --- a/internal/pkg/agent/install/uninstall_windows_test.go +++ b/internal/pkg/agent/install/uninstall_windows_test.go @@ -22,6 +22,8 @@ func TestRemovePath(t *testing.T) { binaryName = pkgName + ".exe" ) + t.Skip("https://github.com/elastic/elastic-agent/issues/3221") + // Create a temporary directory that we can safely remove. The directory is created as a new // sub-directory. This avoids having Microsoft Defender quarantine the file if it is exec'd from // the default temporary directory. From d81804694304f9b752ea056faf59ca481f8aa80d Mon Sep 17 00:00:00 2001 From: Andrew Gizas Date: Mon, 18 Sep 2023 10:37:53 +0300 Subject: [PATCH 5/8] Fix creatork8sscript (#3396) * Updating Elastic Manifests with NETINFO variable * Fixing bug for statefuleset configmap --- .../1694439479-fix_creatork8sscript.yaml | 32 +++++++++++++++++++ deploy/kubernetes/Makefile | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 changelog/fragments/1694439479-fix_creatork8sscript.yaml diff --git a/changelog/fragments/1694439479-fix_creatork8sscript.yaml b/changelog/fragments/1694439479-fix_creatork8sscript.yaml new file mode 100644 index 00000000000..7f7a9d1fd95 --- /dev/null +++ b/changelog/fragments/1694439479-fix_creatork8sscript.yaml @@ -0,0 +1,32 @@ +# Kind can be one of: +# - breaking-change: a change to previously-documented behavior +# - deprecation: functionality that is being removed in a later release +# - bug-fix: fixes a problem in a previous version +# - enhancement: extends functionality but does not break or fix existing behavior +# - feature: new functionality +# - known-issue: problems that we are aware of in a given version +# - security: impacts on the security of a product or a user’s deployment. +# - upgrade: important information for someone upgrading from a prior version +# - other: does not fit into any of the other categories +kind: bug + +# Change summary; a 80ish characters long description of the change. +summary: Fixing deploy/kubernetes/creator_k8.sh script to correcly exclude configmaps + +# Long description; in case the summary is not enough to describe the change +# this field accommodate a description without length limits. +# NOTE: This field will be rendered only for breaking-change and known-issue kinds at the moment. +#description: + +# Affected component; usually one of "elastic-agent", "fleet-server", "filebeat", "metricbeat", "auditbeat", "all", etc. +component: + +# PR URL; optional; the PR number that added the changeset. +# If not present is automatically filled by the tooling finding the PR where this changelog fragment has been added. +# NOTE: the tooling supports backports, so it's able to fill the original PR number instead of the backport PR number. +# Please provide it if you are adding a fragment for a different PR. +#pr: https://github.com/owner/repo/1234 + +# Issue URL; optional; the GitHub issue related to this changeset (either closes or is part of). +# If not present is automatically filled by the tooling with the issue linked to the PR number. +#issue: https://github.com/owner/repo/1234 diff --git a/deploy/kubernetes/Makefile b/deploy/kubernetes/Makefile index 553315683fc..e4d8b474908 100644 --- a/deploy/kubernetes/Makefile +++ b/deploy/kubernetes/Makefile @@ -30,7 +30,7 @@ $(ALL): ifdef WITHOUTCONFIG @echo "Generating $@-kubernetes-without-configmap.yaml" @rm -f $@-kubernetes-without-configmap.yaml - @for f in $(shell ls $@/*.yaml | grep -v daemonset-configmap); do \ + @for f in $(shell ls $@/*.yaml | grep -v configmap ); do \ sed -e "s/%VERSION%/VERSION/g" -e "s/%BRANCH%/${BRANCH_VERSION}/g" $$f >> $@-kubernetes-without-configmap.yaml; \ echo --- >> $@-kubernetes-without-configmap.yaml; \ done From 23fe2ef05c8132c60a99ca73ee75371b09dba602 Mon Sep 17 00:00:00 2001 From: Alexandros Sapranidis Date: Mon, 18 Sep 2023 11:29:16 +0300 Subject: [PATCH 6/8] Structure the BK pipeline output for failures (#3359) --- .buildkite/pipeline.yml | 9 +++++++++ .buildkite/scripts/steps/integration_tests.sh | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 256a351e8ff..8ff198708fd 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -40,3 +40,12 @@ steps: agents: provider: "gcp" machineType: "n1-standard-8" + + - wait: ~ + continue_on_failure: true + - label: "Processing test results" + agents: + provider: "gcp" + plugins: + - junit-annotate#v2.4.1: + artifacts: build/TEST-go-*.xml diff --git a/.buildkite/scripts/steps/integration_tests.sh b/.buildkite/scripts/steps/integration_tests.sh index ea28f1f503d..6a582c4d8ef 100755 --- a/.buildkite/scripts/steps/integration_tests.sh +++ b/.buildkite/scripts/steps/integration_tests.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -set -euxo pipefail +set -euo pipefail source .buildkite/scripts/common.sh From b19e95069e28d0389e2e66a8281e5df823566ecc Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Mon, 18 Sep 2023 08:29:10 -0700 Subject: [PATCH 7/8] Fix `TestInstallAndCLIUninstallWithEndpointSecurity` integration test flakiness (#3410) * Return error if more than one Agent with same hostname is found in Fleet * Fix make call * Un-enroll Agent on test cleanup * Use policy ID and hostname to uniquely find Agent * Passing policy ID in more calls * Fix implicit memory aliasing * [Testing] Increasing timeout for status check to 10m * Get Agent by ID * Revert "Get Agent by ID" This reverts commit 1c7da6e7f646d0151cf091ff467915e19e3d7abc. --- pkg/testing/tools/agents.go | 43 ++++++++++++------- pkg/testing/tools/tools.go | 8 ++-- testing/integration/endpoint_security_test.go | 8 +++- testing/integration/fqdn_test.go | 36 ++++++++-------- testing/integration/monitoring_logs_test.go | 2 +- testing/integration/upgrade_test.go | 10 ++--- 6 files changed, 62 insertions(+), 45 deletions(-) diff --git a/pkg/testing/tools/agents.go b/pkg/testing/tools/agents.go index 1bb6eda9cd4..f7ca5c33270 100644 --- a/pkg/testing/tools/agents.go +++ b/pkg/testing/tools/agents.go @@ -19,30 +19,41 @@ import ( "github.com/elastic/elastic-agent/pkg/control/v2/cproto" ) -// GetAgentByHostnameFromList get an agent by the local_metadata.host.name property, reading from the agents list -func GetAgentByHostnameFromList(client *kibana.Client, hostname string) (*kibana.AgentExisting, error) { +// GetAgentByPolicyIDAndHostnameFromList get an agent by the local_metadata.host.name property, reading from the agents list +func GetAgentByPolicyIDAndHostnameFromList(client *kibana.Client, policyID, hostname string) (*kibana.AgentExisting, error) { listAgentsResp, err := client.ListAgents(context.Background(), kibana.ListAgentsRequest{}) if err != nil { return nil, err } - for _, item := range listAgentsResp.Items { + hostnameAgents := make([]*kibana.AgentExisting, 0) + for i, item := range listAgentsResp.Items { agentHostname := item.LocalMetadata.Host.Hostname - if agentHostname == hostname { - return &item, nil + agentPolicyID := item.PolicyID + + if agentHostname == hostname && agentPolicyID == policyID { + hostnameAgents = append(hostnameAgents, &listAgentsResp.Items[i]) } } - return nil, fmt.Errorf("unable to find agent with hostname [%s]", hostname) + if len(hostnameAgents) == 0 { + return nil, fmt.Errorf("unable to find agent with hostname [%s]", hostname) + } + + if len(hostnameAgents) > 1 { + return nil, fmt.Errorf("found %d agents with hostname [%s]; expected to find only one", len(hostnameAgents), hostname) + } + + return hostnameAgents[0], nil } -func GetAgentStatus(client *kibana.Client) (string, error) { +func GetAgentStatus(client *kibana.Client, policyID string) (string, error) { hostname, err := os.Hostname() if err != nil { return "", err } - agent, err := GetAgentByHostnameFromList(client, hostname) + agent, err := GetAgentByPolicyIDAndHostnameFromList(client, policyID, hostname) if err != nil { return "", err } @@ -50,13 +61,13 @@ func GetAgentStatus(client *kibana.Client) (string, error) { return agent.Status, nil } -func GetAgentVersion(client *kibana.Client) (string, error) { +func GetAgentVersion(client *kibana.Client, policyID string) (string, error) { hostname, err := os.Hostname() if err != nil { return "", err } - agent, err := GetAgentByHostnameFromList(client, hostname) + agent, err := GetAgentByPolicyIDAndHostnameFromList(client, policyID, hostname) if err != nil { return "", err } @@ -64,12 +75,12 @@ func GetAgentVersion(client *kibana.Client) (string, error) { return agent.Agent.Version, err } -func UnEnrollAgent(client *kibana.Client) error { +func UnEnrollAgent(client *kibana.Client, policyID string) error { hostname, err := os.Hostname() if err != nil { return err } - agentID, err := GetAgentIDByHostname(client, hostname) + agentID, err := GetAgentIDByHostname(client, policyID, hostname) if err != nil { return err } @@ -86,20 +97,20 @@ func UnEnrollAgent(client *kibana.Client) error { return nil } -func GetAgentIDByHostname(client *kibana.Client, hostname string) (string, error) { - agent, err := GetAgentByHostnameFromList(client, hostname) +func GetAgentIDByHostname(client *kibana.Client, policyID, hostname string) (string, error) { + agent, err := GetAgentByPolicyIDAndHostnameFromList(client, policyID, hostname) if err != nil { return "", err } return agent.Agent.ID, nil } -func UpgradeAgent(client *kibana.Client, version string) error { +func UpgradeAgent(client *kibana.Client, policyID, version string) error { hostname, err := os.Hostname() if err != nil { return err } - agentID, err := GetAgentIDByHostname(client, hostname) + agentID, err := GetAgentIDByHostname(client, policyID, hostname) if err != nil { return err } diff --git a/pkg/testing/tools/tools.go b/pkg/testing/tools/tools.go index 7b125293eb6..4ac8c930e66 100644 --- a/pkg/testing/tools/tools.go +++ b/pkg/testing/tools/tools.go @@ -19,9 +19,9 @@ import ( // WaitForAgentStatus returns a niladic function that returns true if the agent // has reached expectedStatus; false otherwise. The returned function is intended // for use with assert.Eventually or require.Eventually. -func WaitForAgentStatus(t *testing.T, client *kibana.Client, expectedStatus string) func() bool { +func WaitForAgentStatus(t *testing.T, client *kibana.Client, policyID string, expectedStatus string) func() bool { return func() bool { - currentStatus, err := GetAgentStatus(client) + currentStatus, err := GetAgentStatus(client, policyID) if err != nil { t.Errorf("unable to determine agent status: %s", err.Error()) return false @@ -128,14 +128,14 @@ func InstallAgentForPolicy(t *testing.T, ctx context.Context, } t.Logf(">>> Ran Enroll. Output: %s", output) - timeout := 5 * time.Minute + timeout := 10 * time.Minute if deadline, ok := ctx.Deadline(); ok { timeout = time.Until(deadline) } // Wait for Agent to be healthy require.Eventually( t, - WaitForAgentStatus(t, kibClient, "online"), + WaitForAgentStatus(t, kibClient, policyID, "online"), timeout, 10*time.Second, "Elastic Agent status is not online", diff --git a/testing/integration/endpoint_security_test.go b/testing/integration/endpoint_security_test.go index bb77f724e52..9304901047f 100644 --- a/testing/integration/endpoint_security_test.go +++ b/testing/integration/endpoint_security_test.go @@ -19,6 +19,7 @@ import ( "text/template" "time" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/google/uuid" @@ -135,6 +136,11 @@ func testInstallAndCLIUninstallWithEndpointSecurity(t *testing.T, info *define.I installOpts, fixture, info.KibanaClient, createPolicyReq) require.NoError(t, err, "failed to install agent with policy") + t.Cleanup(func() { + t.Log("Un-enrolling Elastic Agent...") + assert.NoError(t, tools.UnEnrollAgent(info.KibanaClient, policy.ID)) + }) + t.Log("Installing Elastic Defend") pkgPolicyResp, err := installElasticDefendPackage(t, info, policy.ID) require.NoErrorf(t, err, "Policy Response was: %v", pkgPolicyResp) @@ -238,7 +244,7 @@ func testInstallAndUnenrollWithEndpointSecurity(t *testing.T, info *define.Info, hostname, err := os.Hostname() require.NoError(t, err) - agentID, err := tools.GetAgentIDByHostname(info.KibanaClient, hostname) + agentID, err := tools.GetAgentIDByHostname(info.KibanaClient, policy.ID, hostname) require.NoError(t, err) _, err = info.KibanaClient.UnEnrollAgent(ctx, kibana.UnEnrollAgentRequest{ID: agentID}) diff --git a/testing/integration/fqdn_test.go b/testing/integration/fqdn_test.go index b280f1e6e5b..2fb76a6028c 100644 --- a/testing/integration/fqdn_test.go +++ b/testing/integration/fqdn_test.go @@ -56,19 +56,6 @@ func TestFQDN(t *testing.T) { origHostname, err := getHostname(context.Background()) require.NoError(t, err) - t.Cleanup(func() { - t.Log("Un-enrolling Elastic Agent...") - assert.NoError(t, tools.UnEnrollAgent(info.KibanaClient)) - - t.Log("Restoring hostname...") - err := setHostname(context.Background(), origHostname, t.Log) - require.NoError(t, err) - - t.Log("Restoring original /etc/hosts...") - err = setEtcHosts(origEtcHosts) - require.NoError(t, err) - }) - ctx := context.Background() kibClient := info.KibanaClient @@ -101,8 +88,21 @@ func TestFQDN(t *testing.T) { policy, err := tools.InstallAgentWithPolicy(t, ctx, installOpts, agentFixture, kibClient, createPolicyReq) require.NoError(t, err) + t.Cleanup(func() { + t.Log("Un-enrolling Elastic Agent...") + assert.NoError(t, tools.UnEnrollAgent(info.KibanaClient, policy.ID)) + + t.Log("Restoring hostname...") + err := setHostname(context.Background(), origHostname, t.Log) + require.NoError(t, err) + + t.Log("Restoring original /etc/hosts...") + err = setEtcHosts(origEtcHosts) + require.NoError(t, err) + }) + t.Log("Verify that agent name is short hostname") - agent := verifyAgentName(t, shortName, info.KibanaClient) + agent := verifyAgentName(t, policy.ID, shortName, info.KibanaClient) t.Log("Verify that hostname in `logs-*` and `metrics-*` is short hostname") verifyHostNameInIndices(t, "logs-*", shortName, info.Namespace, info.ESClient) @@ -133,7 +133,7 @@ func TestFQDN(t *testing.T) { ) t.Log("Verify that agent name is FQDN") - verifyAgentName(t, fqdn, info.KibanaClient) + verifyAgentName(t, policy.ID, fqdn, info.KibanaClient) t.Log("Verify that hostname in `logs-*` and `metrics-*` is FQDN") verifyHostNameInIndices(t, "logs-*", fqdn, info.Namespace, info.ESClient) @@ -164,7 +164,7 @@ func TestFQDN(t *testing.T) { ) t.Log("Verify that agent name is short hostname again") - verifyAgentName(t, shortName, info.KibanaClient) + verifyAgentName(t, policy.ID, shortName, info.KibanaClient) // TODO: Re-enable assertion once https://github.com/elastic/elastic-agent/issues/3078 is // investigated for root cause and resolved. @@ -173,7 +173,7 @@ func TestFQDN(t *testing.T) { // verifyHostNameInIndices(t, "metrics-*", shortName, info.ESClient) } -func verifyAgentName(t *testing.T, hostname string, kibClient *kibana.Client) *kibana.AgentExisting { +func verifyAgentName(t *testing.T, policyID, hostname string, kibClient *kibana.Client) *kibana.AgentExisting { t.Helper() var agent *kibana.AgentExisting @@ -182,7 +182,7 @@ func verifyAgentName(t *testing.T, hostname string, kibClient *kibana.Client) *k require.Eventually( t, func() bool { - agent, err = tools.GetAgentByHostnameFromList(kibClient, hostname) + agent, err = tools.GetAgentByPolicyIDAndHostnameFromList(kibClient, policyID, hostname) return err == nil && agent != nil }, 5*time.Minute, diff --git a/testing/integration/monitoring_logs_test.go b/testing/integration/monitoring_logs_test.go index 368462ed92b..607fe0c9b8d 100644 --- a/testing/integration/monitoring_logs_test.go +++ b/testing/integration/monitoring_logs_test.go @@ -114,7 +114,7 @@ func TestMonitoringLogsShipped(t *testing.T) { t.Fatalf("could not get hostname to filter Agent: %s", err) } - agentID, err := tools.GetAgentIDByHostname(info.KibanaClient, hostname) + agentID, err := tools.GetAgentIDByHostname(info.KibanaClient, policy.ID, hostname) require.NoError(t, err, "could not get Agent ID by hostname") t.Logf("Agent ID: %q", agentID) diff --git a/testing/integration/upgrade_test.go b/testing/integration/upgrade_test.go index cf363bdf8fc..1e44f2bf6ae 100644 --- a/testing/integration/upgrade_test.go +++ b/testing/integration/upgrade_test.go @@ -158,25 +158,25 @@ func testUpgradeFleetManagedElasticAgent(t *testing.T, ctx context.Context, info require.NoError(t, err) t.Cleanup(func() { t.Log("Un-enrolling Elastic Agent...") - assert.NoError(t, tools.UnEnrollAgent(info.KibanaClient)) + assert.NoError(t, tools.UnEnrollAgent(info.KibanaClient, policy.ID)) }) t.Log(`Waiting for enrolled Agent status to be "online"...`) - require.Eventually(t, tools.WaitForAgentStatus(t, kibClient, "online"), 2*time.Minute, 10*time.Second, "Agent status is not online") + require.Eventually(t, tools.WaitForAgentStatus(t, kibClient, policy.ID, "online"), 2*time.Minute, 10*time.Second, "Agent status is not online") t.Logf("Upgrade Elastic Agent to version %s...", toVersion) - err = tools.UpgradeAgent(kibClient, toVersion) + err = tools.UpgradeAgent(kibClient, policy.ID, toVersion) require.NoError(t, err) t.Log(`Waiting for enrolled Agent status to be "online"...`) - require.Eventually(t, tools.WaitForAgentStatus(t, kibClient, "online"), 10*time.Minute, 15*time.Second, "Agent status is not online") + require.Eventually(t, tools.WaitForAgentStatus(t, kibClient, policy.ID, "online"), 10*time.Minute, 15*time.Second, "Agent status is not online") // We remove the `-SNAPSHOT` suffix because, post-upgrade, the version reported // by the Agent will not contain this suffix, even if a `-SNAPSHOT`-suffixed // version was used as the target version for the upgrade. require.Eventually(t, func() bool { t.Log("Getting Agent version...") - newVersion, err := tools.GetAgentVersion(kibClient) + newVersion, err := tools.GetAgentVersion(kibClient, policy.ID) if err != nil { t.Logf("error getting agent version: %v", err) return false From 735a8fbc52c94b78f9b893b761e4a373df46c2e3 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 18 Sep 2023 19:25:24 +0200 Subject: [PATCH 8/8] Changelog for 8.10.1 (#3435) (#3436) (cherry picked from commit d83b889999ac64a14049737d6e1918cf64653019) Co-authored-by: Pierre HILBERT --- changelog/8.10.1.asciidoc | 40 +++++++++++++++++++ changelog/8.10.1.yaml | 25 ++++++++++++ .../1690917883-crash-checker-pid-zero.yaml | 32 --------------- .../1694190260-improve-upgrade-logging.yaml | 32 --------------- 4 files changed, 65 insertions(+), 64 deletions(-) create mode 100644 changelog/8.10.1.asciidoc create mode 100644 changelog/8.10.1.yaml delete mode 100644 changelog/fragments/1690917883-crash-checker-pid-zero.yaml delete mode 100644 changelog/fragments/1694190260-improve-upgrade-logging.yaml diff --git a/changelog/8.10.1.asciidoc b/changelog/8.10.1.asciidoc new file mode 100644 index 00000000000..4ca9b796f2c --- /dev/null +++ b/changelog/8.10.1.asciidoc @@ -0,0 +1,40 @@ +// begin 8.10.1 relnotes + +[[release-notes-8.10.1]] +== 8.10.1 + +Review important information about the 8.10.1 release. + + + + + + + + + + + + +[discrete] +[[enhancements-8.10.1]] +=== Enhancements + + +elastic-agent:: + +* Improve Logging During Agent Upgrades. {elastic-agent-pull}https://github.com/elastic/elastic-agent/pull/3382[#https://github.com/elastic/elastic-agent/pull/3382] + + + + +[discrete] +[[bug-fixes-8.10.1]] +=== Bug fixes + + +elastic-agent:: + +* Rollback Elastic Agent Upgrade If Upgraded Agent Process Crashes Immediately. {elastic-agent-pull}https://github.com/elastic/elastic-agent/pull/3166[#https://github.com/elastic/elastic-agent/pull/3166] {elastic-agent-issue}https://github.com/elastic/elastic-agent/issues/3124[#https://github.com/elastic/elastic-agent/issues/3124] + +// end 8.10.1 relnotes diff --git a/changelog/8.10.1.yaml b/changelog/8.10.1.yaml new file mode 100644 index 00000000000..dcdfc805615 --- /dev/null +++ b/changelog/8.10.1.yaml @@ -0,0 +1,25 @@ +version: 8.10.1 +entries: + - kind: bug-fix + summary: Rollback Elastic Agent upgrade if upgraded Agent process crashes immediately. + description: "" + component: elastic-agent + pr: + - https://github.com/elastic/elastic-agent/pull/3166 + issue: + - https://github.com/elastic/elastic-agent/issues/3124 + timestamp: 1690917883 + file: + name: 1690917883-crash-checker-pid-zero.yaml + checksum: 0a2ceec945ec5f1829bbf0d6d9f13f2f5b428885 + - kind: enhancement + summary: Improve logging during Agent upgrades + description: "" + component: elastic-agent + pr: + - https://github.com/elastic/elastic-agent/pull/3382 + issue: [] + timestamp: 1694190260 + file: + name: 1694190260-improve-upgrade-logging.yaml + checksum: 4d9c6f196e8fa89e834969c751237153b69b18e5 diff --git a/changelog/fragments/1690917883-crash-checker-pid-zero.yaml b/changelog/fragments/1690917883-crash-checker-pid-zero.yaml deleted file mode 100644 index 2540afe4b94..00000000000 --- a/changelog/fragments/1690917883-crash-checker-pid-zero.yaml +++ /dev/null @@ -1,32 +0,0 @@ -# Kind can be one of: -# - breaking-change: a change to previously-documented behavior -# - deprecation: functionality that is being removed in a later release -# - bug-fix: fixes a problem in a previous version -# - enhancement: extends functionality but does not break or fix existing behavior -# - feature: new functionality -# - known-issue: problems that we are aware of in a given version -# - security: impacts on the security of a product or a user’s deployment. -# - upgrade: important information for someone upgrading from a prior version -# - other: does not fit into any of the other categories -kind: bug-fix - -# Change summary; a 80ish characters long description of the change. -summary: Rollback Elastic Agent upgrade if upgraded Agent process crashes immediately. - -# Long description; in case the summary is not enough to describe the change -# this field accommodate a description without length limits. -# NOTE: This field will be rendered only for breaking-change and known-issue kinds at the moment. -#description: - -# Affected component; usually one of "elastic-agent", "fleet-server", "filebeat", "metricbeat", "auditbeat", "all", etc. -component: elastic-agent - -# PR URL; optional; the PR number that added the changeset. -# If not present is automatically filled by the tooling finding the PR where this changelog fragment has been added. -# NOTE: the tooling supports backports, so it's able to fill the original PR number instead of the backport PR number. -# Please provide it if you are adding a fragment for a different PR. -pr: https://github.com/elastic/elastic-agent/pull/3166 - -# Issue URL; optional; the GitHub issue related to this changeset (either closes or is part of). -# If not present is automatically filled by the tooling with the issue linked to the PR number. -issue: https://github.com/elastic/elastic-agent/issues/3124 diff --git a/changelog/fragments/1694190260-improve-upgrade-logging.yaml b/changelog/fragments/1694190260-improve-upgrade-logging.yaml deleted file mode 100644 index a471629b90a..00000000000 --- a/changelog/fragments/1694190260-improve-upgrade-logging.yaml +++ /dev/null @@ -1,32 +0,0 @@ -# Kind can be one of: -# - breaking-change: a change to previously-documented behavior -# - deprecation: functionality that is being removed in a later release -# - bug-fix: fixes a problem in a previous version -# - enhancement: extends functionality but does not break or fix existing behavior -# - feature: new functionality -# - known-issue: problems that we are aware of in a given version -# - security: impacts on the security of a product or a user’s deployment. -# - upgrade: important information for someone upgrading from a prior version -# - other: does not fit into any of the other categories -kind: enhancement - -# Change summary; a 80ish characters long description of the change. -summary: Improve logging during Agent upgrades - -# Long description; in case the summary is not enough to describe the change -# this field accommodate a description without length limits. -# NOTE: This field will be rendered only for breaking-change and known-issue kinds at the moment. -#description: - -# Affected component; usually one of "elastic-agent", "fleet-server", "filebeat", "metricbeat", "auditbeat", "all", etc. -component: elastic-agent - -# PR URL; optional; the PR number that added the changeset. -# If not present is automatically filled by the tooling finding the PR where this changelog fragment has been added. -# NOTE: the tooling supports backports, so it's able to fill the original PR number instead of the backport PR number. -# Please provide it if you are adding a fragment for a different PR. -pr: https://github.com/elastic/elastic-agent/pull/3382 - -# Issue URL; optional; the GitHub issue related to this changeset (either closes or is part of). -# If not present is automatically filled by the tooling with the issue linked to the PR number. -#issue: https://github.com/owner/repo/1234