Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] file.directory ignores test=true and removes symlink #66049

Closed
1 task done
groucho86 opened this issue Feb 12, 2024 · 5 comments
Closed
1 task done

[BUG] file.directory ignores test=true and removes symlink #66049

groucho86 opened this issue Feb 12, 2024 · 5 comments
Assignees
Labels
Bug broken, incorrect, or confusing behavior needs-triage

Comments

@groucho86
Copy link

Description
Despite test=true, file.directory state is deleting a symlink

Setup

dir_check:
  file.directory:
    - name: /tmp/dest_folder
    - allow_symlink: False
    - force: True

Please be as specific as possible and give set-up details.

  • on-prem machine
mkdir /tmp/source_folder
ln -s /tmp/source_folder /tmp/dest_folder

Steps to Reproduce the behavior

Running the state via CLI equivalent:
sudo salt-call state.single file.directory name="/tmp/dest_folder" allow_symlink=False force=True test=true
returns

----------
          ID: /tmp/dest_folder
    Function: file.directory
      Result: True
     Comment: The directory /tmp/dest_folder is in the correct state
     Started: 16:47:12.778895
    Duration: 6.571 ms
     Changes:   
              ----------
              forced:
                  Symlink would be forcibly replaced

Summary for local
------------

But running the above state.apply test=true returns

----------
          ID: luts_local_dir_check
    Function: file.directory
        Name: /tmp/dest_folder
      Result: None
     Comment: The following files will be changed:
              /tmp/dest_folder: directory - new
     Started: 16:46:40.176155
    Duration: 1.033 ms
     Changes:   
              ----------
              /tmp/dest_folder:
                  ----------
                  directory:
                      new
----------

Expected behavior
I expect the state.apply test=true not to modify the minion's filesystem.

Versions Report

salt --versions-report (Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
salt --versions-report
Salt Version:
          Salt: 3006.1
 
Python Version:
        Python: 3.10.11 (main, May  5 2023, 02:31:54) [GCC 11.2.0]
 
Dependency Versions:
          cffi: 1.14.6
      cherrypy: unknown
      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: 5.4.1
         PyZMQ: 23.2.0
        relenv: 0.12.3
         smmap: Not Installed
       timelib: 0.2.4
       Tornado: 4.5.3
           ZMQ: 4.3.4
 
System Versions:
          dist: rocky 8.4 Green Obsidian
        locale: utf-8
       machine: x86_64
       release: 4.18.0-305.3.1.el8_4.x86_64
        system: Linux
       version: Rocky Linux 8.4 Green Obsidian
@groucho86 groucho86 added Bug broken, incorrect, or confusing behavior needs-triage labels Feb 12, 2024
Copy link

welcome bot commented Feb 12, 2024

Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey.
Please be sure to review our Code of Conduct. Also, check out some of our community resources including:

There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar.
If you have additional questions, email us at [email protected]. We’re glad you’ve joined our community and look forward to doing awesome things with you!

@terminalmage
Copy link
Contributor

I'm not able to reproduce, neither on 3006.1 nor the head of the 3006.x branch.

@groucho86
Copy link
Author

Apologies @terminalmage , looks like it only happens when "backupname" is present:

mkdir /tmp/source_folder
ln -s /tmp/source_folder /tmp/dest_folder
dir_check:
  file.directory:
    - name: /tmp/dest_folder
    - allow_symlink: False
    - force: True
    - backupname: /tmp/saved

sudo salt-call --local state.sls dir_check test=True

@terminalmage
Copy link
Contributor

@groucho86 That helps! I have found the bug. I will have a PR open in the next day or two.

@terminalmage
Copy link
Contributor

@groucho86 see #66120.

@Akm0d Akm0d self-assigned this May 8, 2024
@Akm0d Akm0d closed this as completed Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior needs-triage
Projects
None yet
Development

No branches or pull requests

3 participants