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

PMM-13031: Upgrades PMM 2 client with PMM 3 client. #3182

Merged
merged 2 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
27 changes: 22 additions & 5 deletions build/packages/deb/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,28 @@ 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..."
mv /usr/local/percona/pmm2/config/pmm-agent.yaml.bak /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
10 changes: 10 additions & 0 deletions build/packages/deb/postrm
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ 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 [ -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
23 changes: 23 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,24 @@ 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
mv /usr/local/percona/pmm2/config/pmm-agent.yaml.bak /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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if I got it right we remove this directory only if it's empty, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BupycHuk Yes you are right.

rmdir /usr/local/percona/pmm2
fi
fi

%build

Expand Down Expand Up @@ -132,6 +151,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