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

[BUG] Salt minion 3006.9 does not respect /usr/sbin/policy-rc.d on Debian derivatives #67052

Open
1 of 9 tasks
lubyou opened this issue Nov 14, 2024 · 0 comments
Open
1 of 9 tasks
Labels
Bug broken, incorrect, or confusing behavior needs-triage

Comments

@lubyou
Copy link
Contributor

lubyou commented Nov 14, 2024

Description

The postinst in 3006.9 directly uses systemctl to restart a minion after an upgrade instead of using deb-systemd-invoke:

systemctl restart salt-minion

/usr/sbin/policy-rc.d gets ignored as result.

The following patch seems to restore the previous behaviour:

--- 3006.9/postinst	2024-07-29 07:42:36.000000000 +0000
+++ 3006.9-fix-postinst/postinst	2024-11-07 22:17:46.816048641 +0000
@@ -16,13 +16,14 @@
       fi
       chown -R $RET:$RET /etc/salt/pki/minion /etc/salt/minion.d /var/log/salt/minion /var/cache/salt/minion /var/run/salt/minion
     fi
-    if command -v systemctl; then
+    command -v systemctl >/dev/null
+    if [ $? -eq 0 ]; then
         db_get salt-minion/active
         RESLT=$(echo "$RET" | cut -d ' ' -f 1)
         if [ "$RESLT" != 10 ]; then
             systemctl daemon-reload
             if [ "$RESLT" = "active" ]; then
-                systemctl restart salt-minion
+                deb-systemd-invoke restart salt-minion
             fi
             db_get salt-minion/enabled
             RESLT=$(echo "$RET" | cut -d ' ' -f 1)
@@ -33,7 +34,7 @@
             fi
         else
             systemctl daemon-reload
-            systemctl restart salt-minion
+            deb-systemd-invoke restart salt-minion
             systemctl enable salt-minion
         fi
     fi

Setup
(Please provide relevant configs and/or SLS files (be sure to remove sensitive info. There is no general set-up of Salt.)

Please be as specific as possible and give set-up details.

  • on-prem machine
  • VM (Virtualbox, KVM, etc. please specify)
  • VM running on a cloud service, please be explicit and add details
  • container (Kubernetes, Docker, containerd, etc. please specify)
  • or a combination, please be explicit
  • jails if it is FreeBSD
  • classic packaging
  • onedir packaging
  • used bootstrap to install

Steps to Reproduce the behavior

# define /usr/sbin/policy-rc.d
printf '#!/bin/sh\nexit 101' | sudo tee /usr/sbin/policy-rc.d && sudo chmod +x /usr/sbin/policy-rc.d
# 3006.7 to 3006.8 upgrade, `/usr/sbin/policy-rc.d` is respected
DEBIAN_FRONTEND=noninteracive sudo apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install salt-common=3006.8 salt-minion=3006.8
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Suggested packages:
  ifupdown
The following packages will be upgraded:
  salt-common salt-minion
2 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.
Need to get 0 B/34.3 MB of archives.
After this operation, 2,846 kB of additional disk space will be used.
(Reading database ... 116481 files and directories currently installed.)
Preparing to unpack .../salt-common_3006.8_amd64.deb ...
usermod: no changes
Unpacking salt-common (3006.8) over (3006.7) ...
Preparing to unpack .../salt-minion_3006.8_amd64.deb ...
Unpacking salt-minion (3006.8) over (3006.7) ...
Setting up salt-common (3006.8) ...
Setting up salt-minion (3006.8) ...

Configuration file '/etc/salt/minion'
 ==> Modified (by you or by a script) since installation.
 ==> Package distributor has shipped an updated version.
 ==> Keeping old config file as default.
/usr/sbin/policy-rc.d returned 101, not running 'restart salt-minion.service'
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for libc-bin (2.35-0ubuntu3.8) ...
# upgrade from 3006.8 to 3006.9, /usr/sbin/policy-rc.d is not considered
DEBIAN_FRONTEND=noninteracive sudo apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install salt-common=3006.9 salt-minion=3006.9
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Suggested packages:
  ifupdown
The following packages will be upgraded:
  salt-common salt-minion
2 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.
Need to get 0 B/34.3 MB of archives.
After this operation, 221 kB of additional disk space will be used.
Preconfiguring packages ...
(Reading database ... 116522 files and directories currently installed.)
Preparing to unpack .../salt-common_3006.9_amd64.deb ...
usermod: no changes
Unpacking salt-common (3006.9) over (3006.8) ...
Preparing to unpack .../salt-minion_3006.9_amd64.deb ...
/usr/bin/systemctl
Unpacking salt-minion (3006.9) over (3006.8) ...
Setting up salt-common (3006.9) ...
Setting up salt-minion (3006.9) ...
/usr/bin/systemctl
Synchronizing state of salt-minion.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable salt-minion
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for libc-bin (2.35-0ubuntu3.8) ...
Scanning processes...
Scanning candidates...
Scanning linux images...

Expected behavior
/usr/sbin/policy-rc.d should be considered.

Versions Report

Salt Version:
          Salt: 3006.9

Python Version:
        Python: 3.10.14 (main, Jun 26 2024, 11:44:37) [GCC 11.2.0]

Dependency Versions:
          cffi: 1.14.6
      cherrypy: 18.6.1
  cryptography: 42.0.5
      dateutil: 2.8.1
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 3.1.4
       libgit2: Not Installed
  looseversion: 1.0.2
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.0.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     packaging: 22.0
     pycparser: 2.21
      pycrypto: Not Installed
  pycryptodome: 3.19.1
        pygit2: Not Installed
  python-gnupg: 0.4.8
        PyYAML: 6.0.1
         PyZMQ: 23.2.0
        relenv: 0.17.0
         smmap: Not Installed
       timelib: 0.2.4
       Tornado: 4.5.3
           ZMQ: 4.3.4

System Versions:
          dist: ubuntu 22.04.5 jammy
        locale: utf-8
       machine: x86_64
       release: 5.15.0-86-generic
        system: Linux
       version: Ubuntu 22.04.5 jammy
@lubyou lubyou added Bug broken, incorrect, or confusing behavior needs-triage labels Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior needs-triage
Projects
None yet
Development

No branches or pull requests

1 participant