Skip to content

Commit

Permalink
Merge branch 'elastic:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
agithomas authored May 20, 2024
2 parents b86ce22 + 4679220 commit 520fe3f
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 59 deletions.
101 changes: 45 additions & 56 deletions .buildkite/scripts/changesets.sh
Original file line number Diff line number Diff line change
@@ -1,77 +1,66 @@
#!/usr/bin/env bash

# This script contains helper functions related to what should be run depending on Git changes

set -euo pipefail

OSS_MODULE_PATTERN="^[a-z0-9]+beat\\/module\\/([^\\/]+)\\/.*"
XPACK_MODULE_PATTERN="^x-pack\\/[a-z0-9]+beat\\/module\\/([^\\/]+)\\/.*"

are_paths_changed() {
local patterns=("${@}")
local changelist=()
for pattern in "${patterns[@]}"; do
changed_files=($(git diff --name-only HEAD@{1} HEAD | grep -E "$pattern"))
if [ "${#changed_files[@]}" -gt 0 ]; then
changelist+=("${changed_files[@]}")
fi
done
definePattern() {
pattern="${OSS_MODULE_PATTERN}"

if [ "${#changelist[@]}" -gt 0 ]; then
echo "Files changed:"
echo "${changelist[*]}"
return 0
else
echo "No files changed within specified changeset:"
echo "${patterns[*]}"
return 1
if [[ "$beatPath" == *"x-pack/"* ]]; then
pattern="${XPACK_MODULE_PATTERN}"
fi
}

are_changed_only_paths() {
local patterns=("${@}")
local changed_files=($(git diff --name-only HEAD@{1} HEAD))
local matched_files=()
for pattern in "${patterns[@]}"; do
local matched=($(grep -E "${pattern}" <<< "${changed_files[@]}"))
if [ "${#matched[@]}" -gt 0 ]; then
matched_files+=("${matched[@]}")
fi
done
if [ "${#matched_files[@]}" -eq "${#changed_files[@]}" ] || [ "${#changed_files[@]}" -eq 0 ]; then
return 0
fi
return 1
defineExclusions() {
exclude="^$beatPath\/module\/(.*(?<!\.asciidoc|\.png))$"
}

defineModuleFromTheChangeSet() {
# This function sets a `MODULE` env var, required by IT tests, containing a comma separated list of modules for a given beats project (specified via the first argument).
# The list is built depending on directories that have changed under `modules/` excluding anything else such as asciidoc and png files.
# `MODULE` will empty if no changes apply.
local project_path=$1
local project_path_transformed=$(echo "$project_path" | sed 's/\//\\\//g')
local project_path_exclussion="((?!^${project_path_transformed}\\/).)*\$"
local exclude=("^(${project_path_exclussion}|((?!\\/module\\/).)*\$|.*\\.asciidoc|.*\\.png)")
defineFromCommit() {
local changeTarget=${BUILDKITE_PULL_REQUEST_BASE_BRANCH:-$BUILDKITE_BRANCH}

if [[ "$project_path" == *"x-pack/"* ]]; then
local pattern=("$XPACK_MODULE_PATTERN")
if [[ -z ${changeTarget+x} ]]; then
# If not a PR (no target branch) - use last commit
from=$(git rev-parse HEAD^)
else
local pattern=("$OSS_MODULE_PATTERN")
# If it's a PR - add "origin/"
from="origin/$changeTarget"
fi
local changed_modules=""
local module_dirs=$(find "$project_path/module" -mindepth 1 -maxdepth 1 -type d)
for module_dir in $module_dirs; do
if are_paths_changed $module_dir && ! are_changed_only_paths "${exclude[@]}"; then
if [[ -z "$changed_modules" ]]; then
changed_modules=$(basename "$module_dir")
else
changed_modules+=",$(basename "$module_dir")"
fi
}

getMatchingModules() {
local changedPaths
mapfile -t changedPaths < <(git diff --name-only "$from"..."$BUILDKITE_COMMIT" | grep -P "$exclude" | grep -oP "$pattern")
mapfile -t modulesMatched < <(printf "%s\n" "${changedPaths[@]}" | grep -o 'module/.*' | awk -F '/' '{print $2}' | sort -u)
}

addToModuleEnvVar() {
local module
for module in "${modulesMatched[@]}"; do
if [[ -z ${modules+x} ]]; then
modules="$module"
else
modules+=",$module"
fi
done
}

# export MODULE="" leads to an infinite loop https://github.com/elastic/ingest-dev/issues/2993
if [[ ! -z $changed_modules ]]; then
export MODULE="${changed_modules}"
echo "~~~ Set env var MODULE to [$MODULE]"
defineModuleFromTheChangeSet() {
beatPath=$1

definePattern
defineExclusions
defineFromCommit
getMatchingModules

if [ "${#modulesMatched[@]}" -gt 0 ]; then
addToModuleEnvVar
export MODULE=$modules
echo "~~~ Detected file changes for some modules. Setting env var MODULE to [$MODULE]"
echo "~~~ Resuming commands"
else
echo "~~~ No changes in modules for $beatPath"
fi
}
17 changes: 17 additions & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@
:issue: https://github.com/elastic/beats/issues/
:pull: https://github.com/elastic/beats/pull/

[[release-notes-8.13.4]]
=== Beats version 8.13.4
https://github.com/elastic/beats/compare/v8.13.3\...v8.13.4[View commits]

==== Bugfixes

*Auditbeat*

- Prevent scenario of losing children-related file events in a directory for recursive fsnotify backend of auditbeat file integrity module. {pull}39133[39133]
- Allow extra syscalls by auditbeat required in FIM with kprobes back-end. {pull}39361[39361]
- Fix losing events in FIM for MacOS X by allowing always to walk an added directory to monitor. {pull}39362[39362]

*Metricbeat*

- Fix Azure Monitor support for multiple aggregation types. {issue}39192[39192] {pull}39204[39204]


[[release-notes-8.13.3]]
=== Beats version 8.13.3
https://github.com/elastic/beats/compare/v8.13.2\...v8.13.3[View commits]
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]
- Fix losing events in FIM for OS X by allowing always to walk an added directory to monitor {pull}39362[39362]




*Filebeat*

- [Gcs Input] - Added missing locks for safe concurrency {pull}34914[34914]
Expand Down Expand Up @@ -412,6 +414,9 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]









Expand Down
1 change: 1 addition & 0 deletions libbeat/docs/release.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This section summarizes the changes in each release. Also read
<<breaking-changes>> for more detail about changes that affect
upgrade.

* <<release-notes-8.13.4>>
* <<release-notes-8.13.3>>
* <<release-notes-8.13.2>>
* <<release-notes-8.13.1>>
Expand Down
6 changes: 3 additions & 3 deletions testing/environments/snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
version: '2.3'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.15.0-177234da-SNAPSHOT
image: docker.elastic.co/elasticsearch/elasticsearch:8.15.0-1a872dbc-SNAPSHOT
# When extend is used it merges healthcheck.tests, see:
# https://github.com/docker/compose/issues/8962
# healthcheck:
Expand Down Expand Up @@ -31,7 +31,7 @@ services:
- "./docker/elasticsearch/users_roles:/usr/share/elasticsearch/config/users_roles"

logstash:
image: docker.elastic.co/logstash/logstash:8.15.0-177234da-SNAPSHOT
image: docker.elastic.co/logstash/logstash:8.15.0-1a872dbc-SNAPSHOT
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9600/_node/stats"]
retries: 600
Expand All @@ -44,7 +44,7 @@ services:
- 5055:5055

kibana:
image: docker.elastic.co/kibana/kibana:8.15.0-177234da-SNAPSHOT
image: docker.elastic.co/kibana/kibana:8.15.0-1a872dbc-SNAPSHOT
environment:
- "ELASTICSEARCH_USERNAME=kibana_system_user"
- "ELASTICSEARCH_PASSWORD=testing"
Expand Down

0 comments on commit 520fe3f

Please sign in to comment.