Skip to content

Commit 17b25d9

Browse files
committed
conflicts with es exporter
2 parents eaa8990 + f24a88a commit 17b25d9

30 files changed

+1447
-546
lines changed

.agent-versions.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"testVersions": [
33
"8.14.0-SNAPSHOT",
4+
"8.13.3",
45
"8.13.3-SNAPSHOT",
5-
"8.13.2",
66
"8.12.2",
7-
"7.17.21-SNAPSHOT",
8-
"7.17.20"
7+
"7.17.21",
8+
"7.17.21-SNAPSHOT"
99
]
1010
}

.go-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.21.9
1+
1.21.10

.golangci.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ linters-settings:
116116

117117
gosimple:
118118
# Select the Go version to target. The default is '1.13'.
119-
go: "1.21.9"
119+
go: "1.21.10"
120120

121121
nakedret:
122122
# 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:
136136

137137
staticcheck:
138138
# Select the Go version to target. The default is '1.13'.
139-
go: "1.21.9"
139+
go: "1.21.10"
140140
checks: ["all"]
141141

142142
stylecheck:
143143
# Select the Go version to target. The default is '1.13'.
144-
go: "1.21.9"
144+
go: "1.21.10"
145145
checks: ["all"]
146146

147147
unused:
148148
# Select the Go version to target. The default is '1.13'.
149-
go: "1.21.9"
149+
go: "1.21.10"
150150

151151
gosec:
152152
excludes:

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG GO_VERSION=1.21.9
1+
ARG GO_VERSION=1.21.10
22
FROM circleci/golang:${GO_VERSION}
33

44

Dockerfile.skaffold

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG GO_VERSION=1.21.9
1+
ARG GO_VERSION=1.21.10
22
ARG crossbuild_image="docker.elastic.co/beats-dev/golang-crossbuild"
33
ARG AGENT_VERSION=8.9.0-SNAPSHOT
44
ARG AGENT_IMAGE="docker.elastic.co/beats/elastic-agent"

NOTICE.txt

+1,164-469
Large diffs are not rendered by default.

README.md

+16
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,22 @@ sudo elastic-agent install
7878

7979
For basic use the agent binary can be run directly, with the `sudo elastic-agent run` command.
8080

81+
#### Packaging for other architectures
82+
When packaging for an architecture different than the host machine,
83+
you might face the following error:
84+
```
85+
exec /crossbuild: exec format error
86+
```
87+
88+
If that happens, enable
89+
[`multiarch/qemu-user-static`](https://github.com/multiarch/qemu-user-static)
90+
is to enable an execution of different multi-architecture containers
91+
by QEMU and binfmt_misc:
92+
93+
```
94+
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
95+
```
96+
8197
### Docker
8298

8399
Running Elastic Agent in a docker container is a common use case. To build the Elastic Agent and create a docker image run the following command:

changelog/fragments/1712176768-Upgrade-to-Go-1.21.9.yaml changelog/fragments/1712176768-Upgrade-to-Go-1.21.10.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
kind: security
1212

1313
# Change summary; a 80ish characters long description of the change.
14-
summary: Upgrade to Go 1.21.9.
14+
summary: Upgrade to Go 1.21.10.
1515

1616
# Long description; in case the summary is not enough to describe the change
1717
# this field accommodate a description without length limits.
@@ -25,7 +25,7 @@ component: "elastic-agent"
2525
# If not present is automatically filled by the tooling finding the PR where this changelog fragment has been added.
2626
# NOTE: the tooling supports backports, so it's able to fill the original PR number instead of the backport PR number.
2727
# Please provide it if you are adding a fragment for a different PR.
28-
pr: https://github.com/elastic/elastic-agent/pull/4508
28+
pr: https://github.com/elastic/elastic-agent/pull/4697
2929

3030
# Issue URL; optional; the GitHub issue related to this changeset (either closes or is part of).
3131
# If not present is automatically filled by the tooling with the issue linked to the PR number.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Kind can be one of:
2+
# - breaking-change: a change to previously-documented behavior
3+
# - deprecation: functionality that is being removed in a later release
4+
# - bug-fix: fixes a problem in a previous version
5+
# - enhancement: extends functionality but does not break or fix existing behavior
6+
# - feature: new functionality
7+
# - known-issue: problems that we are aware of in a given version
8+
# - security: impacts on the security of a product or a user’s deployment.
9+
# - upgrade: important information for someone upgrading from a prior version
10+
# - other: does not fit into any of the other categories
11+
kind: feature
12+
13+
# Change summary; a 80ish characters long description of the change.
14+
summary: Makes the `filterprocessor` available to users running Elastic Agent in `otel` mode.
15+
16+
# Long description; in case the summary is not enough to describe the change
17+
# this field accommodate a description without length limits.
18+
# NOTE: This field will be rendered only for breaking-change and known-issue kinds at the moment.
19+
#description:
20+
21+
# Affected component; usually one of "elastic-agent", "fleet-server", "filebeat", "metricbeat", "auditbeat", "all", etc.
22+
component: elastic-agent
23+
24+
# PR URL; optional; the PR number that added the changeset.
25+
# If not present is automatically filled by the tooling finding the PR where this changelog fragment has been added.
26+
# NOTE: the tooling supports backports, so it's able to fill the original PR number instead of the backport PR number.
27+
# Please provide it if you are adding a fragment for a different PR.
28+
pr: https://github.com/elastic/elastic-agent/pull/4708
29+
30+
# Issue URL; optional; the GitHub issue related to this changeset (either closes or is part of).
31+
# If not present is automatically filled by the tooling with the issue linked to the PR number.
32+
#issue: https://github.com/owner/repo/1234
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Kind can be one of:
2+
# - breaking-change: a change to previously-documented behavior
3+
# - deprecation: functionality that is being removed in a later release
4+
# - bug-fix: fixes a problem in a previous version
5+
# - enhancement: extends functionality but does not break or fix existing behavior
6+
# - feature: new functionality
7+
# - known-issue: problems that we are aware of in a given version
8+
# - security: impacts on the security of a product or a user’s deployment.
9+
# - upgrade: important information for someone upgrading from a prior version
10+
# - other: does not fit into any of the other categories
11+
kind: feature
12+
13+
# Change summary; a 80ish characters long description of the change.
14+
summary: Makes the `elasticsearchexporter` available to users running Elastic Agent in `otel` mode.
15+
16+
# Long description; in case the summary is not enough to describe the change
17+
# this field accommodate a description without length limits.
18+
# NOTE: This field will be rendered only for breaking-change and known-issue kinds at the moment.
19+
#description:
20+
21+
# Affected component; usually one of "elastic-agent", "fleet-server", "filebeat", "metricbeat", "auditbeat", "all", etc.
22+
component: elastic-agent
23+
24+
# PR URL; optional; the PR number that added the changeset.
25+
# If not present is automatically filled by the tooling finding the PR where this changelog fragment has been added.
26+
# NOTE: the tooling supports backports, so it's able to fill the original PR number instead of the backport PR number.
27+
# Please provide it if you are adding a fragment for a different PR.
28+
pr: https://github.com/elastic/elastic-agent/pull/4707
29+
30+
# Issue URL; optional; the GitHub issue related to this changeset (either closes or is part of).
31+
# If not present is automatically filled by the tooling with the issue linked to the PR number.
32+
#issue: https://github.com/owner/repo/1234

go.mod

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
module github.com/elastic/elastic-agent
22

3-
go 1.21
3+
go 1.21.0
4+
5+
toolchain go1.21.10
46

57
require (
68
github.com/Microsoft/go-winio v0.6.1
@@ -11,10 +13,10 @@ require (
1113
github.com/cenkalti/backoff/v4 v4.3.0
1214
github.com/docker/go-units v0.5.0
1315
github.com/dolmen-go/contextio v0.0.0-20200217195037-68fc5150bcd5
14-
github.com/elastic/e2e-testing v1.1.0
16+
github.com/elastic/e2e-testing v1.2.1
1517
github.com/elastic/elastic-agent-autodiscover v0.6.8
1618
github.com/elastic/elastic-agent-client/v7 v7.8.1
17-
github.com/elastic/elastic-agent-libs v0.9.6
19+
github.com/elastic/elastic-agent-libs v0.9.7
1820
github.com/elastic/elastic-agent-system-metrics v0.9.2
1921
github.com/elastic/elastic-transport-go/v8 v8.5.0
2022
github.com/elastic/go-elasticsearch/v8 v8.13.1
@@ -85,8 +87,10 @@ require (
8587
// open telemetry dependencies
8688
// pinned to v0.97.0 due to issue with ports binding which causes our tests to fail
8789
// Do NOT upgrade the version beyond 0.97.0 until https://github.com/open-telemetry/opentelemetry-collector/issues/10031 is fixed!
90+
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/elasticsearchexporter v0.97.0
8891
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/fileexporter v0.97.0
8992
github.com/open-telemetry/opentelemetry-collector-contrib/processor/attributesprocessor v0.97.0
93+
github.com/open-telemetry/opentelemetry-collector-contrib/processor/filterprocessor v0.97.0
9094
github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourceprocessor v0.97.0
9195
github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor v0.97.0
9296
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/filelogreceiver v0.97.0
@@ -127,6 +131,7 @@ require (
127131
github.com/dnephin/pflag v1.0.7 // indirect
128132
github.com/docker/docker v25.0.5+incompatible // indirect
129133
github.com/docker/go-connections v0.5.0 // indirect
134+
github.com/elastic/go-elasticsearch/v7 v7.17.10 // indirect
130135
github.com/elastic/go-structform v0.0.10 // indirect
131136
github.com/elastic/go-windows v1.0.1 // indirect
132137
github.com/elastic/gosigar v0.14.3 // indirect
@@ -169,6 +174,7 @@ require (
169174
github.com/knadh/koanf/providers/confmap v0.1.0 // indirect
170175
github.com/knadh/koanf/v2 v2.1.1 // indirect
171176
github.com/leodido/ragel-machinery v0.0.0-20190525184631-5f46317e436b // indirect
177+
github.com/lestrrat-go/strftime v1.0.6 // indirect
172178
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
173179
github.com/mailru/easyjson v0.7.7 // indirect
174180
github.com/markbates/pkger v0.17.0 // indirect
@@ -186,6 +192,7 @@ require (
186192
github.com/mostynb/go-grpc-compression v1.2.2 // indirect
187193
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
188194
github.com/onsi/ginkgo/v2 v2.9.0 // indirect
195+
github.com/open-telemetry/opentelemetry-collector-contrib/internal/common v0.97.0 // indirect
189196
github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.97.0 // indirect
190197
github.com/open-telemetry/opentelemetry-collector-contrib/internal/filter v0.97.0 // indirect
191198
github.com/open-telemetry/opentelemetry-collector-contrib/internal/sharedcomponent v0.97.0 // indirect

go.sum

+14-4
Original file line numberDiff line numberDiff line change
@@ -789,21 +789,23 @@ github.com/dsnet/golib v0.0.0-20171103203638-1ea166775780/go.mod h1:Lj+Z9rebOhdf
789789
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
790790
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
791791
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
792-
github.com/elastic/e2e-testing v1.1.0 h1:Y+K215EWkf3ojAWmBK2JrxH/rITjkKM1zR8mnwIpvLw=
793-
github.com/elastic/e2e-testing v1.1.0/go.mod h1:8q2d8dmwavJXISowwaoreHFBnbR/uK4qanfRGhC/W9A=
792+
github.com/elastic/e2e-testing v1.2.1 h1:jIuikohPtTxtO+bfoVEyKAWmcsAl21lxiiTK8Fj+G8U=
793+
github.com/elastic/e2e-testing v1.2.1/go.mod h1:8q2d8dmwavJXISowwaoreHFBnbR/uK4qanfRGhC/W9A=
794794
github.com/elastic/elastic-agent-autodiscover v0.6.8 h1:BSXz+QwjZAEt08G+T3GDGl14Bh9a6zD8luNCvZut/b8=
795795
github.com/elastic/elastic-agent-autodiscover v0.6.8/go.mod h1:hFeFqneS2r4jD0/QzGkrNk0YVdN0JGh7lCWdsH7zcI4=
796796
github.com/elastic/elastic-agent-client/v7 v7.8.1 h1:J9wZc/0mUvSEok0X5iR5+n60Jgb+AWooKddb3XgPWqM=
797797
github.com/elastic/elastic-agent-client/v7 v7.8.1/go.mod h1:axl1nkdqc84YRFkeJGD9jExKNPUrOrzf3DFo2m653nY=
798-
github.com/elastic/elastic-agent-libs v0.9.6 h1:3paTd2JVkxTHH8rnlVZVrTLJgacR2l8jFr+NYHHCNio=
799-
github.com/elastic/elastic-agent-libs v0.9.6/go.mod h1:xhHF9jeWhPzKPtEHN+epKjdiZi0bCbACLxwkp1aHMpc=
798+
github.com/elastic/elastic-agent-libs v0.9.7 h1:LZdfxbq724Y1zAdE3COp+OIPwU8SquOCLIXpI/twcdQ=
799+
github.com/elastic/elastic-agent-libs v0.9.7/go.mod h1:xhHF9jeWhPzKPtEHN+epKjdiZi0bCbACLxwkp1aHMpc=
800800
github.com/elastic/elastic-agent-system-metrics v0.9.2 h1:/tvTKOt55EerU0WwGFoDhBlyWLgxyv7d8xCbny0bciw=
801801
github.com/elastic/elastic-agent-system-metrics v0.9.2/go.mod h1:VfJnKw4Jqrd9ddljXCwaGKJgN+7ADyyGk089NaXVsf0=
802802
github.com/elastic/elastic-integration-corpus-generator-tool v0.5.0/go.mod h1:uf9N86y+UACGybdEhZLpwZ93XHWVhsYZAA4c2T2v6YM=
803803
github.com/elastic/elastic-package v0.77.0/go.mod h1:Xeqx0OOVnKBfFoSHsHmKI74RxgRGiDhU6yXEu8BkJJM=
804804
github.com/elastic/elastic-transport-go/v8 v8.5.0 h1:v5membAl7lvQgBTexPRDBO/RdnlQX+FM9fUVDyXxvH0=
805805
github.com/elastic/elastic-transport-go/v8 v8.5.0/go.mod h1:YLHer5cj0csTzNFXoNQ8qhtGY1GTvSqPnKWKaqQE3Hk=
806806
github.com/elastic/go-elasticsearch/v7 v7.17.7/go.mod h1:OJ4wdbtDNk5g503kvlHLyErCgQwwzmDtaFC4XyOxXA4=
807+
github.com/elastic/go-elasticsearch/v7 v7.17.10 h1:TCQ8i4PmIJuBunvBS6bwT2ybzVFxxUhhltAs3Gyu1yo=
808+
github.com/elastic/go-elasticsearch/v7 v7.17.10/go.mod h1:OJ4wdbtDNk5g503kvlHLyErCgQwwzmDtaFC4XyOxXA4=
807809
github.com/elastic/go-elasticsearch/v8 v8.0.0-20210317102009-a9d74cec0186/go.mod h1:xe9a/L2aeOgFKKgrO3ibQTnMdpAeL0GC+5/HpGScSa4=
808810
github.com/elastic/go-elasticsearch/v8 v8.13.1 h1:du5F8IzUUyCkzxyHdrO9AtopcG95I/qwi2WK8Kf1xlg=
809811
github.com/elastic/go-elasticsearch/v8 v8.13.1/go.mod h1:DIn7HopJs4oZC/w0WoJR13uMUxtHeq92eI5bqv5CRfI=
@@ -1322,6 +1324,10 @@ github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0/go.mod h1:vmVJ0l/dxyfGW6Fm
13221324
github.com/leodido/ragel-machinery v0.0.0-20181214104525-299bdde78165/go.mod h1:WZxr2/6a/Ar9bMDc2rN/LJrE/hF6bXE4LPyDSIxwAfg=
13231325
github.com/leodido/ragel-machinery v0.0.0-20190525184631-5f46317e436b h1:11UHH39z1RhZ5dc4y4r/4koJo6IYFgTRMe/LlwRTEw0=
13241326
github.com/leodido/ragel-machinery v0.0.0-20190525184631-5f46317e436b/go.mod h1:WZxr2/6a/Ar9bMDc2rN/LJrE/hF6bXE4LPyDSIxwAfg=
1327+
github.com/lestrrat-go/envload v0.0.0-20180220234015-a3eb8ddeffcc h1:RKf14vYWi2ttpEmkA4aQ3j4u9dStX2t4M8UM6qqNsG8=
1328+
github.com/lestrrat-go/envload v0.0.0-20180220234015-a3eb8ddeffcc/go.mod h1:kopuH9ugFRkIXf3YoqHKyrJ9YfUFsckUU9S7B+XP+is=
1329+
github.com/lestrrat-go/strftime v1.0.6 h1:CFGsDEt1pOpFNU+TJB0nhz9jl+K0hZSLE205AhTIGQQ=
1330+
github.com/lestrrat-go/strftime v1.0.6/go.mod h1:f7jQKgV5nnJpYgdEasS+/y7EsTb8ykN2z68n3TtcTaw=
13251331
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
13261332
github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
13271333
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9B/r2mtpb6U+EI2rYA5OAXxsYw6wTamcNW+zcE=
@@ -1519,6 +1525,8 @@ github.com/onsi/gomega v1.22.1/go.mod h1:x6n7VNe4hw0vkyYUM4mjIXx3JbLiPaBPNgB7PRQ
15191525
github.com/onsi/gomega v1.23.0/go.mod h1:Z/NWtiqwBrwUt4/2loMmHL63EDLnYHmVbuBpDr2vQAg=
15201526
github.com/onsi/gomega v1.27.3 h1:5VwIwnBY3vbBDOJrNtA4rVdiTZCsq9B5F12pvy1Drmk=
15211527
github.com/onsi/gomega v1.27.3/go.mod h1:5vG284IBtfDAmDyrK+eGyZmUgUlmi+Wngqo557cZ6Gw=
1528+
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/elasticsearchexporter v0.97.0 h1:VDx9u2xhgrjb0ozp2/SDeSF0cGZ0ECP4KSSQT8jOo5U=
1529+
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/elasticsearchexporter v0.97.0/go.mod h1:PXX2jvijwqSwoS2wR/kNqeW3YLH9FcWIkJp4GBOGlVE=
15221530
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/fileexporter v0.97.0 h1:hiLEBltXVuC1aTxp8J/6dJv0qu1dLJMFvmU7BJSlWoM=
15231531
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/fileexporter v0.97.0/go.mod h1:tkySqhV+P3MZI0GhbSHFFs4dkYlUjFqUDm+L9AIdU4I=
15241532
github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding v0.97.0 h1:HgmPxcExu/+JEe0SAH3nCwE/tXXtZR8piQLukFNwKZM=
@@ -1545,6 +1553,8 @@ github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza v0.97.0 h1:
15451553
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza v0.97.0/go.mod h1:BleH1EFM1PjhKy9geg/FVIsvc/v7hl+FqZlxAnzUHSk=
15461554
github.com/open-telemetry/opentelemetry-collector-contrib/processor/attributesprocessor v0.97.0 h1:CeNd+aJaRCDb3bwNvC75ilP8uFRpWI3oD5rSJgmP7AY=
15471555
github.com/open-telemetry/opentelemetry-collector-contrib/processor/attributesprocessor v0.97.0/go.mod h1:2YXD48xGbLZ2mk5ScmrDYzPXjZb4R+1c2723AWuz5Pw=
1556+
github.com/open-telemetry/opentelemetry-collector-contrib/processor/filterprocessor v0.97.0 h1:IfJ9EkykXHBYdwuvZd0qfFcCHAAOuTEaiIlTRw6R9g4=
1557+
github.com/open-telemetry/opentelemetry-collector-contrib/processor/filterprocessor v0.97.0/go.mod h1:uTs2ukYAG9tCkoUhW39J9bNQAqwpqHhE85eeRVm6zCM=
15481558
github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourceprocessor v0.97.0 h1:Fa3TvB9WKi6wF3N1Kn4oDeyrigAidK+0uQaAvRQUwLQ=
15491559
github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourceprocessor v0.97.0/go.mod h1:XKpJmOEQTVg6CdbWi9n1Gr+MYc3A6DtYX3uuYB7Q4so=
15501560
github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor v0.97.0 h1:8UfxoSP0ZKkib+RWZVdCixHEjkz1VxspRAmHqmexO9M=

internal/pkg/agent/install/uninstall.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ func killWatcher(pt *progressbar.ProgressBar) error {
391391
errs = errors.Join(errs, fmt.Errorf("failed to load watcher process with pid %d: %w", pid, err))
392392
continue
393393
}
394-
err = proc.Kill()
394+
err = killNoneChildProcess(proc)
395395
if err != nil && !errors.Is(err, os.ErrProcessDone) {
396396
errs = errors.Join(errs, fmt.Errorf("failed to kill watcher process with pid %d: %w", pid, err))
397397
continue

internal/pkg/agent/install/uninstall_unix.go

+9
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
package install
88

9+
import "os"
10+
911
func isBlockingOnExe(_ error) bool {
1012
return false
1113
}
@@ -17,3 +19,10 @@ func removeBlockingExe(_ error) error {
1719
func isRetryableError(_ error) bool {
1820
return false
1921
}
22+
23+
// killNoneChildProcess provides a way of killing a process that is not started as a child of this process.
24+
//
25+
// On Unix systems it just calls the native golang kill.
26+
func killNoneChildProcess(proc *os.Process) error {
27+
return proc.Kill()
28+
}

internal/pkg/agent/install/uninstall_windows.go

+17
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"errors"
1111
"fmt"
1212
"io/fs"
13+
"os"
1314
"syscall"
1415
"unsafe"
1516

@@ -160,3 +161,19 @@ type fileRenameInfo struct {
160161
type fileDispositionInfo struct {
161162
DeleteFile bool
162163
}
164+
165+
// killNoneChildProcess provides a way of killing a process that is not started as a child of this process.
166+
//
167+
// On Windows when running in unprivileged mode the internal way that golang uses DuplicateHandle to perform the kill
168+
// only works when the process is a child of this process.
169+
func killNoneChildProcess(proc *os.Process) error {
170+
h, e := syscall.OpenProcess(syscall.PROCESS_TERMINATE, false, uint32(proc.Pid))
171+
if e != nil {
172+
return os.NewSyscallError("OpenProcess", e)
173+
}
174+
defer func() {
175+
_ = syscall.CloseHandle(h)
176+
}()
177+
e = syscall.TerminateProcess(h, 1)
178+
return os.NewSyscallError("TerminateProcess", e)
179+
}

internal/pkg/agent/storage/store/state_store.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ type stateSerializer struct {
7575
}
7676

7777
// NewStateStoreWithMigration creates a new state store and migrates the old one.
78-
func NewStateStoreWithMigration(ctx context.Context, log *logger.Logger, actionStorePath, stateStorePath string) (*StateStore, error) {
79-
err := migrateStateStore(ctx, log, actionStorePath, stateStorePath)
78+
func NewStateStoreWithMigration(ctx context.Context, log *logger.Logger, actionStorePath, stateStorePath string, storageOpts ...storage.EncryptedOptionFunc) (*StateStore, error) {
79+
err := migrateStateStore(ctx, log, actionStorePath, stateStorePath, storageOpts...)
8080
if err != nil {
8181
return nil, err
8282
}
8383

84-
encryptedDiskStore, err := storage.NewEncryptedDiskStore(ctx, stateStorePath)
84+
encryptedDiskStore, err := storage.NewEncryptedDiskStore(ctx, stateStorePath, storageOpts...)
8585
if err != nil {
8686
return nil, fmt.Errorf("error instantiating encrypted disk store: %w", err)
8787
}
@@ -147,14 +147,14 @@ func NewStateStore(log *logger.Logger, store storeLoad) (*StateStore, error) {
147147
}, nil
148148
}
149149

150-
func migrateStateStore(ctx context.Context, log *logger.Logger, actionStorePath, stateStorePath string) (err error) {
150+
func migrateStateStore(ctx context.Context, log *logger.Logger, actionStorePath, stateStorePath string, storageOpts ...storage.EncryptedOptionFunc) (err error) {
151151
log = log.Named("state_migration")
152152
actionDiskStore, err := storage.NewDiskStore(actionStorePath)
153153
if err != nil {
154154
return fmt.Errorf("error creating disk store: %w", err)
155155
}
156156

157-
stateDiskStore, err := storage.NewEncryptedDiskStore(ctx, stateStorePath)
157+
stateDiskStore, err := storage.NewEncryptedDiskStore(ctx, stateStorePath, storageOpts...)
158158
if err != nil {
159159
return fmt.Errorf("error instantiating encrypted disk store: %w", err)
160160
}

0 commit comments

Comments
 (0)