salt icon indicating copy to clipboard operation
salt copied to clipboard

rsync state not working on RedHat / CentOS

Open CapBananoid opened this issue 10 years ago • 3 comments

Description of Issue/Question

The rsync.synchronized state doesn't work on 2016.3.2 (and previous as well 2016.3.X)

[vagrant@saltmaster master]$ sudo salt 'mono' state.apply test
mono:
  Name: rsync - Function: pkg.installed - Result: Clean
----------
          ID: rsync_from_master
    Function: rsync.synchronized
        Name: /tmp/test2
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/usr/lib/python2.7/site-packages/salt/state.py", line 1733, in call
                  **cdata['kwargs'])
                File "/usr/lib/python2.7/site-packages/salt/loader.py", line 1651, in wrapper
                  return f(*args, **kwargs)
                File "/usr/lib/python2.7/site-packages/salt/states/rsync.py", line 112, in synchronized
                  if result.get('retcode'):
              AttributeError: 'str' object has no attribute 'get'
     Started: 08:56:27.129665
    Duration: 30.972 ms
     Changes:

Summary for mono
------------
Succeeded: 1
Failed:    1
------------
Total states run:     2

Setup

Simple test.sls

rsync:
  pkg.installed

rsync_from_master:
  rsync.synchronized:
    - name: '/tmp/test2'
    - source: '/tmp/test1'
    - delete: false
    - update: true
    - prepare: true

Steps to Reproduce Issue

Create /tmp/test1 folder Launch a salt '*' state.apply test

well in fact I think it comes from the rsync module that now uses cmd.run instead of run_all, the rsync state is then getting back a string instead of a dictionnary and is not so happy with it as a workaround I m going to use the module directly.... which... was not a good idea because it doesn't return an error if rsync fails... going for the cmd.run instead

Versions Report

[vagrant@saltmaster salt]$ salt --versions-report
Salt Version:
           Salt: 2016.3.2

Dependency Versions:
           cffi: 0.8.6
       cherrypy: Not Installed
       dateutil: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.7.2
        libgit2: 0.21.0
        libnacl: Not Installed
       M2Crypto: 0.21.1
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.7
   mysql-python: Not Installed
      pycparser: 2.14
       pycrypto: 2.6.1
         pygit2: 0.21.4
         Python: 2.7.5 (default, Nov 20 2015, 02:00:19)
   python-gnupg: Not Installed
         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: centos 7.2.1511 Core
        machine: x86_64
        release: 3.10.0-327.el7.x86_64
         system: Linux
        version: CentOS Linux 7.2.1511 Core

Same config for the minion

CapBananoid avatar Aug 18 '16 09:08 CapBananoid

I am able to replicate this on 2016.3.0 and 2016.3.2. Looks like this is a new state module in 2016.3 so not a regression. thanks for the headsup Here is my testcase for added information:

/opt/user-backups:
  rsync.synchronized:
    - source: /tmp/rsync/
    - force: True

sudo salt-call --local state.sls issues.35551 -ldebug

[INFO    ] Executing command ['rsync', '-avz', '--force', '/tmp/rsync/', '/opt/user-backups'] in directory '/root'
[DEBUG   ] output: sending incremental file list
./

sent 91 bytes  received 19 bytes  220.00 bytes/sec
total size is 0  speedup is 0.00
[ERROR   ] An exception occurred in this state: Traceback (most recent call last):
  File "/home/ch3ll/git/salt/salt/state.py", line 1733, in call
    **cdata['kwargs'])
  File "/home/ch3ll/git/salt/salt/loader.py", line 1651, in wrapper
    return f(*args, **kwargs)
  File "/home/ch3ll/git/salt/salt/states/rsync.py", line 112, in synchronized
    if result.get('retcode'):
AttributeError: 'str' object has no attribute 'get'

[INFO    ] Completed state [/opt/user-backups] at time 12:13:50.406572 duration_in_ms=51.741
[DEBUG   ] File /var/cache/salt/minion/accumulator/139850384099728 does not exist, no need to cleanup.
[DEBUG   ] LazyLoaded config.option
[DEBUG   ] LazyLoaded highstate.output
local:
----------
          ID: /opt/user-backups
    Function: rsync.synchronized
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/home/ch3ll/git/salt/salt/state.py", line 1733, in call
                  **cdata['kwargs'])
                File "/home/ch3ll/git/salt/salt/loader.py", line 1651, in wrapper
                  return f(*args, **kwargs)
                File "/home/ch3ll/git/salt/salt/states/rsync.py", line 112, in synchronized
                  if result.get('retcode'):
              AttributeError: 'str' object has no attribute 'get'
     Started: 12:13:50.354831
    Duration: 51.741 ms
     Changes:   

Summary for local
------------
Succeeded: 0
Failed:    1
------------
Total states run:     1
Total run time:  51.741 ms

Ch3LL avatar Aug 18 '16 18:08 Ch3LL

@cachedout @Ch3LL This should be already fixed here: https://github.com/saltstack/salt/pull/32739

Just need to backport.

hu-dabao avatar Aug 19 '16 05:08 hu-dabao

@hu-dabao Nice find! Thank you. I've marked that for backporting.

cachedout avatar Aug 19 '16 07:08 cachedout