(PUP-3088) Fix zone provider debug call#4000
Conversation
|
Can you update the commit message with the PUP ticket? |
|
CLA signed by all contributors. |
|
It looks like there are other calls to |
lib/puppet/provider/zone/solaris.rb
Outdated
There was a problem hiding this comment.
The real root cause is that puppet assumes if the resource responds to path then it must respond to tags, file, etc. When that issue is fixed, then this change will cause us to lose context information about the resource that failed, e.g.
Error: /Stage[main]/Main/Zone[test_zone]: Ignoring ...
How about we fix the root cause instead, so we don't lose the context and ensure we work with custom providers that also have a path, e.g. registry_key. Something like?
diff --git a/lib/puppet/util/log.rb b/lib/puppet/util/log.rb
index 08a90b1..8909ab3 100644
--- a/lib/puppet/util/log.rb
+++ b/lib/puppet/util/log.rb
@@ -338,9 +338,9 @@ class Puppet::Util::Log
def source=(source)
if source.respond_to?(:path)
@source = source.path
- source.tags.each { |t| tag(t) }
- self.file = source.file
- self.line = source.line
+ source.tags.each { |t| tag(t) } if source.respond_to?(:tags)
+ self.file = source.file if source.respond_to?(:file)
+ self.line = source.line if source.respond_to?(:line)
else
@source = source.to_s
end
cc'ing @hlindberg and @thallgren who were the last to work on logging messages.
There was a problem hiding this comment.
Well, we can't even be sure that the path/tags/file/line methods for providers are the RIGHT methods to call. A developer can make a custom provider with any one of those methods and end up getting unexpected calls, right? It seems like some sort of manifest source callback would be needed that can be referenced instead of the provider methods directly.
|
ping @joshcooper what's the state of this? |
|
I'll follow up on this while @joshcooper's out. @hunner any updates on Josh's comments? |
|
@MikaelSmith Updating the PR now... |
|
I'm not sure I see the reason in the ticket why this uses the With the special handling you've added for provider we get I'd lean towards not changing the behavior for all providers. |
|
Lost comments from Josh on hunner@afdbb23 @MikaelSmith I think you're referring to calling I can rename the default |
|
No, I mean that for most providers |
|
👍 |
spec/unit/util/log_spec.rb
Outdated
There was a problem hiding this comment.
Spec test fails because these aren't invoked.
The util log library should use the type's path/file/tags when available, but any other object's logging messages do not need this kind of information.
There was a problem hiding this comment.
When would defined?(Puppet::Type) not be true?
There was a problem hiding this comment.
That is from the is_resource? method of Puppet::Util::Logging at https://github.com/puppetlabs/puppet/blob/3.8.1/lib/puppet/util/logging.rb#L197-L199 , but this log util may not be used before require 'puppet/type' though the Puppet::Util::Logging one may, but I included it to be safe.
(PUP-3088) Fix zone provider debug call
The provider should directly call
Puppet.debugandPuppet.errbecause of the issue described in the PUP ticket.