Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
(PUP-3399) autorequire local file sources #8909
base: 7.x
Are you sure you want to change the base?
(PUP-3399) autorequire local file sources #8909
Changes from all commits
6198a9a
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
it seems on Windows, the
file://
prefix is not automatically added and thus this inclusion fails.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.
Or rather, it is, but the path being set as
file:///D:/bar
(note the tree slashes), which is obviously not a valid local windows path pointing atD:/bar
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.
5fea1dc
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.
If
source
is an absolute path, then it will have been normalized inpuppet/lib/puppet/type/file/source.rb
Lines 111 to 118 in 7f41466
Since the source has been normalized, I think you can simply do:
And it will work correctly on all platforms (including Windows).
Is there a particular scenario where this comes up frequently? Or just something that would be good to fix?
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.
"this" being Windows or autorequires for the source attribute?
If the latter: we had it come up in one of our (the foreman) modules and I thought it'd be nice to have. Certainly not everyday material.
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.
yeah the latter, wondering when you'd need to autorequire local sources.
I'm always hesitant to modify the
file
type/provider given the amount of complexity there. For example, are there cases where a file isensure => absent
but has asource
? Puppet doesn't automatically reverse the dependency order so we run into things like #9114 (comment)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 opened this because of this hack we have over in
theforeman/foreman_proxy
:https://github.com/theforeman/puppet-foreman_proxy/blob/69c038e607d9fd9558436b2afad312949ef530d7/manifests/plugin/remote_execution/mosquitto.pp#L99-L103
The TL;DR version is:
We have a different deployment modes:
certs
) that deploys the certs to a specific place on the systemIn either case, the certs need to land in a place where mosquitto can read them (selinux, perms, etc), so we need to copy them from one place to another.
Local source seems like the correct way here, but it needs an explicit require, IF the thing is managed by puppet (it might not be).
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 a source shouldn't apply if something is ensured absent, but you raise a good point.
At first glance, the whole autorequire looks like it's not well designed for ensuring absent. The target relation is not needed either (but probably doesn't hurt in practice). You'd think Finding all ancestors up to the root however is not needed at all and could even introduce problems. Assuming
mkdir -p /path/sub
:Yields:
Ok, misleading. So we modify it to:
Upon further inspection, this tries to remove the top most directory first. That's actually good. It doesn't list all sub-resources and is probably more efficient. If it then needs to ensure a file within the directory it is actually idempotent: it'll fail because the parent doesn't exist, instead of creating the file and then removing the parent which would cause it fail on the next run.