From 6eec152878c1cd1bf96f0364a88c18366f38c672 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Tue, 6 Aug 2024 10:37:49 +0200 Subject: [PATCH] rebase to 7.2.6 merge limit.conf in main service files drop /etc/sysconfig/valkey rename compat package fix working dir partially enable upstream test suite Resolves: RHEL-52975 --- .gitignore | 1 + migrate_redis_to_valkey.sh | 26 +++++++++++ redisconf_to_valkeyconf.sh | 7 --- sources | 2 +- valkey-limit-systemd | 14 ------ valkey-sentinel.service | 19 ++++++-- valkey-sentinel.sysconfig | 1 - valkey.service | 20 +++++++-- valkey.spec | 90 ++++++++++++++++++++------------------ valkey.sysconfig | 1 - 10 files changed, 109 insertions(+), 72 deletions(-) create mode 100644 migrate_redis_to_valkey.sh delete mode 100644 redisconf_to_valkeyconf.sh delete mode 100644 valkey-limit-systemd delete mode 100644 valkey-sentinel.sysconfig delete mode 100644 valkey.sysconfig diff --git a/.gitignore b/.gitignore index 159a24b..b1b6515 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /valkey-7.2.5.tar.gz +/valkey-7.2.6.tar.gz diff --git a/migrate_redis_to_valkey.sh b/migrate_redis_to_valkey.sh new file mode 100644 index 0000000..64f8c0f --- /dev/null +++ b/migrate_redis_to_valkey.sh @@ -0,0 +1,26 @@ +#!/bin/sh +if [ -f /etc/redis/redis.conf ]; then + cp /etc/redis/redis.conf /etc/valkey/valkey.conf + mv /etc/redis/redis.conf /etc/redis/redis.conf.rpmsave + chown valkey:root /etc/valkey/valkey.conf + sed -i 's|^dir\s.*|dir /var/lib/valkey|g' /etc/valkey/valkey.conf + echo "/etc/redis/redis.conf has been copied to /etc/valkey/valkey.conf. Manual review of valkey.conf is strongly suggested especially if you had modified redis.conf." +fi +if [ -f /etc/redis/sentinel.conf ]; then + cp /etc/redis/sentinel.conf /etc/valkey/sentinel.conf + mv /etc/redis/sentinel.conf /etc/redis/sentinel.conf.rpmsave + chown valkey:root /etc/valkey/sentinel.conf + echo "/etc/redis/sentinel.conf has been copied to /etc/valkey/sentinel.conf. Manual review of sentinel.conf is strongly suggested especially if you had modified sentinel.conf." +fi +if [ -d /var/lib/redis ]; then + # cp could take a while, and this is a one-way move anyway + mv /var/lib/redis/* /var/lib/valkey/ + # don't leave garbage behind, plus we check if this dir exists when running this script + rm -rf /var/lib/redis + chown -R valkey. /var/lib/valkey + echo "On-disk redis dumps moved from /var/lib/redis/ to /var/lib/valkey" +fi + +# TODO +# 1. expand logic to read current redis conf for the dir setting. same for sentinel conf. if not stock /var/lib/redis, don't do the mv. redis and sentinel may be using two different paths. + diff --git a/redisconf_to_valkeyconf.sh b/redisconf_to_valkeyconf.sh deleted file mode 100644 index 3ec632c..0000000 --- a/redisconf_to_valkeyconf.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -cp /etc/redis/redis.conf /etc/valkey/valkey.conf -cp /etc/redis/sentinel.conf /etc/valkey/sentinel.conf -mv /var/lib/redis/* /var/lib/valkey/ -echo "/etc/redis/redis.conf has been copied to /etc/valkey/valkey.conf. pidfile, logfile, and dir are overridden by the config at /etc/sysconfig/valkey. Manual review of valkey.conf is strongly suggested especially if you had modified redis.conf." -echo "/etc/redis/sentinel.conf has been copied to /etc/valkey/sentinel.conf. pidfile, logfile, and dir are overridden by the config at /etc/sysconfig/valkey-sentinel. Manual review of sentinel.conf is strongly suggested especially if you had modified sentinel.conf." -echo "On-disk redis dumps moved from /var/lib/redis/ to /var/lib/valkey" diff --git a/sources b/sources index 9377bca..d3970b5 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (valkey-7.2.5.tar.gz) = 0b684a5ffe045ce51bb2f4f76429928784b8b46ee4817a95b658ffd69313a90b3d0fb12e0ddbb0b4cb57a7e0c79072f603eb4524a9bcce96ecc9ae8f1a5f02c3 +SHA512 (valkey-7.2.6.tar.gz) = 99005b82ecbcdfde38ff823aff149b9f8c97052641b098a3197bab9fb6804b068a3ecedce11b99ef790af4ceb04c2eea25ba3ec37e39be6bb9382319933226af diff --git a/valkey-limit-systemd b/valkey-limit-systemd deleted file mode 100644 index a792937..0000000 --- a/valkey-limit-systemd +++ /dev/null @@ -1,14 +0,0 @@ -# If you need to change max open file limit -# for example, when you change maxclient in configuration -# you can change the LimitNOFILE value below. -# See "man systemd.exec" for more information. - -# Slave nodes on large system may take lot of time to start. -# You may need to uncomment TimeoutStartSec and TimeoutStopSec -# directives below and raise their value. -# See "man systemd.service" for more information. - -[Service] -LimitNOFILE=10240 -#TimeoutStartSec=90s -#TimeoutStopSec=90s diff --git a/valkey-sentinel.service b/valkey-sentinel.service index e9e6caa..36093e0 100644 --- a/valkey-sentinel.service +++ b/valkey-sentinel.service @@ -5,10 +5,10 @@ After=network-online.target Wants=network-online.target [Service] +# ensure var is set +Environment=OPTIONS= EnvironmentFile=-/etc/sysconfig/valkey-sentinel -# moved $OPTIONS to start because the --dir option only overrides the config if it is passed before -# the config to the binary. I think this is a bug and will be reporting it upstream as all other -# opts don't care about the order for the override to work +# we must keep $OPTIONS and the env file as some older installs will still be using /etc/sysconfig/valkey-sentinel ExecStart=/usr/bin/valkey-sentinel /etc/valkey/sentinel.conf --daemonize no --supervised systemd $OPTIONS Type=notify User=valkey @@ -16,6 +16,19 @@ Group=valkey RuntimeDirectory=valkey RuntimeDirectoryMode=0755 +# If you need to change max open file limit +# for example, when you change maxclient in configuration +# you can change the LimitNOFILE value below. +# See "man systemd.exec" for more information. +LimitNOFILE=10240 + +# Slave nodes on large system may take lot of time to start. +# You may need to uncomment TimeoutStartSec and TimeoutStopSec +# directives below and raise their value. +# See "man systemd.service" for more information. +#TimeoutStartSec=90s +#TimeoutStopSec=90s + [Install] WantedBy=multi-user.target diff --git a/valkey-sentinel.sysconfig b/valkey-sentinel.sysconfig deleted file mode 100644 index 0203101..0000000 --- a/valkey-sentinel.sysconfig +++ /dev/null @@ -1 +0,0 @@ -OPTIONS="--logfile /var/log/valkey/sentinel.log --unixsocket /var/run/valkey/sentinel.sock --pidfile /var/run/valkey/sentinel.pid" diff --git a/valkey.service b/valkey.service index 9ff10c3..827f5f2 100644 --- a/valkey.service +++ b/valkey.service @@ -5,10 +5,11 @@ After=network-online.target Wants=network-online.target [Service] +WorkingDirectory=/var/lib/valkey +# ensure var is set +Environment=OPTIONS= EnvironmentFile=-/etc/sysconfig/valkey -# moved $OPTIONS to start because the --dir option only overrides the config if it is passed before -# the config to the binary. I think this is a bug and will be reporting it upstream as all other -# opts don't care about the order for the override to work +# we must keep $OPTIONS and the env file as some older installs will still be using /etc/sysconfig/valkey ExecStart=/usr/bin/valkey-server /etc/valkey/valkey.conf --daemonize no --supervised systemd $OPTIONS Type=notify User=valkey @@ -16,6 +17,19 @@ Group=valkey RuntimeDirectory=valkey RuntimeDirectoryMode=0755 +# If you need to change max open file limit +# for example, when you change maxclient in configuration +# you can change the LimitNOFILE value below. +# See "man systemd.exec" for more information. +LimitNOFILE=10240 + +# Slave nodes on large system may take lot of time to start. +# You may need to uncomment TimeoutStartSec and TimeoutStopSec +# directives below and raise their value. +# See "man systemd.service" for more information. +#TimeoutStartSec=90s +#TimeoutStopSec=90s + [Install] WantedBy=multi-user.target diff --git a/valkey.spec b/valkey.spec index 282f7a7..ec7cbd1 100644 --- a/valkey.spec +++ b/valkey.spec @@ -1,9 +1,9 @@ # Tests fail in mock, not in local build. -%bcond_with tests +%bcond_without tests Name: valkey -Version: 7.2.5 -Release: 4%{?dist} +Version: 7.2.6 +Release: 1%{?dist} Summary: A persistent key-value database # valkey: BSD-3-Clause # hiredis: BSD-3-Clause @@ -17,13 +17,8 @@ Source1: %{name}.logrotate Source2: %{name}-sentinel.service Source3: %{name}.service Source4: %{name}.sysusers -# could have pulled this out of unpacked sources but -# our copy has additional options pre-programmed in -Source5: %{name}-limit-systemd -Source6: %{name}.sysconfig -Source7: %{name}-sentinel.sysconfig Source8: macros.%{name} -Source9: redisconf_to_valkeyconf.sh +Source9: migrate_redis_to_valkey.sh BuildRequires: make BuildRequires: gcc @@ -36,10 +31,6 @@ BuildRequires: systemd-devel BuildRequires: systemd-rpm-macros BuildRequires: openssl-devel Requires: logrotate -Requires(pre): shadow-utils -Requires(post): systemd -Requires(preun): systemd -Requires(postun): systemd # from deps/hiredis/hiredis.h Provides: bundled(hiredis) = 1.0.3 # from deps/jemalloc/VERSION @@ -94,16 +85,19 @@ Provides: %{name}-static = %{version}-%{release} Header file required for building loadable Valkey modules. -%package compat +%package compat-redis Summary: Conversion script and compatibility symlinks for Redis -Requires: valkey -Conflicts: redis -# if change proposal is approved -#%if 0%%{?fedora} > 40 -#Obsoletes: redis <= 7.2.4 -#%endif +Requires: valkey = %{version}-%{release} +%if 0%{?fedora} > 40 || 0%{?rhel} > 9 +Obsoletes: redis < 7.4 +Provides: redis = %{version}-%{release} +%else +Conflicts: redis < 7.4 +%endif +BuildArch: noarch -%description compat + +%description compat-redis %summary @@ -134,6 +128,22 @@ if test "$api" != "%{valkey_modules_abi}"; then exit 1 fi + +sed -i -e 's|^logfile .*$|logfile /var/log/valkey/valkey.log|g' \ + -e 's|^# unixsocket .*$|unixsocket /run/valkey/valkey.sock|g' \ + -e 's|^pidfile .*$|pidfile /run/valkey/valkey.pid|g' \ + valkey.conf + +sed -i -e 's|^logfile .*$|logfile /var/log/valkey/sentinel.log|g' \ + -e 's|^pidfile .*$|pidfile /run/valkey/sentinel.pid|g' \ + sentinel.conf + +%if (%{defined fedora} && 0%{?fedora} < 42) || (%{defined rhel} && 0%{?rhel} < 10) +# these lines are for conditionals around sysconfig to valkey.conf porting scriptlets to avoid re-runs +echo '# valkey_rpm_conf' >> valkey.conf +echo '# valkey-sentinel_rpm_conf' >> sentinel.conf +%endif + %global make_flags DEBUG="" V="echo" PREFIX=%{buildroot}%{_prefix} BUILD_WITH_SYSTEMD=yes BUILD_TLS=yes %build @@ -166,10 +176,6 @@ mkdir -p %{buildroot}%{_unitdir} install -pm644 %{S:3} %{buildroot}%{_unitdir} install -pm644 %{S:2} %{buildroot}%{_unitdir} -# Install systemd limit files -install -p -D -m 644 %{S:5} %{buildroot}%{_unitdir}/%{name}.service.d/limit.conf -install -p -D -m 644 %{S:5} %{buildroot}%{_unitdir}/%{name}-sentinel.service.d/limit.conf - # Fix non-standard-executable-perm error. chmod 755 %{buildroot}%{_bindir}/%{name}-* @@ -180,19 +186,17 @@ install -pDm644 src/%{name}module.h %{buildroot}%{_includedir}/%{name}module.h #mkdir -p %{buildroot}%{_rpmmacrodir} install -pDm644 %{S:8} %{buildroot}%{_rpmmacrodir}/macros.%{name} -# Install sysconfig files -install -Dpm 644 %{S:6} %{buildroot}%{_sysconfdir}/sysconfig/%{name} -install -Dpm 644 %{S:7} %{buildroot}%{_sysconfdir}/sysconfig/%{name}-sentinel - # compat script -install -Dpm 755 %{S:9} %{buildroot}%{_libexecdir}/redisconf_to_valkeyconf.sh +install -Dpm 755 %{S:9} %{buildroot}%{_libexecdir}/migrate_redis_to_valkey.sh %check %if %{with tests} # https://github.com/redis/redis/issues/1417 (for "taskset -c 1") -taskset -c 1 make %{make_flags} test -make %{make_flags} test-sentinel +taskset -c 1 ./runtest --skiptest "Active defrag - AOF loading" + +# sentinel tests fail in mock, but we want the normal tests above +#./runtest-sentinel %endif %pre @@ -204,8 +208,8 @@ make %{make_flags} test-sentinel %systemd_post %{name}-sentinel.service -%post compat -%{_libexecdir}/redisconf_to_valkeyconf.sh +%post compat-redis +%{_libexecdir}/migrate_redis_to_valkey.sh %preun @@ -237,14 +241,8 @@ make %{make_flags} test-sentinel %{_bindir}/%{name}-* %{_unitdir}/%{name}.service %{_unitdir}/%{name}-sentinel.service -%dir %{_unitdir}/%{name}.service.d -%{_unitdir}/%{name}.service.d/limit.conf -%dir %{_unitdir}/%{name}-sentinel.service.d -%{_unitdir}/%{name}-sentinel.service.d/limit.conf %dir %attr(0755, valkey, valkey) %ghost %{_localstatedir}/run/%{name} %{_sysusersdir}/%{name}.conf -%config(noreplace) %{_sysconfdir}/sysconfig/%{name} -%config(noreplace) %{_sysconfdir}/sysconfig/%{name}-sentinel %files devel @@ -254,12 +252,20 @@ make %{make_flags} test-sentinel %{_rpmmacrodir}/macros.%{name} -%files compat -%{_libexecdir}/redisconf_to_valkeyconf.sh +%files compat-redis +%{_libexecdir}/migrate_redis_to_valkey.sh %{_bindir}/redis-* %changelog +* Tue Aug 6 2024 Remi Collet - 7.2.6.1 +- rebase to 7.2.6 +- merge limit.conf in main service files +- drop /etc/sysconfig/valkey +- rename compat package +- fix working dir +- partially enable upstream test suite + * Mon Jun 24 2024 Troy Dawson - 7.2.5-4 - Bump release for June 2024 mass rebuild diff --git a/valkey.sysconfig b/valkey.sysconfig deleted file mode 100644 index 622bdc6..0000000 --- a/valkey.sysconfig +++ /dev/null @@ -1 +0,0 @@ -OPTIONS="--logfile /var/log/valkey/valkey.log --dir /var/lib/valkey --unixsocket /var/run/valkey/valkey.sock --pidfile /var/run/valkey/valkey.pid"