salt.states.git.cloned can't clone into an existing directory
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
Description of Issue
Attempting to use git.cloned where "target" directory already exists results in an error:
Comment: Command 'git status -z --porcelain' failed: fatal: not a git repository (or any of the parent directories): .git
Setup
(Please provide relevant configs and/or SLS files (Be sure to remove sensitive info).)
I'm bootstrapping my salt master. Largely untouched Debian buster running latest salt. Applied using
# salt-call --local --file-root=$top/salt --pillar-root=$top/pillar --id=$(hostname -f) state.highstate $@
Steps to Reproduce Issue
(Include debug logs if possible and relevant.)
I want to set up a git clone in /srv/salt-master. /srv is root:root 0755. /srv/salt-master is salt:salt 0750. As user "salt" is unable to create a directory in /srv, I use a salt state to create /srv/salt-master:
/srv/salt-master/:
file.directory:
- user: salt
- group: salt
- mode: 0750
and then attempt to clone into it with
clone-bare-repo:
git.cloned:
- name: /srv/git/salt-yhhyt.git/
- target: /srv/salt-master/
- user: salt
Result is
ID: clone-bare-repo
Function: git.cloned
Name: /srv/git/salt-yhhyt.git/
Result: False
Comment: Command 'git status -z --porcelain' failed: fatal: not a git repository (or any of the parent directories): .git
Started: 22:32:19.815419
Duration: 118.882 ms
Changes:
An alternative attempt replacing git.cloned with this cmd.run is sucessful:
clone-bare-repo:
cmd.run:
- name: git clone /srv/git/salt-yhhyt /srv/salt-master/
- creates: /srv/salt-master/.git/
- runas: salt
Versions Report
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
root@havelock:~/git/salt-yhhyt# salt --versions-report
Salt Version:
Salt: 2019.2.3
Dependency Versions:
cffi: Not Installed
cherrypy: Not Installed
dateutil: 2.7.3
docker-py: Not Installed
gitdb: 2.0.5
gitpython: 2.1.11
ioflo: Not Installed
Jinja2: 2.10
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: Not Installed
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.5.6
mysql-python: Not Installed
pycparser: Not Installed
pycrypto: 2.6.1
pycryptodome: Not Installed
pygit2: Not Installed
Python: 3.7.3 (default, Apr 3 2019, 05:39:12)
python-gnupg: Not Installed
PyYAML: 3.13
PyZMQ: 17.1.2
RAET: Not Installed
smmap: 2.0.5
timelib: Not Installed
Tornado: 4.5.3
ZMQ: 4.3.1
System Versions:
dist: debian 10.2
locale: ISO-8859-1
machine: x86_64
release: 4.19.0-6-cloud-amd64
system: Linux
version: debian 10.2
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the salt.states.git.cloned entry point and reproduce the reported failure with an existing /srv/salt-master directory, comparing it with the successful cmd.run git clone. Trace the git status -z --porcelain check and verify the behavior when the target directory exists but is not yet a repository; done means the supplied state can clone successfully into that directory without the reported error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git, python
- Domain
- devops, infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100