Skip to content

Commit

Permalink
Merge branch 'main' of github.com:elastic/elastic-agent into checkin-…
Browse files Browse the repository at this point in the history
…cleanup
  • Loading branch information
faec committed Sep 18, 2023
2 parents ce535cf + 735a8fb commit 5a3f251
Show file tree
Hide file tree
Showing 23 changed files with 169 additions and 75 deletions.
9 changes: 9 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .buildkite/scripts/steps/integration_tests.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -euxo pipefail
set -euo pipefail

source .buildkite/scripts/common.sh

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/govulncheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ./...
2 changes: 1 addition & 1 deletion .go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.20.7
1.20.8
8 changes: 4 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG GO_VERSION=1.20.7
ARG GO_VERSION=1.20.8
FROM circleci/golang:${GO_VERSION}


Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.skaffold
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
8 changes: 4 additions & 4 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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/[email protected].0/LICENSE.txt:
Contents of probable licence file $GOMODCACHE/github.com/elastic/[email protected].1/LICENSE.txt:


Apache License
Expand Down
40 changes: 40 additions & 0 deletions changelog/8.10.1.asciidoc
Original file line number Diff line number Diff line change
@@ -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
25 changes: 25 additions & 0 deletions changelog/8.10.1.yaml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@
# - 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
kind: bug

# Change summary; a 80ish characters long description of the change.
summary: Rollback Elastic Agent upgrade if upgraded Agent process crashes immediately.
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: elastic-agent
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/elastic/elastic-agent/pull/3166
#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/elastic/elastic-agent/issues/3124
#issue: https://github.com/owner/repo/1234
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@
# - 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
kind: security

# Change summary; a 80ish characters long description of the change.
summary: Improve logging during Agent upgrades
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
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
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.
Expand Down
2 changes: 1 addition & 1 deletion deploy/kubernetes/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ $(ALL):
ifdef WITHOUTCONFIG
@echo "Generating [email protected]"
@rm -f [email protected]
@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 >> [email protected]; \
echo --- >> [email protected]; \
done
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ 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-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
Expand Down
9 changes: 5 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand All @@ -799,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=
Expand Down
2 changes: 2 additions & 0 deletions internal/pkg/agent/install/uninstall_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
43 changes: 27 additions & 16 deletions pkg/testing/tools/agents.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,57 +19,68 @@ 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
}

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
}

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
}
Expand All @@ -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
}
Expand Down
Loading

0 comments on commit 5a3f251

Please sign in to comment.