Skip to content

Commit

Permalink
Merge branch 'v3' into PMM-13129-encryption
Browse files Browse the repository at this point in the history
  • Loading branch information
JiriCtvrtka authored Oct 4, 2024
2 parents 751c084 + 730ef71 commit c1d804d
Show file tree
Hide file tree
Showing 12 changed files with 177 additions and 80 deletions.
32 changes: 26 additions & 6 deletions api-tests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,16 @@ services:
--sql-mode="ANSI_QUOTES"
--performance-schema --innodb_monitor_enable=all
--slow_query_log --slow_query_log_file=/mysql/slowlogs/slow.log --long_query_time=0
ports:
- 127.0.0.1:3306:3306
environment:
- MYSQL_ROOT_PASSWORD=root-password
- MYSQL_USER=pmm-agent
- MYSQL_PASSWORD=pmm-agent-password
- UMASK=0777 # for slowlog file
healthcheck:
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost", "-uroot", "-proot-password"]
interval: 5s
timeout: 5s
retries: 20
volumes:
- test_db_mysql:/docker-entrypoint-initdb.d/:ro
- ./testdata/mysql:/mysql
Expand All @@ -50,8 +53,6 @@ services:
image: ${MONGO_IMAGE:-percona/percona-server-mongodb:4.2}
container_name: pmm-agent_mongo
command: --profile 2
ports:
- 127.0.0.1:27017:27017
environment:
- MONGO_INITDB_ROOT_USERNAME=root
- MONGO_INITDB_ROOT_PASSWORD=root-password
Expand All @@ -66,14 +67,33 @@ services:
-c pg_stat_statements.track=all
-c pg_stat_statements.save=off
-c track_io_timing=on
ports:
- 127.0.0.1:5432:5432
environment:
- POSTGRES_USER=pmm-agent
- POSTGRES_PASSWORD=pmm-agent-password
volumes:
- test_db_postgres:/docker-entrypoint-initdb.d/


pmm-client-mysql:
image: percona/pmm-client:2
platform: "linux/amd64"
container_name: pmm-client-mysql
depends_on:
pmm-server:
condition: service_healthy
mysql:
condition: service_healthy
environment:
PMM_AGENT_SERVER_ADDRESS: pmm-server
PMM_AGENT_SERVER_USERNAME: admin
PMM_AGENT_SERVER_PASSWORD: admin
PMM_AGENT_SERVER_INSECURE_TLS: 1
PMM_AGENT_CONFIG_FILE: config/pmm-agent.yaml
PMM_AGENT_SETUP: 1
PMM_AGENT_SETUP_FORCE: 1
PMM_AGENT_SIDECAR: 1
# PMM_AGENT_PRERUN_SCRIPT: "pmm-admin status --wait=10s; pmm-admin add mysql --username=pmm-agent --password=pmm-agent-password --host=pmm-agent_mysql --port=3306"

sysbench:
image: perconalab/sysbench
container_name: pmm-agent_sysbench
Expand Down
2 changes: 1 addition & 1 deletion build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fetch:
-o ${PACKER_CACHE_DIR}/id_rsa_vagrant
chmod 600 ${PACKER_CACHE_DIR}/id_rsa_vagrant
test -f ${PACKER_CACHE_DIR}/box/oracle9.ova \
|| curl -fL https://vagrantcloud.com/bento/boxes/oracle-9.3/versions/202401.31.0/providers/virtualbox.box -o ${PACKER_CACHE_DIR}/box/oracle9.ova
|| curl -fL https://pmm-build-cache.s3.us-east-2.amazonaws.com/VBOXES/oracle9-202401.31.0.box -o ${PACKER_CACHE_DIR}/box/oracle9.ova

# NOTE: image from vagrant registry is twice as large
test -f ${PACKER_CACHE_DIR}/box/box.ovf \
Expand Down
2 changes: 2 additions & 0 deletions build/packages/deb/control
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Build-Depends: debhelper
Package: pmm-client
Architecture: any
Breaks: pmm-client
Conflicts: pmm2-client
Replaces: pmm2-client
Description: Percona Monitoring and Management Client
Percona Monitoring and Management (PMM) is an open-source platform for managing and monitoring MySQL and MongoDB
performance. It is developed by Percona in collaboration with experts in the field of managed database services,
Expand Down
33 changes: 28 additions & 5 deletions build/packages/deb/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,34 @@ fi

case "$1" in
configure)
chown -R pmm-agent:pmm-agent /usr/local/percona/pmm
if [ ! -f /usr/local/percona/pmm/config/pmm-agent.yaml ]; then
install -d -m 0755 /usr/local/percona/pmm/config
install -m 0660 -o pmm-agent -g pmm-agent /dev/null /usr/local/percona/pmm/config/pmm-agent.yaml
fi
chown -R pmm-agent:pmm-agent /usr/local/percona/pmm
if [ ! -f /usr/local/percona/pmm/config/pmm-agent.yaml ]; then
install -d -m 0755 /usr/local/percona/pmm/config
install -m 0660 -o pmm-agent -g pmm-agent /dev/null /usr/local/percona/pmm/config/pmm-agent.yaml
fi

# Backup the new pmm-agent.yaml if it exists
if [ -f /usr/local/percona/pmm2/config/pmm-agent.yaml.bak ]; then
echo "Backing up the new pmm-agent.yaml as pmm-agent.yaml.new..."
mv /usr/local/percona/pmm/config/pmm-agent.yaml /usr/local/percona/pmm/config/pmm-agent.yaml.new

echo "Restoring pmm-agent.yaml from backup..."
# Take a backup of pmm-agent.yaml and then modify it to remove paths properties
mv /usr/local/percona/pmm2/config/pmm-agent.yaml.bak /usr/local/percona/pmm/config/pmm-agent.yaml.bak
cp /usr/local/percona/pmm/config/pmm-agent.yaml.bak /usr/local/percona/pmm/config/pmm-agent.yaml
sed '/^paths:/,/^[^[:space:]]/ {
/^paths:/d
/^[^[:space:]]/!d
}' "/usr/local/percona/pmm/config/pmm-agent.yaml" > "/usr/local/percona/pmm/config/pmm-agent.yaml.tmp" && mv "/usr/local/percona/pmm/config/pmm-agent.yaml.tmp" "/usr/local/percona/pmm/config/pmm-agent.yaml"

# Clean up old directories if empty
if [ -d /usr/local/percona/pmm2/config ] && [ -z "$(ls -A /usr/local/percona/pmm2/config)" ]; then
rmdir /usr/local/percona/pmm2/config
fi
if [ -d /usr/local/percona/pmm2 ] && [ -z "$(ls -A /usr/local/percona/pmm2)" ]; then
rmdir /usr/local/percona/pmm2
fi
fi
;;

abort-upgrade|abort-remove|abort-deconfigure)
Expand Down
13 changes: 13 additions & 0 deletions build/packages/deb/postrm
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ if [ "$1" = "purge" ]; then
if [ -f /usr/local/percona/pmm/config/pmm-agent.yaml ]; then
rm -f /usr/local/percona/pmm/config/pmm-agent.yaml
fi
if [ -f /usr/local/percona/pmm/config/pmm-agent.yaml.new ]; then
rm -f /usr/local/percona/pmm/config/pmm-agent.yaml.new
fi
if [ -f /usr/local/percona/pmm/config/pmm-agent.yaml.bak ]; then
rm -f /usr/local/percona/pmm/config/pmm-agent.yaml.bak
fi

if [ -d /usr/local/percona/pmm/config ] && [ -z "$(ls -A /usr/local/percona/pmm/config)" ]; then
rmdir /usr/local/percona/pmm/config
fi
if [ -d /usr/local/percona/pmm ] && [ -z "$(ls -A /usr/local/percona/pmm)" ]; then
rmdir /usr/local/percona/pmm
fi
fi

#DEBHELPER#
Expand Down
5 changes: 5 additions & 0 deletions build/packages/deb/preinst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ if ! getent passwd pmm-agent >/dev/null 2>&1; then
adduser --system --home /usr/local/percona --group pmm-agent
fi

if [ -f /usr/local/percona/pmm2/config/pmm-agent.yaml ]; then
echo "Backing up pmm-agent.yaml before removing pmm2-client..."
mv /usr/local/percona/pmm2/config/pmm-agent.yaml /usr/local/percona/pmm2/config/pmm-agent.yaml.bak
fi

#DEBHELPER#

exit 0
29 changes: 29 additions & 0 deletions build/packages/rpm/client/pmm-client.spec
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Requires(postun): systemd

AutoReq: no
Conflicts: pmm-client
Obsoletes: pmm2-client < 3.0.0

%description
Percona Monitoring and Management (PMM) is an open-source platform for managing and monitoring MySQL and MongoDB
Expand All @@ -35,6 +36,30 @@ as possible.
%prep
%setup -q

%pretrans
if [ -f /usr/local/percona/pmm2/config/pmm-agent.yaml ]; then
cp -a /usr/local/percona/pmm2/config/pmm-agent.yaml /usr/local/percona/pmm2/config/pmm-agent.yaml.bak
fi

%posttrans
if [ -f /usr/local/percona/pmm2/config/pmm-agent.yaml.bak ]; then
mv /usr/local/percona/pmm/config/pmm-agent.yaml /usr/local/percona/pmm/config/pmm-agent.yaml.new
# Take a backup of pmm-agent.yaml and then modify it to remove paths properties
mv /usr/local/percona/pmm2/config/pmm-agent.yaml.bak /usr/local/percona/pmm/config/pmm-agent.yaml.bak
cp /usr/local/percona/pmm/config/pmm-agent.yaml.bak /usr/local/percona/pmm/config/pmm-agent.yaml
sed '/^paths:/,/^[^[:space:]]/ {
/^paths:/d
/^[^[:space:]]/!d
}' "/usr/local/percona/pmm/config/pmm-agent.yaml" > "/usr/local/percona/pmm/config/pmm-agent.yaml.tmp" && mv "/usr/local/percona/pmm/config/pmm-agent.yaml.tmp" "/usr/local/percona/pmm/config/pmm-agent.yaml"

if [ -d /usr/local/percona/pmm2/config ] && [ ! "$(ls -A /usr/local/percona/pmm2/config)" ]; then
rmdir /usr/local/percona/pmm2/config
fi

if [ -d /usr/local/percona/pmm2 ] && [ ! "$(ls -A /usr/local/percona/pmm2)" ]; then
rmdir /usr/local/percona/pmm2
fi
fi

%build

Expand Down Expand Up @@ -132,6 +157,10 @@ fi
%preun
%systemd_preun pmm-agent.service

if [ -f /usr/local/percona/pmm/config/pmm-agent.yaml.new ]; then
rm -f /usr/local/percona/pmm/config/pmm-agent.yaml.new
fi

%postun
case "$1" in
0) # This is a yum remove.
Expand Down
Loading

0 comments on commit c1d804d

Please sign in to comment.