Chef Deprecation Warnings
When we wish to remove a feature or an API in Chef, we try to first mark it with a deprecation warning that contains a link to a description of the change and how to fix it. For example:
Deprecated features used!
JSON auto inflation isn't supported (CHEF-1) at (irb):7:in `irb_binding`.
Please see /chef-client/deprecations/json_auto_inflate.html for further details and information on how to correct this problem.
Testing for Deprecations
To test your code for deprecations, you can put Test Kitchen in a mode
where any deprecations cause the chef run to fail. Ensure your
kitchen.yml
includes:
provisioner:
deprecations_as_errors: true
and then run Test Kitchen as usual. Test Kitchen will fail if any deprecation errors are issued.
Silencing deprecation warnings
Deprecation warnings are great for ensuring cookbooks are kept
up-to-date and to prepare for major version upgrades, sometimes you just
can’t fix a deprecation right away. Enabling
treat_deprecation_warnings_as_errors
mode in Test Kitchen integration
tests often compounds the problem because it doesn’t distinguish
between deprecations from community cookbooks and those in your own
code.
Two new options are provided for silencing deprecation warnings:
silence_deprecation_warnings
and inline chef:silence_deprecation
comments.
The silence_deprecation_warnings
configuration value can be set in
your client.rb
or solo.rb
config file, either to true
to silence
all deprecation warnings or to an array of deprecations to silence. You
can specify which to silence either by the deprecation key name (for example,
"internal_api"
), the numeric deprecation ID (for example, 25
or “CHEF-25”), or by specifying the filename and
line number where the deprecation is being raised from (for example,
"default.rb:67"
).
An example of setting the silence_deprecation_warnings
option in your
client.rb
or solo.rb
:
silence_deprecation_warnings %w{deploy_resource chef-23 recipes/install.rb:22}
or in your `kitchen.yml`:
provisioner:
name: chef_solo
solo_rb:
treat_deprecation_warnings_as_errors: true
silence_deprecation_warnings:
- deploy_resource
- chef-23
- recipes/install.rb:22
You can also silence deprecations using a comment on the line that’s raising the warning:
erl_call 'something' do # chef:silence_deprecation
We advise caution in the use of this feature, as excessive or prolonged silencing can lead to difficulty upgrading when the next major release of Chef comes out.
All Deprecations
ID | Description | Deprecated | Expected Removal |
---|---|---|---|
CHEF-0 | Many internal APIs have been improved. | various | varies |
CHEF-1 | Consumers of JSON are now required to be explicit in how it's turned in to a Chef object. | 12.7 | 13.0 |
CHEF-2 | Chef's exit codes are now defined so that it's easy to understand why Chef exited. | 12.11 | 13.0 |
CHEF-3 | When using the chef_gem resource, the phase to install the gem in must be specified. | 12.1 | 13.0 |
CHEF-4 | Various improvements have been made to attribute syntax. | various | varies |
CHEF-5 | Various improvements have been made to custom resource syntax. | various | varies |
CHEF-6 | The easy_install resource will be removed. | 12.10 | 13.0 |
CHEF-7 | The verify metaproperty's file substitution will be removed. | 12.5 | 13.0 |
CHEF-8 | The supports metaproperty will be removed. | 12.14 | 13.0 |
CHEF-9 | The Chef::REST API will be removed. | 12.7 | 13.0 |
CHEF-10 | DNF package provider and resource don't require --allow-downgrade anymore. | 12.18 | 13.0 |
CHEF-11 | An exception will be raised if a resource property conflicts with an already-existing property or method. | 12.19 | 13.0 |
CHEF-12 | An exception will be raised whenever the hash property in the launchd resource is used. | 12.19 | 13.0 |
CHEF-13 | Deprecated Chef::Platform methods | 12.18 | 13.0 |
CHEF-14 | Deprecation of run_command | 12.18 | 13.0 |
CHEF-18 | Deprecation of local mode listening. | 13.1 | 15.0 |
CHEF-19 | Deprecation of property_name within actions. | 13.2 | 14.0 |
CHEF-20 | Deprecation of the deploy resource. | 13.6 | 14.0 |
CHEF-21 | Deprecation of the :uninstall action in the chocolatey_package resource. | 13.7 | 14.0 |
CHEF-22 | Deprecation of the erl_call resource. | 13.7 | 14.0 |
CHEF-23 | Deprecation of legacy HWRP mixins. | 12.X | 14.0 |
CHEF-24 | Deprecation of epic_fail in favor of allow_failure | 13.7 | 14.0 |
CHEF-25 | Resources in a cookbook collide with the same resources now included in Chef Infra Client. | XX.X | 15.0 |
CHEF-26 | Deprecation of legacy shell_out APIs. | 14.3 | 15.0 |
CHEF-27 | Deprecation of lc_all from locale resource | 15.0 | 16.0 |
CHEF-31 | Deprecation of resource_name declaration without provides | 15.13 | 16.2 |
CHEF-33 | Enabling Unified Mode in custom resources | 17.0 | |
CHEF-3694 | Resource Cloning will no longer work. | 10.18 | 13.0 |
OHAI-1 | Ohai::Config removal. | 12.6 | 13.0 |
OHAI-2 | Sigar gem based plugins removal. | 12.19 | 13.0 |
OHAI-3 | run_command and popen4 helper method removal. | 12.8 | 13.0 |
OHAI-4 | Libvirt plugin attributes changes. | 12.19 | 14.0 |
OHAI-5 | Windows CPU plugin attribute changes. | 12.19 | 13.0 |
OHAI-6 | DigitalOcean plugin attribute changes. | 12.19 | 13.0 |
OHAI-7 | Amazon linux moved to the Amazon platform_family. | 13.0 | 13.0 |
OHAI-8 | Cloud plugin replaced by the Cloud_V2 plugin. | 13.0 | 13.0 |
OHAI-9 | Filesystem plugin replaced by the Filesystem V2 plugin. | 13.0 | 13.0 |
OHAI-10 | Removal of support for Ohai version 6 plugins. | 11.12 | 14.0 |
OHAI-11 | Cloud_v2 attribute removal. | 13.1 | 14.0 |
OHAI-12 | Filesystem2 attribute removal. | 13.1 | 14.0 |
OHAI-13 | Removal of IpScopes plugin | 13.2 | 14.0 |
OHAI-14 | Removal of system_profile plugin | 14.6 | 15.0 |