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

[3006.x] Fix install of logrotate config for debian pkg #65318

Merged
merged 7 commits into from
Nov 3, 2023
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 changelog/65231.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Install logrotate config as /etc/logrotate.d/salt-common for Debian packages
Remove broken /etc/logrotate.d/salt directory from 3006.3 if it exists.
File renamed without changes.
1 change: 1 addition & 0 deletions pkg/debian/salt-common.conffiles
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/etc/logrotate.d/salt-common
1 change: 1 addition & 0 deletions pkg/debian/salt-common.dirs
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
/usr/share/fish/vendor_completions.d
/opt/saltstack/salt
/etc/salt
/etc/logrotate.d
2 changes: 1 addition & 1 deletion pkg/debian/salt-common.install
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pkg/common/salt-common.logrotate /etc/logrotate.d/salt
pkg/common/logrotate/salt-common /etc/logrotate.d
pkg/common/fish-completions/salt-cp.fish /usr/share/fish/vendor_completions.d
pkg/common/fish-completions/salt-call.fish /usr/share/fish/vendor_completions.d
pkg/common/fish-completions/salt-syndic.fish /usr/share/fish/vendor_completions.d
Expand Down
4 changes: 4 additions & 0 deletions pkg/debian/salt-common.preinst
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,9 @@ case "$1" in
-s $SALT_SHELL \
-g $SALT_GROUP \
$SALT_USER

# Remove incorrectly installed logrotate config - issue 65231
test -d /etc/logrotate.d/salt && rm -r /etc/logrotate.d/salt || /bin/true

;;
esac
2 changes: 1 addition & 1 deletion pkg/rpm/salt.spec
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ install -p -m 0644 %{_salt_src}/pkg/common/[email protected] %{buildroot}%{_un
# Logrotate
#install -p %{SOURCE10} .
mkdir -p %{buildroot}%{_sysconfdir}/logrotate.d/
install -p -m 0644 %{_salt_src}/pkg/common/salt-common.logrotate %{buildroot}%{_sysconfdir}/logrotate.d/salt
install -p -m 0644 %{_salt_src}/pkg/common/logrotate/salt-common %{buildroot}%{_sysconfdir}/logrotate.d/salt

# Bash completion
mkdir -p %{buildroot}%{_sysconfdir}/bash_completion.d/
Expand Down
46 changes: 46 additions & 0 deletions pkg/tests/integration/test_logrotate_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"""
Tests for logrotate config
"""

import pathlib

import packaging.version
import pytest

pytestmark = [
pytest.mark.skip_unless_on_linux,
]


@pytest.fixture
def logrotate_config_file(grains):
"""
Fixture for logrotate config file path
"""
if grains["os_family"] == "RedHat":
return pathlib.Path("/etc/logrotate.d", "salt")
elif grains["os_family"] == "Debian":
return pathlib.Path("/etc/logrotate.d", "salt-common")


def test_logrotate_config(logrotate_config_file):
"""
Test that logrotate config has been installed in correctly
"""
assert logrotate_config_file.is_file()
assert logrotate_config_file.owner() == "root"
assert logrotate_config_file.group() == "root"


def test_issue_65231_etc_logrotate_salt_dir_removed(install_salt):
"""
Test that /etc/logrotate.d/salt is not a directory
"""
if install_salt.prev_version and packaging.version.parse(
install_salt.prev_version
) <= packaging.version.parse("3006.4"):
pytest.skip("Testing a downgrade to 3006.4, do not run")

path = pathlib.Path("/etc/logrotate.d/salt")
if path.exists():
assert path.is_dir() is False
Loading