Skip to content

Commit 0093188

Browse files
Merge branch 'main' into dependabot/go_modules/github.com/elastic/go-elasticsearch/v8-8.11.0
2 parents ea84fc9 + d8b446f commit 0093188

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2187
-990
lines changed

.buildkite/pipeline.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ steps:
130130
agents:
131131
provider: "gcp"
132132
# TODO create own image
133-
image: "family/endpoint-windows-10-tester-rel"
133+
image: "family/general-windows-10"
134134
machine_type: "n2-standard-8"
135135
disk_type: "pd-ssd"
136136
retry:
@@ -147,7 +147,7 @@ steps:
147147
agents:
148148
provider: "gcp"
149149
# TODO create own image
150-
image: "family/endpoint-windows-11-tester-rel"
150+
image: "family/general-windows-11"
151151
machine_type: "n2-standard-8"
152152
disk_type: "pd-ssd"
153153
retry:

.github/workflows/bump-golang.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ name: bump-golang
44
on:
55
workflow_dispatch:
66
schedule:
7-
- cron: "0 20 * * 6"
7+
- cron: "0 20 * * 1-6"
88

99
permissions:
1010
contents: read
1111

12+
env:
13+
JOB_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
14+
1215
jobs:
1316
bump:
1417
runs-on: ubuntu-latest
@@ -21,3 +24,5 @@ jobs:
2124
vaultRoleId: ${{ secrets.VAULT_ROLE_ID }}
2225
vaultSecretId: ${{ secrets.VAULT_SECRET_ID }}
2326
pipeline: ./.github/updatecli-bump-golang.yml
27+
notifySlackChannel: "#ingest-notifications"
28+
messageIfFailure: ":traffic_cone: updatecli failed for `${{ github.repository }}@${{ github.ref_name }}`, `@agent-team` please look what's going on <${{ env.JOB_URL }}|here>"

NOTICE.txt

+166-345
Large diffs are not rendered by default.

catalog-info.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ spec:
4848
filter_condition: >-
4949
build.pull_request.id == null || (build.creator.name == 'elasticmachine' && build.pull_request.id != null)
5050
cancel_intermediate_builds: true
51-
cancel_intermediate_builds_branch_filter: "!main"
51+
cancel_intermediate_builds_branch_filter: '!main !7.* !8.* !9.*'
5252
skip_intermediate_builds: true
53-
skip_intermediate_builds_branch_filter: "!main"
53+
skip_intermediate_builds_branch_filter: '!main !7.* !8.* !9.*'
5454
env:
5555
ELASTIC_SLACK_NOTIFICATIONS_ENABLED: "true"
5656
SLACK_NOTIFICATIONS_CHANNEL: "#ingest-notifications"
@@ -96,9 +96,9 @@ spec:
9696
filter_condition: >-
9797
build.pull_request.id == null || (build.creator.name == 'elasticmachine' && build.pull_request.id != null)
9898
cancel_intermediate_builds: true
99-
cancel_intermediate_builds_branch_filter: "!main"
99+
cancel_intermediate_builds_branch_filter: '!main !7.* !8.* !9.*'
100100
skip_intermediate_builds: true
101-
skip_intermediate_builds_branch_filter: "!main"
101+
skip_intermediate_builds_branch_filter: '!main !7.* !8.* !9.*'
102102
teams:
103103
ingest-fp:
104104
access_level: MANAGE_BUILD_AND_READ
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: fleet-config-change-logging
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: Coordinator
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/owner/repo/1234
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: bug-fix
12+
13+
# Change summary; a 80ish characters long description of the change.
14+
summary: On Windows prevent uninstall from within installed directory
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: 'On Windows, prevent uninstall from within installed directory to prevent a sharing violation. Also for install and uninstall, print debug logs to stderr if command fails.'
20+
21+
# Affected component; a word indicating the component this changeset affects.
22+
component: 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/owner/repo/1234
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

dev-tools/mage/common.go

+14-6
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,14 @@ func untar(sourceFile, destinationDir string) error {
480480
if err = writer.Close(); err != nil {
481481
return err
482482
}
483+
case tar.TypeSymlink:
484+
if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil {
485+
return err
486+
}
487+
if err := os.Symlink(header.Linkname, path); err != nil {
488+
return fmt.Errorf("error creating symlink %s pointing to %s: %w", path, header.Linkname, err)
489+
}
490+
483491
default:
484492
return fmt.Errorf("unable to untar type=%c in file=%s", header.Typeflag, path)
485493
}
@@ -861,21 +869,21 @@ var parseVersionRegex = regexp.MustCompile(`(?m)^[^\d]*(?P<major>\d+)\.(?P<minor
861869

862870
// ParseVersion extracts the major, minor, and optional patch number from a
863871
// version string.
864-
func ParseVersion(version string) (major, minor, patch int, err error) {
872+
func ParseVersion(version string) (int, int, int, error) {
865873
names := parseVersionRegex.SubexpNames()
866874
matches := parseVersionRegex.FindStringSubmatch(version)
867875
if len(matches) == 0 {
868-
err = fmt.Errorf("failed to parse version '%v'", version)
869-
return
876+
err := fmt.Errorf("failed to parse version '%v'", version)
877+
return 0, 0, 0, err
870878
}
871879

872880
data := map[string]string{}
873881
for i, match := range matches {
874882
data[names[i]] = match
875883
}
876-
major, _ = strconv.Atoi(data["major"])
877-
minor, _ = strconv.Atoi(data["minor"])
878-
patch, _ = strconv.Atoi(data["patch"])
884+
major, _ := strconv.Atoi(data["major"])
885+
minor, _ := strconv.Atoi(data["minor"])
886+
patch, _ := strconv.Atoi(data["patch"])
879887
return major, minor, patch, nil
880888
}
881889

dev-tools/mage/copy.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import (
1111
"os"
1212
"path/filepath"
1313
"regexp"
14-
15-
"github.com/pkg/errors"
1614
)
1715

1816
// Copy copies a file or a directory (recursively) and preserves the permissions.
@@ -34,22 +32,25 @@ type CopyTask struct {
3432
// Execute executes the copy and returns an error of there is a failure.
3533
func (t *CopyTask) Execute() error {
3634
if err := t.init(); err != nil {
37-
return errors.Wrap(err, "copy failed")
35+
return fmt.Errorf("copy failed: %w", err)
3836
}
3937

4038
info, err := os.Stat(t.Source)
4139
if err != nil {
42-
return errors.Wrapf(err, "copy failed: cannot stat source file %v", t.Source)
40+
return fmt.Errorf("copy failed: cannot stat source file %v: %w", t.Source, err)
4341
}
4442

45-
return errors.Wrap(t.recursiveCopy(t.Source, t.Dest, fs.FileInfoToDirEntry(info)), "copy failed")
43+
if err := t.recursiveCopy(t.Source, t.Dest, fs.FileInfoToDirEntry(info)); err != nil {
44+
return fmt.Errorf("copy failed: %w", err)
45+
}
46+
return nil
4647
}
4748

4849
func (t *CopyTask) init() error {
4950
for _, excl := range t.Exclude {
5051
re, err := regexp.Compile(excl)
5152
if err != nil {
52-
return errors.Wrapf(err, "bad exclude pattern %v", excl)
53+
return fmt.Errorf("bad exclude pattern %v: %w", excl, err)
5354
}
5455
t.excludes = append(t.excludes, re)
5556
}
@@ -89,8 +90,7 @@ func (t *CopyTask) fileCopy(src, dest string, entry fs.DirEntry) error {
8990
}
9091

9192
if !info.Mode().IsRegular() {
92-
return errors.Errorf("failed to copy source file because it is not a " +
93-
"regular file")
93+
return fmt.Errorf("failed to copy source file because it is not a regular file")
9494
}
9595

9696
mode := t.Mode
@@ -126,19 +126,19 @@ func (t *CopyTask) dirCopy(src, dest string, entry fs.DirEntry) error {
126126
}
127127

128128
if err := os.MkdirAll(dest, mode&os.ModePerm); err != nil {
129-
return errors.Wrap(err, "failed creating dirs")
129+
return fmt.Errorf("failed creating dirs: %w", err)
130130
}
131131

132132
contents, err := os.ReadDir(src)
133133
if err != nil {
134-
return errors.Wrapf(err, "failed to read dir %v", src)
134+
return fmt.Errorf("failed to read dir %v: %w", src, err)
135135
}
136136

137137
for _, entry := range contents {
138-
srcFile := filepath.Join(src, info.Name())
139-
destFile := filepath.Join(dest, info.Name())
138+
srcFile := filepath.Join(src, entry.Name())
139+
destFile := filepath.Join(dest, entry.Name())
140140
if err = t.recursiveCopy(srcFile, destFile, entry); err != nil {
141-
return errors.Wrapf(err, "failed to copy %v to %v", srcFile, destFile)
141+
return fmt.Errorf("failed to copy %v to %v: %w", srcFile, destFile, err)
142142
}
143143
}
144144

dev-tools/mage/settings.go

+52-13
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"go/build"
1111
"log"
1212
"os"
13+
"path"
1314
"path/filepath"
1415
"regexp"
1516
"strconv"
@@ -19,11 +20,13 @@ import (
1920

2021
"golang.org/x/text/cases"
2122
"golang.org/x/text/language"
23+
"gopkg.in/yaml.v3"
2224

2325
"github.com/magefile/mage/sh"
2426
"golang.org/x/tools/go/vcs"
2527

2628
"github.com/elastic/elastic-agent/dev-tools/mage/gotool"
29+
v1 "github.com/elastic/elastic-agent/pkg/api/v1"
2730
)
2831

2932
const (
@@ -43,7 +46,8 @@ const (
4346
agentPackageVersionEnvVar = "AGENT_PACKAGE_VERSION"
4447

4548
// Mapped functions
46-
agentPackageVersionMappedFunc = "agent_package_version"
49+
agentPackageVersionMappedFunc = "agent_package_version"
50+
agentManifestGeneratorMappedFunc = "manifest"
4751
)
4852

4953
// Common settings with defaults derived from files, CWD, and environment.
@@ -91,18 +95,19 @@ var (
9195
ManifestURL string
9296

9397
FuncMap = map[string]interface{}{
94-
"beat_doc_branch": BeatDocBranch,
95-
"beat_version": BeatQualifiedVersion,
96-
"commit": CommitHash,
97-
"commit_short": CommitHashShort,
98-
"date": BuildDate,
99-
"elastic_beats_dir": ElasticBeatsDir,
100-
"go_version": GoVersion,
101-
"repo": GetProjectRepoInfo,
102-
"title": func(s string) string { return cases.Title(language.English, cases.NoLower).String(s) },
103-
"tolower": strings.ToLower,
104-
"contains": strings.Contains,
105-
agentPackageVersionMappedFunc: AgentPackageVersion,
98+
"beat_doc_branch": BeatDocBranch,
99+
"beat_version": BeatQualifiedVersion,
100+
"commit": CommitHash,
101+
"commit_short": CommitHashShort,
102+
"date": BuildDate,
103+
"elastic_beats_dir": ElasticBeatsDir,
104+
"go_version": GoVersion,
105+
"repo": GetProjectRepoInfo,
106+
"title": func(s string) string { return cases.Title(language.English, cases.NoLower).String(s) },
107+
"tolower": strings.ToLower,
108+
"contains": strings.Contains,
109+
agentPackageVersionMappedFunc: AgentPackageVersion,
110+
agentManifestGeneratorMappedFunc: PackageManifest,
106111
}
107112
)
108113

@@ -296,6 +301,40 @@ func AgentPackageVersion() (string, error) {
296301
return BeatQualifiedVersion()
297302
}
298303

304+
func PackageManifest() (string, error) {
305+
m := v1.NewManifest()
306+
m.Package.Snapshot = Snapshot
307+
packageVersion, err := AgentPackageVersion()
308+
if err != nil {
309+
return "", fmt.Errorf("retrieving agent package version: %w", err)
310+
}
311+
m.Package.Version = packageVersion
312+
commitHashShort, err := CommitHashShort()
313+
if err != nil {
314+
return "", fmt.Errorf("retrieving agent commit hash: %w", err)
315+
}
316+
317+
versionedHomePath := path.Join("data", fmt.Sprintf("%s-%s", BeatName, commitHashShort))
318+
m.Package.VersionedHome = versionedHomePath
319+
m.Package.PathMappings = []map[string]string{{}}
320+
m.Package.PathMappings[0][versionedHomePath] = fmt.Sprintf("data/elastic-agent-%s%s-%s", m.Package.Version, SnapshotSuffix(), commitHashShort)
321+
m.Package.PathMappings[0]["manifest.yaml"] = fmt.Sprintf("data/elastic-agent-%s%s-%s/manifest.yaml", m.Package.Version, SnapshotSuffix(), commitHashShort)
322+
yamlBytes, err := yaml.Marshal(m)
323+
if err != nil {
324+
return "", fmt.Errorf("marshaling manifest: %w", err)
325+
326+
}
327+
return string(yamlBytes), nil
328+
}
329+
330+
func SnapshotSuffix() string {
331+
if !Snapshot {
332+
return ""
333+
}
334+
335+
return "-SNAPSHOT"
336+
}
337+
299338
var (
300339
elasticBeatsDirValue string
301340
elasticBeatsDirErr error

0 commit comments

Comments
 (0)