salt icon indicating copy to clipboard operation
salt copied to clipboard

Restarting salt minion in orchestration stopped working

Open veym4os opened this issue 7 years ago • 6 comments

Description of Issue

Since the update of minion and master from 2019.2.0 to 2019.2.2, restarting a minion within an orchestration does not work anymore.

Steps to Reproduce Issue

Requires at least one master and minion. It does not matter if those are different machines, result is the same.

# orchestrate/minion-restart.sls
restart minion:
  salt.function:
    - tgt:
      - salt1
    - tgt_type: list
    - name: service.restart
    - arg:
      - salt-minion

wait for minion restart:
  salt.wait_for_event:
    - name: salt/minion/*/start
    - id_list:
      - salt1
    - require:
      - salt: restart minion

On the master run:

salt-run state.orchestrate orchestrate.minion-restart

Expected result: Succes, minion process on minion salt1 is restartet.

Since salt 2019.2.2, the run returns an error:

# salt-run state.orchestrate orchestrate.minion-restart
[ERROR   ] No changes made for service.restart
salt1_master:
----------
          ID: restart minion
    Function: salt.function
        Name: service.restart
      Result: False
     Comment: 
     Started: 10:42:10.481748
    Duration: 15247.467 ms
     Changes:   

Summary for salt1_master
------------
Succeeded: 0
Failed:    1
------------
Total states run:     1
Total run time:  15.247 s

Minion log during the run (log_level: debug):

2019-11-05 10:51:53,587 [salt.utils.lazy  :104 ][DEBUG   ][26207] LazyLoaded list_match.match
2019-11-05 10:51:53,587 [salt.minion      :1482][INFO    ][26207] User root Executing command service.restart with jid 20191105105153581390
2019-11-05 10:51:53,588 [salt.minion      :1489][DEBUG   ][26207] Command details {u'tgt_type': u'list', u'jid': u'20191105105153581390', u'tgt': [u'salt1'], u'ret': u'', u'user': u'root', u'arg': [u'salt-minion'], u'fun': u'service.restart'}
2019-11-05 10:51:53,590 [salt.utils.process:860 ][DEBUG   ][26207] Subprocess SignalHandlingMultiprocessingProcess-1:3-Job-20191105105153581390 added
2019-11-05 10:51:53,648 [salt.utils.lazy  :104 ][DEBUG   ][26542] LazyLoaded jinja.render
2019-11-05 10:51:53,650 [salt.utils.lazy  :104 ][DEBUG   ][26542] LazyLoaded yaml.render
2019-11-05 10:51:53,652 [salt.minion      :1609][INFO    ][26542] Starting a new job 20191105105153581390 with PID 26542
2019-11-05 10:51:53,655 [salt.utils.lazy  :107 ][DEBUG   ][26542] Could not LazyLoad {0}.allow_missing_func: '{0}.allow_missing_func' is not available.
2019-11-05 10:51:53,666 [salt.utils.lazy  :104 ][DEBUG   ][26542] LazyLoaded systemd.booted
2019-11-05 10:51:53,669 [salt.utils.lazy  :104 ][DEBUG   ][26542] LazyLoaded service.restart
2019-11-05 10:51:53,671 [salt.utils.lazy  :104 ][DEBUG   ][26542] LazyLoaded cmd.run_all
2019-11-05 10:51:53,672 [salt.loaded.int.module.cmdmod:397 ][INFO    ][26542] Executing command [u'systemctl', 'status', u'salt-minion.service', u'-n', u'0'] in directory '/root'
2019-11-05 10:51:53,689 [salt.loaded.int.module.cmdmod:843 ][DEBUG   ][26542] stdout: * salt-minion.service - The Salt Minion
   Loaded: loaded (/usr/lib/systemd/system/salt-minion.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2019-11-05 10:51:16 CET; 36s ago
     Docs: man:salt-minion(1)
           file:///usr/share/doc/salt/html/contents.html
           https://docs.saltstack.com/en/latest/contents.html
 Main PID: 26201 (salt-minion)
   Memory: 76.4M
   CGroup: /system.slice/salt-minion.service
           |-26201 /usr/bin/python /usr/bin/salt-minion
           |-26207 /usr/bin/python /usr/bin/salt-minion
           |-26209 /usr/bin/python /usr/bin/salt-minion
           |-26542 /usr/bin/python /usr/bin/salt-minion
           `-26543 systemctl status salt-minion.service -n 0
2019-11-05 10:51:53,703 [salt.utils.lazy  :104 ][DEBUG   ][26542] LazyLoaded config.get
2019-11-05 10:51:53,703 [salt.loaded.int.module.config:398 ][DEBUG   ][26542] key: systemd.scope, ret: _|-
2019-11-05 10:51:53,704 [salt.loaded.int.module.cmdmod:397 ][INFO    ][26542] Executing command [u'systemd-run', u'--scope', u'systemctl', 'restart', u'salt-minion.service'] in directory '/root'
2019-11-05 10:51:53,723 [salt.utils.parsers:1071][WARNING ][26207] Minion received a SIGTERM. Exiting.
2019-11-05 10:51:53,723 [salt.cli.daemons :85  ][INFO    ][26207] Shutting down the Salt Minion
2019-11-05 10:51:53,724 [salt.log.setup   :1044][DEBUG   ][26207] Stopping the multiprocessing logging queue listener
2019-11-05 10:51:54,226 [salt.log.setup   :1050][DEBUG   ][26207] closing multiprocessing queue
2019-11-05 10:51:54,227 [salt.log.setup   :1052][DEBUG   ][26207] joining multiprocessing queue thread
2019-11-05 10:51:54,229 [salt.log.setup   :1066][DEBUG   ][26207] Stopped the multiprocessing logging queue listener

Between printing the last line of log and the master's error message, there is a delay of about 10 seconds.

Versions Report

Salt Version:
           Salt: 2019.2.2
 
Dependency Versions:
           cffi: 1.6.0
       cherrypy: Not Installed
       dateutil: Not Installed
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.7.2
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: 0.31.0
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.5.6
   mysql-python: Not Installed
      pycparser: 2.14
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.5 (default, Aug  7 2019, 08:19:52)
   python-gnupg: 0.4.3
         PyYAML: 3.11
          PyZMQ: 15.3.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.1.4
 
System Versions:
           dist: oracle 7.7 
         locale: UTF-8
        machine: x86_64
        release: 4.1.12-124.32.3.el7uek.x86_64
         system: Linux
        version: Oracle Linux Server 7.7 

veym4os avatar Nov 05 '19 10:11 veym4os

looks like i was able to replicate this. i bisected it to this commit 9f1fe42b3cca0809616e2782a13b8bbf4dd4e3c9 which is this PR https://github.com/saltstack/salt/pull/54259

I also saw this fail on the head of master.

Ch3LL avatar Nov 06 '19 15:11 Ch3LL

it seems like this also impacts attempting to do a salt '*' service.restart salt-minion

Ch3LL avatar Nov 06 '19 15:11 Ch3LL

Based on the activity on this issue, this has been moved from being worked on for Sodium to Magnesium? When is that expected to be released? I was really sad to find that restarting the salt minion via salt broke when we upgraded from 2018.3.3 to 3000.3. Looking forward to this issue being fixed as with 3000.3 neither restarting the salt-minion via salt or reloading modules in states is working for us, which when standing up new VMs means running the same state multiple times to get the salt-minion to load modules after dependencies are installed.

robertpenberthy avatar Jun 15 '20 17:06 robertpenberthy

Spent some time on this and still digging in, but this updated orchestration state will restart the minion as expected. Rather than calling service.restart directly from the reactor we call cmd.run and then call service.restart via cmd.run.

restart minion:
  salt.function:
    - tgt:
      - packer-local-minion
    - tgt_type: list
    - name: cmd.run
    - arg:
      - "salt-call service.restart salt-minion"
    - kwarg:
        bg: True

wait for minion restart:
  salt.wait_for_event:
    - name: salt/minion/*/start
    - id_list:
      - packer-local-minion
    - require:
      - salt: restart minion

garethgreenaway avatar Nov 06 '20 22:11 garethgreenaway

I encounter this as well - with module.run.

tacerus avatar Jun 08 '22 11:06 tacerus

Closing this due to age and the old version of Salt. Can you retest this with the latest release of Salt 3006.2 and if this is still an issue, please open a new issue.

garethgreenaway avatar Aug 28 '23 18:08 garethgreenaway