From 1e54c5998d19d1804aace3f80c2529087624e832 Mon Sep 17 00:00:00 2001 From: Maxim Styushin Date: Fri, 16 Aug 2024 18:48:53 +0400 Subject: [PATCH 1/4] fix: run on systems with newer setuptools - Don't use pkg_resources.packaging if installed version of setuptools doesn't support it --- mamonsu/plugins/pgsql/driver/pg8000/core.py | 6 +++++- mamonsu/plugins/pgsql/driver/pool.py | 5 ++++- mamonsu/plugins/pgsql/memory_leak_diagnostic.py | 5 ++++- mamonsu/plugins/pgsql/replication.py | 6 +++++- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/mamonsu/plugins/pgsql/driver/pg8000/core.py b/mamonsu/plugins/pgsql/driver/pg8000/core.py index 7816bff..26db69a 100755 --- a/mamonsu/plugins/pgsql/driver/pg8000/core.py +++ b/mamonsu/plugins/pgsql/driver/pg8000/core.py @@ -2,12 +2,16 @@ from collections import defaultdict, deque from datetime import datetime as Datetime from decimal import Decimal -from pkg_resources import packaging from hashlib import md5 from itertools import count, islice from struct import Struct from warnings import warn +try: + from pkg_resources import packaging +except ImportError: + import packaging.version + from mamonsu.plugins.pgsql.driver.pg8000 import converters from .exceptions import ( ArrayContentNotSupportedError, DatabaseError, Error, IntegrityError, diff --git a/mamonsu/plugins/pgsql/driver/pool.py b/mamonsu/plugins/pgsql/driver/pool.py index b7ca620..bfd4749 100644 --- a/mamonsu/plugins/pgsql/driver/pool.py +++ b/mamonsu/plugins/pgsql/driver/pool.py @@ -1,6 +1,9 @@ -from pkg_resources import packaging from .connection import Connection, ConnectionInfo +try: + from pkg_resources import packaging +except ImportError: + import packaging.version class Pool(object): ExcludeDBs = ["template0", "template1"] diff --git a/mamonsu/plugins/pgsql/memory_leak_diagnostic.py b/mamonsu/plugins/pgsql/memory_leak_diagnostic.py index cb368a9..c22c5f9 100644 --- a/mamonsu/plugins/pgsql/memory_leak_diagnostic.py +++ b/mamonsu/plugins/pgsql/memory_leak_diagnostic.py @@ -4,10 +4,13 @@ import os from .pool import Pooler import re -from pkg_resources import packaging import mamonsu.lib.platform as platform import posix +try: + from pkg_resources import packaging +except ImportError: + import packaging.version class MemoryLeakDiagnostic(Plugin): DEFAULT_CONFIG = { diff --git a/mamonsu/plugins/pgsql/replication.py b/mamonsu/plugins/pgsql/replication.py index 0c53f5b..78d841a 100644 --- a/mamonsu/plugins/pgsql/replication.py +++ b/mamonsu/plugins/pgsql/replication.py @@ -1,10 +1,14 @@ # -*- coding: utf-8 -*- from mamonsu.plugins.pgsql.plugin import PgsqlPlugin as Plugin -from pkg_resources import packaging from .pool import Pooler from mamonsu.lib.zbx_template import ZbxTemplate +try: + from pkg_resources import packaging +except ImportError: + import packaging.version + NUMBER_NON_ACTIVE_SLOTS = 0 From f94a504671be0ce028065556617f6b59b14ee5ad Mon Sep 17 00:00:00 2001 From: Maxim Styushin Date: Fri, 16 Aug 2024 18:53:59 +0400 Subject: [PATCH 2/4] build: fix RPM buildspec - Stop using old-style user:group specification in chown calls --- packaging/rpm/SPECS/mamonsu.spec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packaging/rpm/SPECS/mamonsu.spec b/packaging/rpm/SPECS/mamonsu.spec index f35fbd9..6fc2357 100644 --- a/packaging/rpm/SPECS/mamonsu.spec +++ b/packaging/rpm/SPECS/mamonsu.spec @@ -57,20 +57,20 @@ getent passwd mamonsu > /dev/null || \ -c "mamonsu monitoring user" mamonsu mkdir -p /var/run/mamonsu -chown -R mamonsu.mamonsu /var/run/mamonsu +chown -R mamonsu:mamonsu /var/run/mamonsu mkdir -p /etc/mamonsu/plugins touch /etc/mamonsu/plugins/__init__.py mkdir -p /var/log/mamonsu -chown -R mamonsu.mamonsu /var/log/mamonsu +chown -R mamonsu:mamonsu /var/log/mamonsu %preun /sbin/service mamonsu stop >/dev/null 2>&1 /sbin/chkconfig --del mamonsu %post -chown -R mamonsu.mamonsu /etc/mamonsu +chown -R mamonsu:mamonsu /etc/mamonsu %changelog * Thu Apr 18 2024 Maxim Styushin - 3.5.8-1 From 4f1a44c52435ff054c1f5df386f7c7281ec8ddd5 Mon Sep 17 00:00:00 2001 From: Maxim Styushin Date: Mon, 19 Aug 2024 12:43:49 +0400 Subject: [PATCH 3/4] cicd: fix url for EPEL rpm (moved to archives) --- github-actions-tests/tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github-actions-tests/tests.sh b/github-actions-tests/tests.sh index 36e3e71..5562da6 100644 --- a/github-actions-tests/tests.sh +++ b/github-actions-tests/tests.sh @@ -69,7 +69,7 @@ REPO eval "${PACKAGE_MANAGER_INSTALL} wget" eval "${PACKAGE_MANAGER_INSTALL} bc" eval "${PACKAGE_MANAGER_INSTALL} unzip" - eval "${PACKAGE_MANAGER_INSTALL} https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm" + eval "${PACKAGE_MANAGER_INSTALL} https://archives.fedoraproject.org/pub/archive/epel/7/x86_64/Packages/e/epel-release-7-14.noarch.rpm" REPO=${PACKAGE_MANAGER_INSTALL}" https://download.postgresql.org/pub/repos/yum/reporpms/EL-"$(echo ${OS} | sed -r 's/^[^0-9]*([0-9]+).*/\1/')"-x86_64/pgdg-redhat-repo-latest.noarch.rpm"\ # run tests From 29961c24bc3cbb100025902433990d2b88e346ad Mon Sep 17 00:00:00 2001 From: Maxim Styushin Date: Mon, 19 Aug 2024 12:58:17 +0400 Subject: [PATCH 4/4] build: upgrade to 3.5.9 --- .github/workflows/mamonsu-tests-dev.yml | 2 +- .github/workflows/mamonsu-tests-master.yml | 2 +- github-actions-tests/mamonsu_build.sh | 4 ++-- .../sources/{agent_3.5.8.conf => agent_3.5.9.conf} | 0 mamonsu/__init__.py | 2 +- packaging/debian/changelog | 4 ++++ packaging/rpm/SPECS/mamonsu.spec | 6 +++++- packaging/win/mamonsu.def.nsh | 2 +- 8 files changed, 15 insertions(+), 7 deletions(-) rename github-actions-tests/sources/{agent_3.5.8.conf => agent_3.5.9.conf} (100%) diff --git a/.github/workflows/mamonsu-tests-dev.yml b/.github/workflows/mamonsu-tests-dev.yml index 22386fb..0162db9 100644 --- a/.github/workflows/mamonsu-tests-dev.yml +++ b/.github/workflows/mamonsu-tests-dev.yml @@ -80,7 +80,7 @@ jobs: echo "zabbix_address=$(hostname -I | awk '{print $1}')" >> $GITHUB_OUTPUT id: zabbix_address - name: Edit Zabbix address in agent.conf - run: sed -i "s/\(address *= *\).*/\1 ${{ steps.zabbix_address.outputs.zabbix_address }}/" ${{ env.MAMONSU_PATH }}/github-actions-tests/sources/agent_3.5.8.conf + run: sed -i "s/\(address *= *\).*/\1 ${{ steps.zabbix_address.outputs.zabbix_address }}/" ${{ env.MAMONSU_PATH }}/github-actions-tests/sources/agent_3.5.9.conf - name: Copy test scripts to container run: docker exec $( echo "${{ matrix.docker_os }}" | sed 's/://' | sed 's/\.//' ) mkdir -p -m 755 /mamonsu/ diff --git a/.github/workflows/mamonsu-tests-master.yml b/.github/workflows/mamonsu-tests-master.yml index 2cdde54..0d895af 100644 --- a/.github/workflows/mamonsu-tests-master.yml +++ b/.github/workflows/mamonsu-tests-master.yml @@ -91,7 +91,7 @@ jobs: echo "zabbix_address=$(hostname -I | awk '{print $1}')" >> $GITHUB_OUTPUT id: zabbix_address - name: Edit Zabbix address in agent.conf - run: sed -i "s/\(address *= *\).*/\1 ${{ steps.zabbix_address.outputs.zabbix_address }}/" ${{ env.MAMONSU_PATH }}/github-actions-tests/sources/agent_3.5.8.conf + run: sed -i "s/\(address *= *\).*/\1 ${{ steps.zabbix_address.outputs.zabbix_address }}/" ${{ env.MAMONSU_PATH }}/github-actions-tests/sources/agent_3.5.9.conf - name: Copy test scripts to container run: docker exec $( echo "${{ matrix.docker_os }}" | sed 's/://' | sed 's/\.//' ) mkdir -p -m 755 /mamonsu/ diff --git a/github-actions-tests/mamonsu_build.sh b/github-actions-tests/mamonsu_build.sh index bc7d5e4..137e072 100644 --- a/github-actions-tests/mamonsu_build.sh +++ b/github-actions-tests/mamonsu_build.sh @@ -41,7 +41,7 @@ if [ "${OS%:*}" = "centos" ]; then python3 setup.py build && python3 setup.py install make rpm sudo rpm -i ./mamonsu*.rpm - cat /mamonsu/github-actions-tests/sources/agent_3.5.8.conf > /etc/mamonsu/agent.conf + cat /mamonsu/github-actions-tests/sources/agent_3.5.9.conf > /etc/mamonsu/agent.conf systemctl daemon-reload systemctl restart mamonsu sleep 5 @@ -64,7 +64,7 @@ elif [ "${OS%:*}" = "ubuntu" ]; then python3 setup.py build && python3 setup.py install make deb sudo dpkg -i ./mamonsu*.deb - cat /mamonsu/github-actions-tests/sources/agent_3.5.8.conf > /etc/mamonsu/agent.conf + cat /mamonsu/github-actions-tests/sources/agent_3.5.9.conf > /etc/mamonsu/agent.conf service mamonsu restart sleep 5 echo && echo && echo "mamonsu version:" diff --git a/github-actions-tests/sources/agent_3.5.8.conf b/github-actions-tests/sources/agent_3.5.9.conf similarity index 100% rename from github-actions-tests/sources/agent_3.5.8.conf rename to github-actions-tests/sources/agent_3.5.9.conf diff --git a/mamonsu/__init__.py b/mamonsu/__init__.py index 0a9cadd..634d8d3 100644 --- a/mamonsu/__init__.py +++ b/mamonsu/__init__.py @@ -1,7 +1,7 @@ __author__ = 'Dmitry Vasilyev' __author_email__ = 'info@postgrespro.ru' __description__ = 'Monitoring agent for PostgreSQL' -__version__ = '3.5.8' +__version__ = '3.5.9' __licence__ = 'BSD' __url__ = 'https://github.com/postgrespro/mamonsu' diff --git a/packaging/debian/changelog b/packaging/debian/changelog index 0a0c778..dd77d37 100644 --- a/packaging/debian/changelog +++ b/packaging/debian/changelog @@ -1,3 +1,7 @@ +mamonsu (3.5.9-1) stable; urgency=low + * Run on systems with latest setuptools installed (>67.7.2); + * Drop using dotted user:group specification in RPM pre-install stage; + mamonsu (3.5.8-1) stable; urgency=low * Prepare for python 3.12: remove deprecated distutils imports; diff --git a/packaging/rpm/SPECS/mamonsu.spec b/packaging/rpm/SPECS/mamonsu.spec index 6fc2357..f9e19b1 100644 --- a/packaging/rpm/SPECS/mamonsu.spec +++ b/packaging/rpm/SPECS/mamonsu.spec @@ -1,5 +1,5 @@ Name: mamonsu -Version: 3.5.8 +Version: 3.5.9 Release: 1%{?dist} Summary: Monitoring agent for PostgreSQL Group: Applications/Internet @@ -73,6 +73,10 @@ chown -R mamonsu:mamonsu /var/log/mamonsu chown -R mamonsu:mamonsu /etc/mamonsu %changelog +* Mon Aug 19 2024 Maxim Styushin - 3.5.9-1 + - Run on systems with latest setuptools installed (>67.7.2); + - Drop using dotted user:group specification in RPM pre-install stage; + * Thu Apr 18 2024 Maxim Styushin - 3.5.8-1 - Prepare for python 3.12: remove deprecated distutils imports; diff --git a/packaging/win/mamonsu.def.nsh b/packaging/win/mamonsu.def.nsh index 1e32c88..5ca5afc 100644 --- a/packaging/win/mamonsu.def.nsh +++ b/packaging/win/mamonsu.def.nsh @@ -1,5 +1,5 @@ !define NAME Mamonsu -!define VERSION 3.5.8 +!define VERSION 3.5.9 !define MAMONSU_REG_PATH "Software\PostgresPro\Mamonsu" !define MAMONSU_REG_UNINSTALLER_PATH "Software\Microsoft\Windows\CurrentVersion\Uninstall" !define EDB_REG "SOFTWARE\Postgresql"