salt icon indicating copy to clipboard operation
salt copied to clipboard

Recurse failed with gitfs per-remote mountpoint and file.recurse

Open jasonrm opened this issue 11 years ago • 8 comments

I've been unable to use a git repo with no sub directories at a mountpoint with file.recurse.

My guess is that because mountpoints aren't appearing in cp.list_master_dirs, for similar reasons, it also isn't being seen by file.recurse as a directory. I should be able to work around this by placing the files in my sphinx repo into a sub directory for now, but that shouldn't be required.

$ salt minion.example.com state.highstate test=True
[snip]
----------
          ID: /etc/sphinx/conf.d
    Function: file.recurse
      Result: False
     Comment: Recurse failed: none of the specified sources were found
     Started: 22:41:35.437446
    Duration: 18.539 ms
     Changes:   
----------
[snip]
$ salt minion.example.com cp.list_master_dirs
minion.example.com:
    - zsh
    - zsh/files
$ salt minion.example.com cp.list_master
minion.example.com:
    - cfg/sphinx/00_core.conf
    - cfg/sphinx/10_products.conf
    - cfg/sphinx/20_forums.conf
    - cfg/sphinx/30_blogs.conf
    - top.sls
    - zsh/files/zshrc
    - zsh/init.sls

/etc/salt/master

fileserver_backend:
  - git
gitfs_remotes:
  - ssh://[email protected]/salt/states.git
  - ssh://[email protected]/salt/zsh-formula.git
  - ssh://[email protected]/cfg/sphinx.git:
    - mountpoint: salt://cfg/sphinx

Salt State

/etc/sphinx/conf.d:
  file.recurse:
    - source: salt://cfg/sphinx
    - dir_mode: 0755
    - file_mode: 0644

Versions

$ uname -a
Linux energy 3.18.6-1-ARCH #1 SMP PREEMPT Sat Feb 7 08:44:05 CET 2015 x86_64 GNU/Linux
$ salt --versions                                          
           Salt: 2014.7.2
         Python: 2.7.9 (default, Dec 11 2014, 04:42:00)
         Jinja2: 2.7.3
       M2Crypto: 0.22
 msgpack-python: 0.4.5
   msgpack-pure: Not Installed
       pycrypto: 2.6.1
        libnacl: Not Installed
         PyYAML: 3.11
          ioflo: Not Installed
          PyZMQ: 14.5.0
           RAET: Not Installed
            ZMQ: 4.0.5
           Mako: Not Installed

jasonrm avatar Feb 18 '15 23:02 jasonrm

@jasonrm Thanks for this very detailed report! That will help very much in reproducing your issue. I haven't ever used file.recurse with gitfs, so I am not quite sure what the fix is here, however @terminalmage might be able to take a look here.

rallytime avatar Feb 20 '15 21:02 rallytime

@jasonrm Your assessment was right on, great catch. This is fixed in #21411.

terminalmage avatar Mar 08 '15 07:03 terminalmage

Fix was merged, closing.

terminalmage avatar Mar 09 '15 17:03 terminalmage

I am running salt-master with 2014.7.4-4. But I still have this problem. Running gitfs with gitpython.

deuscapturus avatar Apr 15 '15 21:04 deuscapturus

I can't reproduce with 2014.7.4, it works fine for me. Try stopping the salt-master service, then check and see if any stray salt-master processes are still running. If there are any, kill them. Then start the salt-master.

If you still have the same issue, please provide a reproducible use case.

terminalmage avatar Apr 15 '15 22:04 terminalmage

I reverted back to 2014.7.1 and moved to gitfs to pygit2. It's now working. I don't know which resolved the problem though. @terminalmage were you running exactly version 2014.7.4-4 and using gitpython for gitfs?

deuscapturus avatar Apr 15 '15 23:04 deuscapturus

The -4 doesn't have anything to do with the Salt version, that's the revision of the RPM. I tested with 2014.7.4 and gitpython.

terminalmage avatar Apr 15 '15 23:04 terminalmage

@terminalmage @deuscapturus My Salt is 2014.7.4, OS: CentOS 6.5 , Python: 2.6.6

I found "_modules" didn't sync to minion with "saltutil.sync_modules", I tracked the code, found some unusual things in "fileserver/gitfs.py" https://github.com/saltstack/salt/blob/v2014.7.5/salt/fileserver/gitfs.py#L1702

relpath = lambda path: os.path.relpath(path, repo['root'])

the repo['root'] is "", path is ".gitignore", the result is "../.gitignore" after relpath, it's unusual.

I tested the code in python console, the result was ".gitignore". But I tested os.path.relpath in this file, the result was "../gitignore" again.....

pengyao avatar Apr 24 '15 10:04 pengyao