summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2020-03-11 19:12:34 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2020-03-11 19:12:34 -0700
commit34a1d7eec7206029c663d56097ba738a63608c31 (patch)
treea9d56b7a31a9a14688fc5d3e5d169b9caec8fdc8 /lib
parentdfd018cb04a2eae78e5cd8f7569dff4919e3769a (diff)
downloadchef-34a1d7eec7206029c663d56097ba738a63608c31.tar.gz
fix ruby 2.7 encoding bug and add --always-dump-stacktrace option
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/chef/application.rb8
-rw-r--r--lib/chef/application/apply.rb6
-rw-r--r--lib/chef/application/base.rb8
-rw-r--r--lib/chef/provider/file.rb4
4 files changed, 21 insertions, 5 deletions
diff --git a/lib/chef/application.rb b/lib/chef/application.rb
index 197ae20c6d..02d4a4bacb 100644
--- a/lib/chef/application.rb
+++ b/lib/chef/application.rb
@@ -1,7 +1,7 @@
#
# Author:: AJ Christensen (<aj@chef.io>)
# Author:: Mark Mzyk (mmzyk@chef.io)
-# Copyright:: Copyright 2008-2019, Chef Software Inc.
+# Copyright:: Copyright 2008-2020, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -392,7 +392,11 @@ class Chef
Chef::FileCache.store("#{Chef::Dist::SHORT}-stacktrace.out", chef_stacktrace_out)
logger.fatal("Stacktrace dumped to #{Chef::FileCache.load("#{Chef::Dist::SHORT}-stacktrace.out", false)}")
logger.fatal("Please provide the contents of the stacktrace.out file if you file a bug report")
- logger.debug(message)
+ if Chef::Config[:always_dump_stacktrace]
+ logger.fatal(message)
+ else
+ logger.debug(message)
+ end
true
end
diff --git a/lib/chef/application/apply.rb b/lib/chef/application/apply.rb
index 35aefc949d..4718e8750b 100644
--- a/lib/chef/application/apply.rb
+++ b/lib/chef/application/apply.rb
@@ -76,6 +76,12 @@ class Chef::Application::Apply < Chef::Application
description: "Set the log level (trace, debug, info, warn, error, fatal).",
proc: lambda { |l| l.to_sym }
+ option :always_dump_stacktrace,
+ long: "--[no-]always-dump-stacktrace",
+ boolean: true,
+ default: false,
+ description: "Always dump the stacktrace regardless of the log_level setting."
+
option :help,
short: "-h",
long: "--help",
diff --git a/lib/chef/application/base.rb b/lib/chef/application/base.rb
index c5bff9874e..bdc6055c31 100644
--- a/lib/chef/application/base.rb
+++ b/lib/chef/application/base.rb
@@ -1,5 +1,5 @@
#
-# Copyright:: Copyright 2008-2019, Chef Software Inc.
+# Copyright:: Copyright 2008-2020, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -100,6 +100,12 @@ class Chef::Application::Base < Chef::Application
description: "Set the log file location, defaults to STDOUT - recommended for daemonizing.",
proc: nil
+ option :always_dump_stacktrace,
+ long: "--[no-]always-dump-stacktrace",
+ boolean: true,
+ default: false,
+ description: "Always dump the stacktrace regardless of the log_level setting."
+
option :help,
short: "-h",
long: "--help",
diff --git a/lib/chef/provider/file.rb b/lib/chef/provider/file.rb
index 9d9980d2fb..449ab49c90 100644
--- a/lib/chef/provider/file.rb
+++ b/lib/chef/provider/file.rb
@@ -1,7 +1,7 @@
#
# Author:: Adam Jacob (<adam@chef.io>)
# Author:: Lamont Granquist (<lamont@chef.io>)
-# Copyright:: Copyright 2008-2017, Chef Software Inc.
+# Copyright:: Copyright 2008-2020, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -381,7 +381,7 @@ class Chef
def update_file_contents
do_backup unless needs_creating?
- deployment_strategy.deploy(tempfile.path, ::File.realpath(new_resource.path))
+ deployment_strategy.deploy(tempfile.path, ::File.realpath(new_resource.path).force_encoding(Chef::Config[:ruby_encoding]))
logger.info("#{new_resource} updated file contents #{new_resource.path}")
if managing_content?
# save final checksum for reporting.