Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for modules #39629

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
444ea6c
mysql update query
harnish-elastic Mar 14, 2024
1aa4011
add changelog entry
harnish-elastic Mar 18, 2024
465e2c4
Merge branch 'main' of https://github.com/harnish-elastic/beats into …
harnish-elastic Mar 18, 2024
0e87886
mage check command
harnish-elastic Mar 18, 2024
78a997b
make update
harnish-elastic Mar 26, 2024
b0ab6ce
change in python version to fix CI issue
harnish-elastic Mar 27, 2024
40c85b4
update python version
harnish-elastic Apr 3, 2024
bf21a73
Merge branch 'main' of https://github.com/harnish-elastic/beats into …
harnish-elastic Apr 3, 2024
7167af7
Merge branch 'main' into mysql-update-query
shmsr Apr 3, 2024
92e8b82
revert changes of python file
harnish-elastic Apr 3, 2024
a86fb55
Merge branch 'mysql-update-query' of https://github.com/harnish-elast…
harnish-elastic Apr 3, 2024
99b6521
revert install-tools.bat file changes
harnish-elastic Apr 3, 2024
0e74215
Merge branch 'main' of https://github.com/harnish-elastic/beats into …
harnish-elastic May 9, 2024
0e7dd32
Merge branch 'main' of https://github.com/harnish-elastic/beats into …
harnish-elastic May 9, 2024
cd1389a
Merge branch 'main' into mysql-update-query
harnish-elastic May 15, 2024
93484cb
Merge branch 'main' of https://github.com/harnish-elastic/beats into …
harnish-elastic May 16, 2024
be607aa
Merge branch 'mysql-update-query' of https://github.com/harnish-elast…
harnish-elastic May 16, 2024
7f6c060
Update xpack/filebeat & xpack/metricbeat pipelines to match Jenkins s…
oakrizan May 17, 2024
4edc4f6
updated module definition script
oakrizan May 17, 2024
1c5761b
Merge branch 'main' into update-changeset-script
oakrizan May 17, 2024
959df1b
Merge branch 'main' into update-changeset-script
oakrizan May 18, 2024
4e1cc82
Merge remote-tracking branch 'origin/main' into update-changeset-script
oakrizan May 20, 2024
f7887f6
Merge branch 'main' of https://github.com/harnish-elastic/beats into …
harnish-elastic May 20, 2024
5a872a4
address review comments
harnish-elastic May 20, 2024
4128eab
updated commit definition logic
oakrizan May 20, 2024
38a83b2
simplified from commit definition logic
oakrizan May 20, 2024
17d38d6
add test
dliappis May 20, 2024
2418e81
Revert "add test"
dliappis May 20, 2024
54063b3
Merge branch 'pr/38363' into fix-for-modules
dliappis May 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]
- Align on the algorithm used to transform Prometheus histograms into Elasticsearch histograms {pull}36647[36647]
- Add linux IO metrics to system/process {pull}37213[37213]
- Add new memory/cgroup metrics to Kibana module {pull}37232[37232]
- Support schema_name for MySQL performance metricset {pull}38363[38363]
- Add SSL support to mysql module {pull}37997[37997]
- Add SSL support for aerospike module {pull}38126[38126]
- Add last_terminated_timestamp metric in kubernetes module {pull}39200[39200] {issue}3802[3802]
Expand Down
9 changes: 9 additions & 0 deletions metricbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -53661,6 +53661,15 @@ type: long

--

*`mysql.performance.events_statements.schemaname`*::
+
--
Schema name.

type: keyword

--

[float]
=== table_io_waits

Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/mysql/fields.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading