-
Notifications
You must be signed in to change notification settings - Fork 457
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
(1093) - Fix unresolved fact error #1094
Conversation
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.
LGTM
63f11de
to
a99bb3f
Compare
|
Wouldn't it be better to confine the evaluation of facts to those nodes having the required commands installed? IMO, nodes haven't installed |
14fc6bf
to
74270c3
Compare
There is no support for such a confine as far as I know. The alternative is to run some kind of |
|
You can confine a fact to a command or there is a confine block also available. I do such facts like, e.g. In the case the command fails or cannot be executed, the confine block returns false and the fact won't be reported at all, while there isn't even a warning on the agent. |
e8e6dc2
to
87e5827
Compare
Thanks for the suggestion @rtib, when implementing a confine statement such as this introduces spec test failures on nodes that do not have the package installed. |
You need to mock the allow(Facter::Core::Execution).to receive(:which).with('iptables')
.and_return('/usr/sbin/iptables')This worked in my rspec environment without iptables installed. |
|
I assume you mean spec checks like spec/unit/facter/iptables_persistent_version_spec.rb#L34. That's because, these checks assume the fact being reported contain a IMO, this would be the desired behaviour. Imagine an environment running a large number of nodes, but only a few need firewall. There is no need to report facts with value nil from nodes which doesn't configure a firewall. This could also reduce the utilisation of PuppetDB. It is not a big difference within the DSL if a fact doesn't exists or exists but its value is unset, since for those nodes the firewall module is not included in their manifest. |
7d2bedc
to
7f1b30a
Compare
7f1b30a
to
6f5368c
Compare
8b27323
to
3fe4e97
Compare
Prior to this commit, work was carried out on this module to update all instances of the now deprecated Facter::Util::Resolution, and replace all with its newer and supported counterpart Facter::Core::Execution. However, these do not behave exactly the same. Facter::Util::Resolution initially ran a which to locate the binary before executing, preventing any errors from occuring. The newer Facter::Core::Execution method did not do this, instead it attempted to execut> This commit aims to introduce an "on_fail:false" flag to each execute statement, so that a failed execute will return false (boolean) as oppose to an error, which can then be used for further logic.
3fe4e97
to
14c1371
Compare
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.
LGTM, GJ
|
Excellent collaboration here to address the issue quickly and professionally, thanks all! |
Fix for #1093
Prior to this PR, work was carried out on this module to update all instances of the now deprecated Facter::Util::Resolution, and replace all with its newer and supported counterpart Facter::Core::Execution.
However, these do not behave exactly the same.
Facter::Util::Resolution initially ran a which to locate the binary before executing, preventing any errors from occuring. The newer Facter::Core::Execution method did not do this, instead it attempted to execute.
This commit aims to introduce an "on_fail:false" flag to each execute statement, so that a failed execute will return false (boolean) and not generate an error.