Skip to content

Commit 90714ec

Browse files
Merge branch 'main' into otel/added-k8s-comps
2 parents 628555d + 1f3ddcd commit 90714ec

21 files changed

+424
-193
lines changed

.agent-versions.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"testVersions": [
3+
"8.14.1",
34
"8.14.1-SNAPSHOT",
4-
"8.14.0",
55
"8.13.5-SNAPSHOT",
66
"8.13.4",
77
"7.17.22-SNAPSHOT",

.buildkite/pipeline.yml

+48
Original file line numberDiff line numberDiff line change
@@ -232,3 +232,51 @@ steps:
232232
image: "family/core-ubuntu-2204"
233233
env:
234234
- GH_VERSION=2.4.0
235+
236+
# Trigger for pull requests
237+
- label: "Trigger Integration tests for Pull request"
238+
if: |
239+
(build.pull_request.id != null && !build.env("GITHUB_PR_LABELS") =~ /skip-it/) ||
240+
build.env("GITHUB_PR_TRIGGER_COMMENT") =~ /.*extended.*/
241+
242+
plugins:
243+
- monorepo-diff#v1.0.1:
244+
diff: "git diff --name-only origin/${GITHUB_PR_TARGET_BRANCH}...HEAD"
245+
watch:
246+
- path:
247+
- internal/
248+
- dev-tools/
249+
- pkg/
250+
- testing/
251+
- version/
252+
- specs/
253+
- .agent-versions.json
254+
- .go-version
255+
- .package-version
256+
- go.mod
257+
- go.sum
258+
- magefile.go
259+
- main.go
260+
261+
- .buildkite/integration.pipeline.yml
262+
- .buildkite/pipeline.yml
263+
- .buildkite/scripts/
264+
- .buildkite/hooks/
265+
266+
config:
267+
trigger: "elastic-agent-extended-testing"
268+
build:
269+
commit: "${BUILDKITE_COMMIT}"
270+
branch: "${BUILDKITE_BRANCH}"
271+
env:
272+
- BUILDKITE_PULL_REQUEST=${BUILDKITE_PULL_REQUEST}
273+
- BUILDKITE_PULL_REQUEST_BASE_BRANCH=${BUILDKITE_PULL_REQUEST_BASE_BRANCH}
274+
- GITHUB_PR_LABELS=${GITHUB_PR_LABELS}
275+
276+
# Trigger for branches
277+
- label: "Triggering Integration tests for branches"
278+
if: build.pull_request.id == null
279+
trigger: "elastic-agent-extended-testing"
280+
build:
281+
commit: "${BUILDKITE_COMMIT}"
282+
branch: "${BUILDKITE_BRANCH}"

.buildkite/pull-requests.json

+2-19
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,13 @@
99
"set_commit_status": true,
1010
"build_on_commit": true,
1111
"build_on_comment": true,
12-
"trigger_comment_regex": "^(?:(?:buildkite\\W+)?(?:build|test)\\W+(?:this|it))|^/test$",
13-
"always_trigger_comment_regex": "^(?:(?:buildkite\\W+)?(?:build|test)\\W+(?:this|it))|^/test$",
12+
"trigger_comment_regex": "^(?:(?:buildkite\\W+)?(?:build|test)\\W+(?:this|it|extended))|^/test\\W*(?:extended|)",
13+
"always_trigger_comment_regex": "^(?:(?:buildkite\\W+)?(?:build|test)\\W+(?:this|it|extended))|^/test\\W*(?:extended|)",
1414
"skip_ci_labels": [ "skip-ci" ],
1515
"skip_target_branches": [ ],
1616
"skip_ci_on_only_changed": [ "^.ci/", "^changelog", "^docs/", "\\.md$", "^docker-compose.yml", "^.pre-commit-config.yaml", "skaffold.yaml", "^Dockerfile.skaffold", "^Dockerfile"],
1717
"always_require_ci_on_changed": [ ]
1818
},
19-
{
20-
"enabled": true,
21-
"build_drafts": false,
22-
"pipelineSlug": "elastic-agent-extended-testing",
23-
"allow_org_users": true,
24-
"allowed_repo_permissions": ["admin", "write"],
25-
"allowed_list": ["dependabot[bot]", "mergify[bot]", "github-actions[bot]"],
26-
"set_commit_status": true,
27-
"build_on_commit": true,
28-
"build_on_comment": true,
29-
"trigger_comment_regex": "^(?:(?:buildkite\\W+)?(?:build|test)\\W+(?:extended))|^/test extended$",
30-
"always_trigger_comment_regex": "^(?:(?:buildkite\\W+)?(?:build|test)\\W+(?:extended))|^/test extended$",
31-
"skip_ci_labels": [ "skip-ci", "skip-it" ],
32-
"skip_target_branches": [ ],
33-
"skip_ci_on_only_changed": [ "^.ci/", "^changelog", "^docs/", "\\.md$", "^sonar-project.properties", "^docker-compose.yml", "^.pre-commit-config.yaml", "skaffold.yaml", "^Dockerfile.skaffold", "^Dockerfile"],
34-
"always_require_ci_on_changed": [ ]
35-
},
3619
{
3720
"enabled": true,
3821
"pipelineSlug": "elastic-agent-package",

NOTICE.txt

+30-30
Original file line numberDiff line numberDiff line change
@@ -2220,6 +2220,36 @@ Contents of probable licence file $GOMODCACHE/github.com/elastic/go-licenser@v0.
22202220
limitations under the License.
22212221

22222222

2223+
--------------------------------------------------------------------------------
2224+
Dependency : github.com/elastic/go-service
2225+
Version: v0.0.0-20240611154109-f44f756f194f
2226+
Licence type (autodetected): Zlib
2227+
--------------------------------------------------------------------------------
2228+
2229+
Contents of probable licence file $GOMODCACHE/github.com/elastic/go-service@v0.0.0-20240611154109-f44f756f194f/LICENSE:
2230+
2231+
Copyright (c) 2015 Daniel Theophanes
2232+
2233+
This software is provided 'as-is', without any express or implied
2234+
warranty. In no event will the authors be held liable for any damages
2235+
arising from the use of this software.
2236+
2237+
Permission is granted to anyone to use this software for any purpose,
2238+
including commercial applications, and to alter it and redistribute it
2239+
freely, subject to the following restrictions:
2240+
2241+
1. The origin of this software must not be misrepresented; you must not
2242+
claim that you wrote the original software. If you use this software
2243+
in a product, an acknowledgment in the product documentation would be
2244+
appreciated but is not required.
2245+
2246+
2. Altered source versions must be plainly marked as such, and must not be
2247+
misrepresented as being the original software.
2248+
2249+
3. This notice may not be removed or altered from any source
2250+
distribution.
2251+
2252+
22232253
--------------------------------------------------------------------------------
22242254
Dependency : github.com/elastic/go-sysinfo
22252255
Version: v1.14.0
@@ -3782,36 +3812,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
37823812
SOFTWARE.
37833813

37843814

3785-
--------------------------------------------------------------------------------
3786-
Dependency : github.com/kardianos/service
3787-
Version: v1.2.1-0.20210728001519-a323c3813bc7
3788-
Licence type (autodetected): Zlib
3789-
--------------------------------------------------------------------------------
3790-
3791-
Contents of probable licence file $GOMODCACHE/github.com/kardianos/service@v1.2.1-0.20210728001519-a323c3813bc7/LICENSE:
3792-
3793-
Copyright (c) 2015 Daniel Theophanes
3794-
3795-
This software is provided 'as-is', without any express or implied
3796-
warranty. In no event will the authors be held liable for any damages
3797-
arising from the use of this software.
3798-
3799-
Permission is granted to anyone to use this software for any purpose,
3800-
including commercial applications, and to alter it and redistribute it
3801-
freely, subject to the following restrictions:
3802-
3803-
1. The origin of this software must not be misrepresented; you must not
3804-
claim that you wrote the original software. If you use this software
3805-
in a product, an acknowledgment in the product documentation would be
3806-
appreciated but is not required.
3807-
3808-
2. Altered source versions must be plainly marked as such, and must not be
3809-
misrepresented as being the original software.
3810-
3811-
3. This notice may not be removed or altered from any source
3812-
distribution.
3813-
3814-
38153815
--------------------------------------------------------------------------------
38163816
Dependency : github.com/magefile/mage
38173817
Version: v1.15.0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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: Add unprivileged mode support (beta)
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+
Add new --unprivileged installation option. This option installs the Elastic Agent as a non-root or non-Administrator
21+
user that has limited permissions on the host.
22+
23+
# Affected component; usually one of "elastic-agent", "fleet-server", "filebeat", "metricbeat", "auditbeat", "all", etc.
24+
component: elastic-agent
25+
26+
# PR URL; optional; the PR number that added the changeset.
27+
# If not present is automatically filled by the tooling finding the PR where this changelog fragment has been added.
28+
# NOTE: the tooling supports backports, so it's able to fill the original PR number instead of the backport PR number.
29+
# Please provide it if you are adding a fragment for a different PR.
30+
#pr: https://github.com/owner/repo/1234
31+
32+
# Issue URL; optional; the GitHub issue related to this changeset (either closes or is part of).
33+
# If not present is automatically filled by the tooling with the issue linked to the PR number.
34+
#issue: https://github.com/owner/repo/1234
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
kind: bug-fix
2+
summary: Increase removal timeout when uninstall
3+
component: "elastic-agent"

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ require (
1919
github.com/elastic/elastic-transport-go/v8 v8.6.0
2020
github.com/elastic/go-elasticsearch/v8 v8.14.0
2121
github.com/elastic/go-licenser v0.4.1
22+
github.com/elastic/go-service v0.0.0-20240611154109-f44f756f194f
2223
github.com/elastic/go-sysinfo v1.14.0
2324
github.com/elastic/go-ucfg v0.8.8
2425
github.com/elastic/mock-es v0.0.0-20240605193845-b5546a703d6f
@@ -36,7 +37,6 @@ require (
3637
github.com/jedib0t/go-pretty/v6 v6.4.6
3738
github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901
3839
github.com/josephspurrier/goversioninfo v0.0.0-20190209210621-63e6d1acd3dd
39-
github.com/kardianos/service v1.2.1-0.20210728001519-a323c3813bc7
4040
github.com/magefile/mage v1.15.0
4141
github.com/mitchellh/gox v1.0.1
4242
github.com/mitchellh/hashstructure v1.1.0

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,8 @@ github.com/elastic/go-elasticsearch/v8 v8.14.0/go.mod h1:WRvnlGkSuZyp83M2U8El/LG
834834
github.com/elastic/go-licenser v0.3.1/go.mod h1:D8eNQk70FOCVBl3smCGQt/lv7meBeQno2eI1S5apiHQ=
835835
github.com/elastic/go-licenser v0.4.1 h1:1xDURsc8pL5zYT9R29425J3vkHdt4RT5TNEMeRN48x4=
836836
github.com/elastic/go-licenser v0.4.1/go.mod h1:V56wHMpmdURfibNBggaSBfqgPxyT1Tldns1i87iTEvU=
837+
github.com/elastic/go-service v0.0.0-20240611154109-f44f756f194f h1:kMtsJ3zfcBBR6wfbf5yUExmvWLru6R7zSLaJIfSjU3g=
838+
github.com/elastic/go-service v0.0.0-20240611154109-f44f756f194f/go.mod h1:3lVNFcuNMdWJrSpGF5SMPUVuC+qOYobfPIrMQUoizrk=
837839
github.com/elastic/go-structform v0.0.10 h1:oy08o/Ih2hHTkNcRY/1HhaYvIp5z6t8si8gnCJPDo1w=
838840
github.com/elastic/go-structform v0.0.10/go.mod h1:CZWf9aIRYY5SuKSmOhtXScE5uQiLZNqAFnwKR4OrIM4=
839841
github.com/elastic/go-sysinfo v1.1.1/go.mod h1:i1ZYdU10oLNfRzq4vq62BEwD2fH8KaWh6eh0ikPT9F0=
@@ -1324,8 +1326,6 @@ github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfV
13241326
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
13251327
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
13261328
github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213/go.mod h1:vNUNkEQ1e29fT/6vq2aBdFsgNPmy8qMdSay1npru+Sw=
1327-
github.com/kardianos/service v1.2.1-0.20210728001519-a323c3813bc7 h1:oohm9Rk9JAxxmp2NLZa7Kebgz9h4+AJDcc64txg3dQ0=
1328-
github.com/kardianos/service v1.2.1-0.20210728001519-a323c3813bc7/go.mod h1:CIMRFEJVL+0DS1a3Nx06NaMn4Dz63Ng6O7dl0qH0zVM=
13291329
github.com/karrick/godirwalk v1.15.6/go.mod h1:j4mkqPuvaLI8mp1DroR3P6ad7cyYd4c1qeJ3RV7ULlk=
13301330
github.com/karrick/godirwalk v1.16.1 h1:DynhcF+bztK8gooS0+NDJFrdNZjJ3gzVzC545UNA9iw=
13311331
github.com/karrick/godirwalk v1.16.1/go.mod h1:j4mkqPuvaLI8mp1DroR3P6ad7cyYd4c1qeJ3RV7ULlk=

internal/pkg/agent/application/gateway/fleet/fleet_gateway.go

+4
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,10 @@ func (f *FleetGateway) execute(ctx context.Context) (*fleetapi.CheckinResponse,
329329
// convert components into checkin components structure
330330
components := f.convertToCheckinComponents(state.Components)
331331

332+
f.log.Debugf("correcting agent loglevel from %s to %s using coordinator state", ecsMeta.Elastic.Agent.LogLevel, state.LogLevel.String())
333+
// Fix loglevel with the current log level used by coordinator
334+
ecsMeta.Elastic.Agent.LogLevel = state.LogLevel.String()
335+
332336
// checkin
333337
cmd := fleetapi.NewCheckinCmd(f.agentInfo, f.client)
334338
req := &fleetapi.CheckinRequest{

internal/pkg/agent/application/info/agent_metadata_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ func TestECSMetadata(t *testing.T) {
2929
metadata, err := agentInfo.ECSMetadata(l)
3030
require.NoError(t, err)
3131

32+
if assert.NotNil(t, metadata.Elastic, "metadata.Elastic must not be nil") {
33+
assert.NotNil(t, metadata.Elastic.Agent, "metadata.Elastic.Agent must not be nil")
34+
}
35+
3236
sysInfo, err := sysinfo.Host()
3337
require.NoError(t, err)
3438

internal/pkg/agent/application/upgrade/service_update_linux.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212

1313
"gopkg.in/ini.v1"
1414

15-
"github.com/kardianos/service"
15+
"github.com/elastic/go-service"
1616

1717
"github.com/elastic/elastic-agent/internal/pkg/agent/application/paths"
1818
)

internal/pkg/agent/cmd/install.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ would like the Agent to operate.
4747
cmd.Flags().BoolP("force", "f", false, "Force overwrite the current installation and do not prompt for confirmation")
4848
cmd.Flags().BoolP("non-interactive", "n", false, "Install Elastic Agent in non-interactive mode which will not prompt on missing parameters but fails instead.")
4949
cmd.Flags().String(flagInstallBasePath, paths.DefaultBasePath, "The path where the Elastic Agent will be installed. It must be an absolute path.")
50-
cmd.Flags().Bool(flagInstallUnprivileged, false, "Installed Elastic Agent will create an 'elastic-agent' user and run as that user. (experimental)")
51-
_ = cmd.Flags().MarkHidden(flagInstallUnprivileged) // Hidden until fully supported
50+
cmd.Flags().Bool(flagInstallUnprivileged, false, "Install in unprivileged mode, limiting the access of the Elastic Agent. (beta)")
5251
addEnrollFlags(cmd)
5352

5453
return cmd
@@ -77,7 +76,7 @@ func installCmd(streams *cli.IOStreams, cmd *cobra.Command) error {
7776

7877
unprivileged, _ := cmd.Flags().GetBool(flagInstallUnprivileged)
7978
if unprivileged {
80-
fmt.Fprintln(streams.Out, "Unprivileged installation mode enabled; this is an experimental and currently unsupported feature.")
79+
fmt.Fprintln(streams.Out, "Unprivileged installation mode enabled; this feature is currently in beta.")
8180
}
8281

8382
topPath := paths.InstallPath(basePath)

internal/pkg/agent/install/install.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ import (
1313
"strings"
1414
"time"
1515

16+
"github.com/elastic/go-service"
17+
1618
"github.com/jaypipes/ghw"
17-
"github.com/kardianos/service"
1819
"github.com/otiai10/copy"
1920
"github.com/schollz/progressbar/v3"
2021

internal/pkg/agent/install/installed.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"os"
99
"path/filepath"
1010

11-
"github.com/kardianos/service"
11+
"github.com/elastic/go-service"
1212

1313
"github.com/elastic/elastic-agent/internal/pkg/agent/application/paths"
1414
"github.com/elastic/elastic-agent/internal/pkg/agent/install/pkgmgr"

internal/pkg/agent/install/svc.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"path/filepath"
1010
"runtime"
1111

12-
"github.com/kardianos/service"
12+
"github.com/elastic/go-service"
1313

1414
"github.com/elastic/elastic-agent/internal/pkg/agent/application/paths"
1515
)

internal/pkg/agent/install/switch.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ package install
77
import (
88
"fmt"
99

10-
"github.com/kardianos/service"
1110
"github.com/schollz/progressbar/v3"
1211

12+
"github.com/elastic/go-service"
13+
1314
"github.com/elastic/elastic-agent/internal/pkg/agent/application/paths"
1415
"github.com/elastic/elastic-agent/internal/pkg/agent/perms"
1516
"github.com/elastic/elastic-agent/pkg/utils"

internal/pkg/agent/install/uninstall.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ import (
1515
"strings"
1616
"time"
1717

18-
"github.com/kardianos/service"
1918
"github.com/schollz/progressbar/v3"
2019

20+
"github.com/elastic/go-service"
21+
2122
"github.com/elastic/elastic-agent-libs/logp"
2223
"github.com/elastic/elastic-agent/internal/pkg/agent/application/paths"
2324
"github.com/elastic/elastic-agent/internal/pkg/agent/application/secret"
@@ -159,7 +160,7 @@ func checkForUnprivilegedVault(ctx context.Context, opts ...vault.OptionFunc) (b
159160
// to an ERROR_SHARING_VIOLATION. RemovePath will retry up to 2
160161
// seconds if it keeps getting that error.
161162
func RemovePath(path string) error {
162-
const arbitraryTimeout = 30 * time.Second
163+
const arbitraryTimeout = 60 * time.Second
163164
start := time.Now()
164165
var lastErr error
165166
for time.Since(start) <= arbitraryTimeout {

pkg/component/runtime/service.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"runtime"
1313
"time"
1414

15-
"github.com/kardianos/service"
15+
"github.com/elastic/go-service"
1616

1717
"github.com/elastic/elastic-agent-client/v7/pkg/client"
1818
"github.com/elastic/elastic-agent-client/v7/pkg/proto"

pkg/testing/fixture.go

+10
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,16 @@ func (f *Fixture) PrepareAgentCommand(ctx context.Context, args []string, opts .
665665
return nil, fmt.Errorf("failed to prepare before exec: %w", err)
666666
}
667667

668+
// prepare a client if it's not already set
669+
if f.c == nil {
670+
cAddr, err := control.AddressFromPath(f.operatingSystem, f.workDir)
671+
if err != nil {
672+
return nil, fmt.Errorf("failed to get control protcol address: %w", err)
673+
}
674+
agentClient := client.New(client.WithAddress(cAddr))
675+
f.setClient(agentClient)
676+
}
677+
668678
// #nosec G204 -- Not so many ways to support variadic arguments to the elastic-agent command :(
669679
cmd := exec.CommandContext(ctx, f.binaryPath(), args...)
670680
for _, o := range opts {

0 commit comments

Comments
 (0)