-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
file.directory clean does not work as expected #26605
Comments
@ryanwalder, thanks for the report. |
I suspect this is related to https://groups.google.com/forum/#!topic/salt-users/x-3zCIA_s4w which was at the time linked to two other bugs, both now closed but in ways that clearly didn't affect this issue. @ryanwalder can you check if your tests work if you use what is currently the -name onto the id line? |
Ok, so it's partially resolved. It now works as expected with you manage a file directly (adds file, does not delete)
However it does not work as expected if salt creates the file (pkgrepo.managed adds the file, file.directory clean removes the file)
Version info:
|
Workaround saltstack/salt#26605 by cleaning the sources.list.d folder first, and running pkgrepo states that add repositories to the folder afterwards using require. This unbreaks servo#232: Travis has the Chrome apt repo configured, but Google has dropped 32-bit support (March 2016), causing apt to fail on multiarch hosts. By removing all external repos we will only use repositories we configure ourselves.
Remove non-Salted external apt sources Workaround saltstack/salt#26605 by cleaning the sources.list.d folder first, and running pkgrepo states that add repositories to the folder afterwards using require. This unbreaks #232: Travis has the Chrome apt repo configured, but Google has dropped 32-bit support (March 2016), causing apt to fail on multiarch hosts. By removing all external repos we will only use repositories we configure ourselves. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/saltfs/234) <!-- Reviewable:end -->
_gen_keep_files() isn't checking lowstates for any entries that require the file.directory being created.
|
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. |
This is still an issue. |
Thank you for updating this issue. It is no longer marked as stale. |
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. |
This is still an issue |
Thank you for updating this issue. It is no longer marked as stale. |
(running salt 3000) We too have seen this issue, it gets even weirder when one uses keyword arguments for requisites (which we do). Will not clean files:
Cleans files:
One of our many workarounds is to create the directory using cmd.run and then manage the "clean: True" using file.directory. |
We will see if the core team can get to this in Aluminium, but cannot commit due to time and resource constraints. If anyone in the community would like to open an PR we will definitely review it and see if we can merge it sooner rather than later. :) |
I am not convinced there is a workaround here so I am changing the severity up one level until determined otherwise. We will take a look at this in next couple of weeks. |
@sagetherage I think we should downgrade the severity here, unless someone can show otherwise it looks like the I just tried with this:
This will not remove the expected file. It will remove other files from the directory. (There are some other wonky things happening with file.directory when not using exclude_pat, but.... seems like we do have a reasonable workaround here) |
@waynew, sorry, but I fail to see how can Usually, a formula managing an application and providing a repository for it, will add a file under the So say that I have, originally, this situation:
Then, I add 2 formulas, with repos, which add these entries
And I add the resource clean_dir:
file.directory:
- name: /etc/apt/sources.list.d/
- clean: True The expected behavior is that salt would remove the The bug describes that salt will delete ALL the entries and re-create the With the And unless I'm not understanding it correctly, the workaround you propose means that each time a new formula or piece of repo-managing code is added to a node, the Am I missing something? If not, imho, the severity should stand the same, right? |
That's exactly the workaround, adding the managed files to the If this didn't work (say, On a different part of this topic, I haven't looked at the underlying code here, but it feels like either we're missing a useful API to pass around file(names) in requisites, or some other way to communicate what files should be under Salt's management. That would allow
That would be handy to have not only for this state, but I'm sure others could also benefit. |
for now I worked around it like so: /etc/ssh/authorized_keys:
file.directory:
- clean: true
# "exclude_list" is a list of files to be excluded from being removed by the
# "clean" operation. Salt would otherwise keep removing and adding the files everytime.
# The `or ""` makes sure the output of the list append isn't None for each key.
{% set exclude_list = [] %}
{% for user in salt['pillar.get']('ssh:authorized_keys', {}) %}
{{ exclude_list.append(user + ".pub") or "" }}
{% endfor %}
- exclude_pat: {{ exclude_list }} |
After further experimentation and really digging into this, it appears that the existing behavior is basically correct. That is to say, this was always (apparently) only intended to ignore files that were managed by a For the original issue, the expected spelling is:
(create/replace: False aren't strictly necessary, but they do help avoid warnings) It would be neat if all states/modules could specify the files that they're managing, but without some potentially pretty impressive changes that isn't possible. Instead, this particular functionality simply depends on the required state being a I've opened a PR to make all of this very explicit in the documentation as well as provide some examples. Since the bug that used to be there was resolved as mentioned earlier up this comment chain, and this isn't really a bug in the code, and I've got the PR open, I'm going to go ahead and close this issue. |
One mechanism that Salt has had since 3001 is the global |
So I want Salt to clear out the
/etc/apt/sources.list.d
folder of any sources.list files it doesn't manage.First attempt:
Nope:
Ok, maybe it can only exclude something if it's a file:
Nope.
The docs are a little sparse:
Which to me reads that if something is required the end file it produces (if in that directory) won't get removed, which doesn't appear to be the case.
I also gave
exclude_pat
a go with no joy:Also tried
(myrepo|ubuntu)
&(myrepo|ubuntu)\.list
with no joy.Tested on salt versions v2015.5.0 to v2015-5-5 and 2015.8 (all from git using the bootstrap), running on Ubuntu 14.04.
The text was updated successfully, but these errors were encountered: