[BUG] file.symlink does not delete link path with force: true anymore
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
Description
Creating a symlink over an existing directory with file.symlink and force: True worked fine for years before. But since Salt 3006, it does not.
Steps to Reproduce the behavior
- Create a Salt State to create a symlink in place of an existing directory, e.g.
/var/cache/tomcat/temp:
file.symlink:
- target: /opt/temp
- force: True
- watch_in:
- service: tomcat
- require:
- pkg: tomcat
Expected behavior
Salt should first remove the file/directory/etc. (here: /var/cache/tomcat/temp), then replace it with the symlink, as stated in the documentation.
Screenshots
----------
ID: /var/cache/tomcat/temp
Function: file.symlink
Result: False
Comment: Unable to create new symlink /var/cache/tomcat/temp -> /opt/temp: [Errno 21] Is a directory: '/var/cache/tomcat/temp'
Started: 09:52:29.518867
Duration: 1.868 ms
Changes:
Versions Report
salt --versions-report
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)# salt-minion --versions-report
Salt Version:
Salt: 3006.4
Python Version:
Python: 3.10.13 (main, Oct 4 2023, 21:54:22) [GCC 11.2.0]
Dependency Versions:
cffi: 1.14.6
cherrypy: 18.6.1
dateutil: 2.8.1
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
Jinja2: 3.1.2
libgit2: Not Installed
looseversion: 1.0.2
M2Crypto: Not Installed
Mako: Not Installed
msgpack: 1.0.2
msgpack-pure: Not Installed
mysql-python: Not Installed
packaging: 22.0
pycparser: 2.21
pycrypto: Not Installed
pycryptodome: 3.9.8
pygit2: Not Installed
python-gnupg: 0.4.8
PyYAML: 6.0.1
PyZMQ: 23.2.0
relenv: 0.13.12
smmap: Not Installed
timelib: 0.2.4
Tornado: 4.5.3
ZMQ: 4.3.4
System Versions:
dist: centos 7.9.2009 Core
locale: utf-8
machine: x86_64
release: 3.10.0-1160.76.1.el7.x86_64
system: Linux
version: CentOS Linux 7.9.2009 Core```
</details>
**Additional context**
#64726 had possibly the same or similar issue, but OP closed it for another reason.
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 with Salt's file.symlink state described in the reproduction and reproduce the failure using an existing directory with force: True. Done means the existing path is removed and replaced by the requested symlink, with regression coverage for this behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devops, infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100