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:57:17 -0700
commit4601e0435e539817b1bfbd80e828291ae6e6c2b2 (patch)
tree6f2b1220813aca63a792062d6a00d18a264661e0
parent951ea92875f5999b5508465e6e4e1f82fab39bda (diff)
downloadchef-eol_release_warning.tar.gz
Add a warning to the end of the chef run for EOL releseseol_release_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..4985d6ea1d 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 = 2022
+ 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, 5, 1)
+ 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?