Open gigi206 opened 5 years ago
@gigi206 Since I don't have access to your repo I've tried to replicate this using the salt-formula repo as described in the gitfs walkthrough: https://docs.saltstack.com/en/latest/topics/tutorials/gitfs.html#simple-configuration
I'm not getting the errors you're seeing. Can you try using the salt-formula repo to see if you get the same errors?
I take a random formulas => jenkins
With the following settings it works:
file_client: local
fileserver_backend:
- roots
- git
top_file_merging_strategy: same
gitfs_provider: pygit2
gitfs_remotes:
- https://github.com/saltstack-formulas/jenkins-formula.git
PS C:\WINDOWS\system32> C:\salt\bin\python.exe C:\salt\bin\Scripts\salt-call state.sls_exists jenkins/nginx
[ERROR ] Exception caught while fetching gitfs remote 'https://github.com/saltstack-formulas/jenkins-formula.git': environment can only contain strings
Traceback (most recent call last):
File "C:\salt\bin\lib\site-packages\salt\utils\gitfs.py", line 2348, in fetch_remotes
if repo.fetch():
File "C:\salt\bin\lib\site-packages\salt\utils\gitfs.py", line 767, in fetch
return self._fetch()
File "C:\salt\bin\lib\site-packages\salt\utils\gitfs.py", line 1767, in _fetch
cleaned = self.clean_stale_refs(local_refs=refs_post)
File "C:\salt\bin\lib\site-packages\salt\utils\gitfs.py", line 1623, in clean_stale_refs
return super(Pygit2, self).clean_stale_refs()
File "C:\salt\bin\lib\site-packages\salt\utils\gitfs.py", line 602, in clean_stale_refs
stderr=subprocess.STDOUT)
File "C:\salt\bin\lib\subprocess.py", line 676, in __init__
restore_signals, start_new_session)
File "C:\salt\bin\lib\subprocess.py", line 957, in _execute_child
startupinfo)
TypeError: environment can only contain strings
local:
True
And with these settings it doesn't work:
file_client: local
fileserver_backend:
- roots
- git
top_file_merging_strategy: same
gitfs_provider: pygit2
gitfs_remotes:
- https://github.com/saltstack-formulas/jenkins-formula.git:
- root: jenkins
- mountpoint: salt://
PS C:\WINDOWS\system32> C:\salt\bin\python.exe C:\salt\bin\Scripts\salt-call state.sls_exists nginx
[ERROR ] Exception caught while fetching gitfs remote 'https://github.com/saltstack-formulas/jenkins-formula.git': environment can only contain strings
Traceback (most recent call last):
File "C:\salt\bin\lib\site-packages\salt\utils\gitfs.py", line 2350, in fetch_remotes
if repo.fetch():
File "C:\salt\bin\lib\site-packages\salt\utils\gitfs.py", line 767, in fetch
return self._fetch()
File "C:\salt\bin\lib\site-packages\salt\utils\gitfs.py", line 1767, in _fetch
cleaned = self.clean_stale_refs(local_refs=refs_post)
File "C:\salt\bin\lib\site-packages\salt\utils\gitfs.py", line 1623, in clean_stale_refs
return super(Pygit2, self).clean_stale_refs()
File "C:\salt\bin\lib\site-packages\salt\utils\gitfs.py", line 602, in clean_stale_refs
stderr=subprocess.STDOUT)
File "C:\salt\bin\lib\subprocess.py", line 676, in __init__
restore_signals, start_new_session)
File "C:\salt\bin\lib\subprocess.py", line 957, in _execute_child
startupinfo)
TypeError: environment can only contain strings
local:
False
The following code that I add (explain in 1st send):
pprint(repo.file_list('base'))
return with the 1st config:
({'.gitignore',
'.travis.yml',
'Gemfile',
'LICENSE',
'README.rst',
'jenkins/cli.sls',
'jenkins/defaults.yaml',
'jenkins/files/Debian/jenkins.conf',
'jenkins/files/RedHat/jenkins.conf',
'jenkins/files/nginx.conf',
'jenkins/init.sls',
'jenkins/jobs.sls',
'jenkins/macros.jinja',
'jenkins/map.jinja',
'jenkins/nginx.sls',
'jenkins/osmap.yaml',
'jenkins/plugins.sls',
'kitchen.yml',
'pillar.example',
'test/integration/default/jenkins_spec.rb',
'test/pillar/example.sls',
'test/pillar/nginx.sls',
'test/pillar/top.sls'},
{'test/pillar/example.sls': b'../../pillar.example'})
And with the 2nd:
({'cli.sls',
'defaults.yaml',
'files\\Debian\\jenkins.conf',
'files\\RedHat\\jenkins.conf',
'files\\nginx.conf',
'init.sls',
'jobs.sls',
'macros.jinja',
'map.jinja',
'nginx.sls',
'osmap.yaml',
'plugins.sls'},
{})
working minion config:
file_client: local
fileserver_backend:
- roots
- git
gitfs_provider: gitpython
gitfs_base: master
gitfs_remotes:
- https://github.com/saltstack-formulas/jenkins-formula.git
Results
C:\dev\salt>salt-call cp.list_master
local:
- .gitignore
- .travis.yml
- Gemfile
- LICENSE
- README.rst
- jenkins/cli.sls
- jenkins/defaults.yaml
- jenkins/files/Debian/jenkins.conf
- jenkins/files/RedHat/jenkins.conf
- jenkins/files/nginx.conf
- jenkins/init.sls
- jenkins/jobs.sls
- jenkins/macros.jinja
- jenkins/map.jinja
- jenkins/nginx.sls
- jenkins/osmap.yaml
- jenkins/plugins.sls
- kitchen.yml
- pillar.example
- test/integration/default/jenkins_spec.rb
- test/pillar/example.sls
- test/pillar/nginx.sls
- test/pillar/top.sls
C:\dev\salt>salt-call state.sls_exists jenkins/nginx
local:
True
Adding root and mountpoint in the minion config like so:
file_client: local
fileserver_backend:
- roots
- git
gitfs_provider: gitpython
gitfs_base: master
gitfs_remotes:
- https://github.com/saltstack-formulas/jenkins-formula.git:
- root: jenkins
- mountpoint: salt://formulas
Results:
C:\dev\salt>salt-call cp.list_master
local:
- formulas/cli.sls
- formulas/defaults.yaml
- formulas/files\Debian\jenkins.conf
- formulas/files\RedHat\jenkins.conf
- formulas/files\nginx.conf
- formulas/init.sls
- formulas/jobs.sls
- formulas/macros.jinja
- formulas/map.jinja
- formulas/nginx.sls
- formulas/osmap.yaml
- formulas/plugins.sls
C:\dev\salt>salt-call state.sls_exists formulas/nginx
local:
False
C:\dev\salt>salt-call state.sls_exists formulas\\nginx
local:
False
C:\dev\salt>salt-call state.sls_exists formulas\nginx
local:
False
C:\dev\salt>salt-call state.sls_exists "formulas\nginx"
local:
False
C:\dev\salt>salt-call state.sls_exists "formulas\\nginx"
local:
False
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.
Thank you for updating this issue. It is no longer marked as stale.
Hi, just to mention this is still an issue on recent versions.
@twangboy any thoughts on this one ?
Worth to mention that the minion (running as a service already) looks like it does not seem to be trying to fetch files till you execute some command like the one below
PS C:\ProgramData\Salt Project\Salt\var\cache\salt\minion> salt-call cp.list_master
[INFO ] Wrote new gitfs remote map to C:\ProgramData\Salt Project\Salt\var\cache\salt\minion\gitfs\remote_map.txt
Till then the minion cache folder does not have a gitfs folder present.
Description of Issue
I arrive to connect remotly on my git repo with the backend gitfs. But when I try to change root, it seems doesn't work (Windows).
I edit file C:\salt\bin\Lib\site-packages\salt\utils\gitfs.py and I add on line 2348 (version 2019.2) the following code:
And I have the following output without root:
And with root:
First has a slash and the second has a backslash. I think that's why I have the issue.
Setup
Note I have the same issue with pygit2 and gitpython. My custom config:
Steps to Reproduce Issue
Without options root and mountpoint activated return True:
With options root and mountpoint activated return False:
Also note and I don't know why (I haven't debug) that repo.fetch return an error !
Versions Report
The main issue is the root and mountpoint options and the minor is the traceback TypeError: environment can only contain strings