summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2020-04-15 15:48:21 -0700
committerTim Smith <tsmith84@gmail.com>2020-04-15 15:48:21 -0700
commitaf38a81dab3d8024cefe804b45db241ba710669f (patch)
tree0ec57eaaab897fcee5e09d6e677d4432dfafbbae
parent0905698f81e1b2814ee7b2dcf65487adf95a355b (diff)
downloadchef-eol_warning.tar.gz
Add a warning to the end of the chef run for EOL releseseol_warning
We really want to encourage people to upgrade. One way we can do this is to just warn them that they're on an EOL release. This simple warning might nudge them to upgrade their client. It's works off the base EOL data of Chef 15 and takes the current release to add to that date. That way we don't have to maintain anything and as long as we keep a yearly release we're good. If we change the schedule then we either remove this or update the logic. That's a risk in shipping code that doesn't fire for 2 years. Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/client.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/chef/client.rb b/lib/chef/client.rb
index eceed0aa7e..a87ae622bb 100644
--- a/lib/chef/client.rb
+++ b/lib/chef/client.rb
@@ -295,6 +295,8 @@ class Chef
# keep this inside the main loop to get exception backtraces
end_profiling
+ warn_if_eol
+
# rebooting has to be the last thing we do, no exceptions.
Chef::Platform::Rebooter.reboot_if_needed!(node)
rescue Exception => run_error
@@ -324,6 +326,22 @@ class Chef
#
# @api private
+ def warn_if_eol
+ require_relative "version"
+
+ # we have a yearly release and we know 15 goes EOL in 2021 so calculate off that
+ # this way we don't have to update anything or maintain a hash of EOL dates
+ base_eol_year = 2017
+ base_release = Gem::Version.new(15)
+
+ diff_from_base_release = Gem::Version.new(Chef::VERSION).segments.first - base_release.segments.first
+
+ if Time.now > Time.new(base_eol_year + diff_from_base_release)
+ logger.warn("This release of #{Chef::Dist::PRODUCT} became end of life (EOL) on May 1st #{base_eol_year + diff_from_base_release}. Please update to a supported release to receive new features, bug fixes, and security updates.")
+ end
+ end
+
+ # @api private
def configure_formatters
formatters_for_run.map do |formatter_name, output_path|
if output_path.nil?