-
Notifications
You must be signed in to change notification settings - Fork 352
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
Purge should purge directories too, not just files #1222
Conversation
@@ -104,7 +104,7 @@ | |||
/\/unmanaged_1/, /\/unmanaged_2/, | |||
/\/managed_subdir_1/, | |||
/\/subdir_expected_1/, /\/subdir_unmanaged_1/, | |||
/\/managed_subdir_2/, /\/ignored_1/, | |||
/\/subdir_allowlisted_2/, /\/ignored_1/, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason you called this dir allowlisted
? I don't actually see you adding it to an allowlist/whitelist anywhere in here, but maybe I'm missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think...check out lines 210-212 down below. I took the opportunity to rename the dir because it isn't/wasn't a managed directory, per se, anywhere in the test that I could tell. Rather, it was being added to the let(:whitelist)
(new term: allowlist) in the "recursive whitelist glob" test.
Since "managed_subdir_2" didn't seem to make any sense in the context of the test, I renamed it based on the one place I could find where it seemed to be doing something meaningful.
Going to play around with this a bit, but on the surface I think it looks good. |
Having a hard time reproducing this... what was your workflow when you saw it? And how were your purge levels configured? |
Looking into a repro. Saw some unexpected behavior on my first try, so digging a little deeper to figure out what else might be going on here. |
Let's put this on hold. I repro'd this on the #1159 branch, but this and other weird purge behaviors seemed to disappear when I rebased that to the current main. Will continue to investigate, and close this PR if the issue no longer reproduces. |
Figured it out. It's kind of a weird one, and seems to intersect with the Puppetfile. Opens a small question: in the event a module is removed from management (either in the Puppetfile OR in an environment source definition), should a deploy without Unrealistic reproduction:
Realistic reproduction requirements:
Interestingly, and opening the question about if |
It looks like the reason stuff isn't purged from Given that context, I think this PR constitutes a valid bug, with the directory-bomb as the reproduction, and consideration of how to handle |
I think I would be inclined to have deleted modules not be purged when It sounds like you still think this PR is valid, even without further uptake of the |
Yeah, I think this PR is valid, even without further update kof |
Is the expected behavior you want for Fwiw I verified that that is the behavior for control-repo-based environments: no |
Yeah. Idealized:
Possible complication:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to merge this after a rebase.
Previously, purge! would never remove directories. This awkwardly left behind large file-less directory trees, when e.g. a module was removed, or a directory stopped being managed in an environment. For the latter use case, this was probably hidden somewhat by Git doing empty directory cleanup on checkout. That won't always be guaranteed to happen, when not using Git sources.
79616da
to
29daf91
Compare
29daf91
to
5ae510a
Compare
Rebased, and CHANGELOG message updated a bit to better reflect what this does. It's not really about modules, turns out; it's more about purge being blind to unmanaged directories. Though, ya know... makes me wonder how module directories are getting removed when Edit: maybe it's something about the difference between |
I think it might be this: r10k/lib/r10k/environment/base.rb Lines 162 to 165 in e2aa4dc
--modules is passed, and that's what does the cleaning.
|
Previously,
R10K::Util::Purgeable#purge!
would never remove directories. This awkwardly left behind large file-less directory trees, when e.g. a module was removed, or a directory stopped being managed in an environment.For the latter use case, this was probably hidden somewhat by Git doing empty directory cleanup on checkout. That won't always be guaranteed to happen, when not using Git sources.