堆栈跟踪将整个类对象转储在自定义资源中
从厨师12升级为17.10.3进行了升级。我正在使用Chef-Solo
,现在已将其更改为Chef-client -z
。自定义资源中有错误时,我会得到整个类转储,而不是之前的类名。
有什么想法吗?我仍然想要更有用的堆栈跟踪信息,而不是这个完整的转储。它使该文件庞大,并且并不是一条巨大的文本行为。 似乎仅与自定义资源隔离(到目前为止)。
这是我的命令:sudo chef -client -z -c/opt/chefsolo/solo/solo.rb- -j/opt/chefsolo/node.json -l warn
。
这是solo.rb的内容:
repo_dir = "/opt/chefsolo"
chef_repo_path repo_dir.to_s
file_cache_path repo_dir.to_s
cookbook_path "#{repo_dir}/cookbooks"
role_path "#{repo_dir}/roles"
data_bag_path "#{repo_dir}/data_bags"
environment_path "#{repo_dir}/environments"
我的/opt/chefsolo/node.json
文件只有一个run_list定义。
更新
这是食谱:
ruby_block "get user list" do
block do
node.default["authorization"]["add"]["users"] = %w[user1 user2]
end
end
brazen_users_users "Create and config users" do
user_list(lazy { node["authorization"]["add"]["users"] })
end
这是资源:
property :user_list, Array, required: true
action :run do
user_list.each do |user|
puts user
end
end
要清楚,我知道资源中的user_list
需要为new_resource.user_list
(< a href =“ https://docs.chef.io/custom_resources/#example-resource” rel =“ nofollow noreferrer”> https://docs.chef.io/custom/custom_resources/#example-resource-resource-resource )。
我的问题不是“为什么这个资源不起作用?”我的问题是:“为什么失败时会打印整个课程信息?”
Did an upgrade from Chef 12 to Chef 17.10.3. I was using chef-solo
and have now changed this to chef-client -z
. When there's an error in a custom resource I get the whole class dump instead of the class name previously.
Any ideas? I still want the more helpful stack trace info, just not this full dump. It makes the file huge and is not particularly helpful as one huge line of text. Seems to be isolated only to custom resources (so far).
Here's my command: sudo chef-client -z -c /opt/chefsolo/solo.rb --environment ENV -N HOSTNAME -j /opt/chefsolo/node.json -l warn
.
And here's the contents of solo.rb:
repo_dir = "/opt/chefsolo"
chef_repo_path repo_dir.to_s
file_cache_path repo_dir.to_s
cookbook_path "#{repo_dir}/cookbooks"
role_path "#{repo_dir}/roles"
data_bag_path "#{repo_dir}/data_bags"
environment_path "#{repo_dir}/environments"
My /opt/chefsolo/node.json
file only has a run_list defined.
Updated
Here's the recipe:
ruby_block "get user list" do
block do
node.default["authorization"]["add"]["users"] = %w[user1 user2]
end
end
brazen_users_users "Create and config users" do
user_list(lazy { node["authorization"]["add"]["users"] })
end
And here's the resource:
property :user_list, Array, required: true
action :run do
user_list.each do |user|
puts user
end
end
To be clear, I know that user_list
in the resource needs to be new_resource.user_list
(https://docs.chef.io/custom_resources/#example-resource).
My question is not "why is this resource not working?" My question is "why when this fails does it print the whole class information ?"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论