chef 13.1.31-universal-mingw32 → 13.2.20-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +68 -134
  3. data/Rakefile +1 -0
  4. data/VERSION +1 -1
  5. data/acceptance/.shared/kitchen_acceptance/.kitchen.ec2.yml +1 -0
  6. data/acceptance/top-cookbooks/.kitchen.docker.yml +4 -0
  7. data/lib/chef/application/client.rb +27 -18
  8. data/lib/chef/deprecated.rb +10 -0
  9. data/lib/chef/dsl/declare_resource.rb +9 -1
  10. data/lib/chef/knife.rb +5 -1
  11. data/lib/chef/knife/cookbook_test.rb +1 -1
  12. data/lib/chef/policy_builder/policyfile.rb +27 -1
  13. data/lib/chef/provider.rb +2 -2
  14. data/lib/chef/provider/group/aix.rb +1 -1
  15. data/lib/chef/provider/group/groupadd.rb +1 -1
  16. data/lib/chef/provider/package/chocolatey.rb +1 -1
  17. data/lib/chef/provider/user/pw.rb +1 -1
  18. data/lib/chef/provider/user/windows.rb +1 -1
  19. data/lib/chef/resource/breakpoint.rb +1 -1
  20. data/lib/chef/version.rb +3 -1
  21. data/lib/chef/version_string.rb +143 -0
  22. data/spec/functional/mixin/powershell_out_spec.rb +20 -4
  23. data/spec/functional/resource/group_spec.rb +19 -13
  24. data/spec/functional/resource/windows_task_spec.rb +2 -9
  25. data/spec/integration/knife/common_options_spec.rb +29 -11
  26. data/spec/integration/knife/cookbook_bulk_delete_spec.rb +2 -2
  27. data/spec/integration/knife/cookbook_show_spec.rb +2 -2
  28. data/spec/integration/knife/environment_compare_spec.rb +2 -2
  29. data/spec/integration/knife/environment_show_spec.rb +2 -2
  30. data/spec/integration/knife/role_show_spec.rb +2 -2
  31. data/spec/integration/recipes/accumulator_spec.rb +6 -6
  32. data/spec/integration/recipes/resource_action_spec.rb +18 -7
  33. data/spec/integration/recipes/resource_load_spec.rb +5 -21
  34. data/spec/spec_helper.rb +2 -0
  35. data/spec/support/platform_helpers.rb +5 -0
  36. data/spec/support/shared/unit/provider/useradd_based_user_provider.rb +1 -1
  37. data/spec/unit/application/client_spec.rb +2 -0
  38. data/spec/unit/knife_spec.rb +22 -0
  39. data/spec/unit/policy_builder/policyfile_spec.rb +50 -0
  40. data/spec/unit/provider/group/groupadd_spec.rb +1 -1
  41. data/spec/unit/provider/user/pw_spec.rb +1 -1
  42. data/spec/unit/version_string_spec.rb +79 -0
  43. data/tasks/dependencies.rb +1 -42
  44. metadata +6 -5
  45. data/tasks/bundle.rb +0 -73
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 18cc628e41c1eb7d8fff6e4256a77785065cc485
4
- data.tar.gz: 3af7acd319ded51c6b1b86524d2fb0fec338e123
3
+ metadata.gz: d6a0b5921631851ef4a8949a2a37ffdf0aa988fb
4
+ data.tar.gz: 9641714d23d46c527d267d73b7eedca919ac223b
5
5
  SHA512:
6
- metadata.gz: 8137abac5c6bd10a499734030f005376bce42d5390ead6abee2d3dc8564aaa88a094bc10e4983dfa651fa6364ed2a857029c97822476d9cfd99a3c114fa76fb4
7
- data.tar.gz: 35a820bc69626e7427ae2cc6358416a07753d729a31f993a5c44ce20827b42ae12b1a16805552d113ae74cc55beb1a708272f14307f19769ef98e864158a24ab
6
+ metadata.gz: b6b23819c1582b599cd50759273057e81180b19b30e7eb993238c5647e5ba9ecf629701ef12b8fc98598c21c4e572896e93e858646cb9e9f2b7217fff2001df9
7
+ data.tar.gz: 99f31b6bbfcd26dde3c43a858dd98ac305522d07fba4d3e20e9bed6b0fde816a62740c9d808acb4727444318b2a66a57d1b515d8c3b80b2e4aec4b9b5589b6fd
data/README.md CHANGED
@@ -24,51 +24,55 @@ If you just want to use Chef, check out these resources:
24
24
  - [Installer Downloads](https://downloads.chef.io/chef/): Install Chef as a complete package
25
25
  - [chef/chef](https://hub.docker.com/r/chef/chef): Docker image for use with [kitchen-dokken](https://github.com/someara/kitchen-dokken)
26
26
 
27
+ ## Reporting Issues
28
+
29
+ Issues can be reported by using [GitHub Issues](https://github.com/chef/chef/issues).
30
+
31
+ Full details on how to report issues can be found in the [CONTRIBUTING](https://github.com/chef/chef/blob/master/CONTRIBUTING.md#-chef-issue-tracking) doc.
32
+
33
+ Note that this repository is primarily for reporting chef-client issues.
34
+ For reporting issues against other Chef projects, please look up the appropriate repository
35
+ to report issues against in the Chef docs in the
36
+ [community contributions section](https://docs.chef.io/community_contributions.html#issues-and-bug-reports).
37
+ If you can't determine the appropriate place to report an issue, then please open it
38
+ against the repository you think best fits and it will be directed to the appropriate project.
39
+
27
40
  ## Installing From Git
28
41
 
29
- **NOTE:** Unless you have a specific reason to install from source (to
30
- try a new feature, contribute a patch, or run chef on an OS for which no
31
- package is available), you should head to the [downloads page](https://downloads.chef.io/chef/)
32
- to get a prebuilt package.
42
+ **NOTE:** As a Chef user, please download the omnibus package of [Chef](https://downloads.chef.io/chef) or [Chef-DK](https://downloads.chef.io/chef)
43
+
44
+ We do not recommend installing from gems, or building from source. The following instructions apply only to those doing software development on Chef.
33
45
 
34
46
  ### Prerequisites
35
47
 
36
- Install these via your platform's preferred method (`apt`, `yum`, `ports`,
37
- `emerge`, etc.):
48
+ Install:
38
49
 
39
50
  * git
40
- * C compiler, header files, etc. On Ubuntu/Debian, use the
41
- `build-essential` package.
42
- * ruby 2.3.0 or later
51
+ * C compiler, header files, etc.
52
+ * ruby 2.3.3 or later
43
53
  * rubygems
44
54
  * bundler gem
45
55
 
56
+ We support too many platforms, and there are too many different ways to manage ruby installs, so
57
+ it is assumed the user understands how to accomplish this for their platform and needs (see previous
58
+ note about downloading the pre-built omnibus install if you do not understand how to accomplish this).
59
+
46
60
  ### Chef Installation
47
61
 
48
62
  Then get the source and install it:
49
63
 
50
64
  ```bash
51
- # Clone this repo
52
65
  git clone https://github.com/chef/chef.git
53
-
54
- # cd into the source tree
55
66
  cd chef
56
-
57
- # Install dependencies with bundler
58
67
  bundle install
59
-
60
- # Build a gem
61
68
  bundle exec rake gem
62
-
63
- # Install the gem you just built
64
- gem install pkg/chef-VERSION.gem
69
+ bundle exec rake install
65
70
  ```
66
71
 
67
72
  ## Contributing/Development
68
73
 
69
- Before working on the code, if you plan to contribute your changes, you need to
70
- read the
71
- [Chef Contributions document](https://docs.chef.io/community_contributions.html).
74
+ Please read our [Community Contributions Guidelines](https://docs.chef.io/community_contributions.html), and
75
+ ensure you are signing all your commits with DCO sign-off.
72
76
 
73
77
  The general development process is:
74
78
 
@@ -82,59 +86,62 @@ RSpec for test driven development, so you'll need to get a development
82
86
  environment running. Follow the above procedure ("Installing from Git") to get
83
87
  your local copy of the source running.
84
88
 
85
- ## Reporting Issues
86
-
87
- Issues can be reported by using [GitHub Issues](https://github.com/chef/chef/issues).
88
-
89
- Full details on how to report issues can be found in the [CONTRIBUTING](https://github.com/chef/chef/blob/master/CONTRIBUTING.md#-chef-issue-tracking) doc.
90
-
91
- Note that this repository is primarily for reporting chef-client issues.
92
- For reporting issues against other Chef projects, please look up the appropriate repository
93
- to report issues against in the Chef docs in the
94
- [community contributions section](https://docs.chef.io/community_contributions.html#issues-and-bug-reports).
95
- If you can't determine the appropriate place to report an issue, then please open it
96
- against the repository you think best fits and it will be directed to the appropriate project.
97
-
98
89
  ## Testing
99
90
 
100
- We use RSpec for unit/spec tests. It is not necessary to start the development
101
- environment to run the specs--they are completely standalone.
91
+ This repository only uses rspec for testing.
102
92
 
103
93
  ```bash
104
- # Run All the Tests
105
- bundle exec rake spec
94
+ # all tests
95
+ bundle exec rspec
106
96
 
107
- # Run a Single Test File
97
+ # single test
108
98
  bundle exec rspec spec/PATH/TO/FILE_spec.rb
109
99
 
110
- # Run a Subset of Tests
100
+ # all tests under a subdir
111
101
  bundle exec rspec spec/PATH/TO/DIR
112
102
  ```
113
103
 
114
- When you submit a pull request, we will automatically run the functional and unit
115
- tests in spec/functional/ and spec/unit/ respectively. These will be run on Ubuntu
116
- through Travis CI, and on Windows through AppVeyor. The status of these runs will
117
- be displayed with your pull request.
104
+ When you submit a PR rspec tests will run automatically on travis and appveyor.
118
105
 
119
106
  ## Building the Full Package
120
107
 
121
- To build chef as a standalone package (with ruby and all dependent libraries included in a .deb, .rpm, .pkg or .msi), we use the omnibus system. Go to the [omnibus README](omnibus/README.md) to find out how to build!
108
+ To build chef as a standalone package, we use the [omnibus](omnibus/README.md) system.
109
+
110
+ To build:
111
+
112
+ ```bash
113
+ git clone https://github.com/chef/chef.git
114
+ cd chef/omnibus
115
+ bundle install
116
+ bundle exec omnibus build chef
117
+ ```
118
+
119
+ The prerequisites necessary to run omnibus itself are not documented here. The automation we use is
120
+ the [opscode-ci cookbook](https://github.com/chef-cookbooks/opscode-ci) cookbook, which serves as the most
121
+ current documentation.
122
122
 
123
123
  ## Updating Dependencies
124
124
 
125
125
  If you want to change our constraints (change which packages and versions we accept in the chef), there are several places to do so:
126
126
 
127
- * To add or remove a gem from chef, or update a gem version, edit [Gemfile](Gemfile).
128
- * To change the version of binary packages, edit [version_policy.rb](version_policy.rb).
129
- * To add new packages to chef, edit [omnibus/config/projects/chef.rb](omnibus/config/projects/chef.rb).
127
+ * [Gemfile](Gemfile) and [Gemfile.lock](Gemfile.lock): All gem version constraints (update with `bundle update`)
128
+ * [omnibus_overrides.rb](omnibus_overrides_rb): Pinned versions of omnibus packages.
129
+ * [omnibus/Gemfile](omnibus/Gemfile) and [omnibus/Gemfile.lock](omnibus/Gemfile.lock): Gems for the omnibus build system itself.
130
+
131
+ In addition there are several places versions are pinned for CI tasks:
132
+
133
+ * [acceptance/Gemfile](acceptance/Gemfile) and [acceptance/Gemfile.lock](acceptance/Gemfile.lock): Acceptance tests (internal jenkins)
134
+ * [kitchen-tests/Gemfile](kitchen-tests/Gemfile) and [kitchen-tests/Gemfile.lock](kitchen-tests/Gemfile.lock): Gems for test-kitchen tests (travis)
135
+ * [kitchen-tests/Berksfile](kitchen-tests/Berksfile) and [kitchen-tests/Berksfile.lock](kitchen-tests/Berksfile.lock): Cookbooks for test-kitchen tests (travis)
130
136
 
131
- Once you've made any changes you want, you have to update the lockfiles that actually drive the build:
132
- * To update chef's gem dependencies to the very latest versions available, run `rake bundle:update`.
133
- * To update chef's gem dependencies *conservatively* (changing as little as possible), run `rake bundle:install`.
134
- * To update specific gems only, run `rake bundle:update[gem1 gem2 ...]`
135
- * **`bundle update` and `bundle install` will *not* work, on purpose:** the rake task handles both the windows and non-windows lockfiles and updates them in sync.
137
+ In order to update everything run `rake dependencies`. Note that the [Gemfile.lock](Gemfile.lock) pins windows platforms and to fully regenerate the lockfile
138
+ you must use the following commands or run `rake dependencies:update_gemfile_lock`:
136
139
 
137
- To perform a full update of all dependencies in chef (including binary packages, tests and build system dependencies), run `rake dependencies`. This will update the `Gemfile.lock`, `omnibus/Gemfile.lock`, `acceptance/Gemfile.lock`, `omnibus/Berksfile.lock`, and `omnibus_overrides.rb`. It will also show you any outdated dependencies due to conflicting constraints. Some outdated dependencies are to be expected; it will inform you if any new ones appear that we don't know about, and tell you how to proceed.
140
+ ```bash
141
+ bundle lock --update --add-platform ruby
142
+ bundle lock --update --add-platform x64-mingw32
143
+ bundle lock --update --add-platform x86-mingw32
144
+ ```
138
145
 
139
146
  # How Chef Builds and Versions
140
147
 
@@ -188,35 +195,23 @@ Sometimes, regressions split through the cracks. Since new functionality is alwa
188
195
 
189
196
  Chef has two sorts of component: ruby components like `berkshelf` and `test-kitchen`, and binary components like `openssl` and even `ruby` itself.
190
197
 
191
- In general, you can find all chef desired versions in the [Gemfile](Gemfile) and [version_policy.rb](version_policy.rb) files. The [Gemfile.lock](Gemfile.lock) is the locked version of the Gemfile, and [omnibus_overrides](omnibus_overrides.rb) is the locked version of omnibus. [build](omnibus/Gemfile) and [test](acceptance/Gemfile) Gemfiles and [Berksfile](omnibus/Berksfile) version the toolset we use to build and test.
198
+ In general, you can find all chef desired versions in the [Gemfile](Gemfile) and [omnibus_overrides.rb](omnibus_overrides.rb) files. The [Gemfile.lock](Gemfile.lock) is the locked version of the Gemfile.
192
199
 
193
200
  ### Binary Components
194
201
 
195
- The versions of binary components (as well as rubygems and bundler, which can't be versioned in a Gemfile) are stored in [version_policy.rb](version_policy.rb) (the `OMNIBUS_OVERRIDES` constant) and locked in [omnibus_overrides](omnibus_overrides.rb). `rake dependencies` will update the `bundler` version, and the rest are be updated manually by Chef every so often.
202
+ The versions of binary components (as well as rubygems and bundler, which can't be versioned in a Gemfile) are stored in [omnibus_overrides.rb](omnibus_overrides.rb).
196
203
 
197
204
  These have software definitions either in [omnibus/config/software](omnibus/config/software) or, more often, in the [omnibus-software](https://github.com/chef/omnibus-software/tree/master/config/software) project.
198
205
 
199
206
  ### Rubygems Components
200
207
 
201
- Most of the actual front-facing software in chef is composed of ruby projects. berkshelf, test-kitchen and even chef itself are made of ruby gems. Chef uses the typical ruby way of controlling rubygems versions, the `Gemfile`. Specifically, the `Gemfile` at the top of chef repository governs the version of every single gem we install into chef package. It's a one-stop shop.
202
-
203
- Our rubygems component versions are locked down with `Gemfile.lock`, and can be updated with `rake dependencies`.
204
-
205
- There are three gems versioned outside the `Gemfile`: `rubygems`, `bundler` and `chef`. `rubygems` and `bundler` are in the `RUBYGEMS_AT_LATEST_VERSION` constant in [version_policy.rb](version-policy.rb) and locked in [omnibus_overrides](omnibus_overrides.rb). They are kept up to date by `rake dependencies`.
206
-
207
- **Windows**: [Gemfile.lock](Gemfile.lock) is generated platform-agnostic, and then generated again for Windows. The one file has the solution for both Linux and Windows.
208
-
209
- The tool we use to generate Windows-specific lockfiles on non-Windows machines is [tasks/bin/bundle-platform](bundle-platform), which takes the first argument and sets `Gem.platforms`, and then calls `bundle` with the remaining arguments.
208
+ Our rubygems component versions are locked down with `Gemfile.lock`, and can be updated with `bundle update` or `rake dependencies:update_gemfile_lock`.
210
209
 
211
210
  ### Build Tooling Versions
212
211
 
213
- Of special mention is the software we use to build omnibus itself. There are two distinct bits of code that control the versions of compilers, make, git, and other tools we use to build.
214
-
215
- First, the Jenkins machines that run the build are configured entirely by the [opscode-ci cookbook](https://github.com/chef-cookbooks/opscode-ci) cookbook. They install most of the tools we use via `build-essentials`, and standardize the build environment so we can tear down and bring up builders at will. These machines are kept alive long-running, are periodically updated by Chef to the latest opscode-ci, omnibus and build-essentials cookbooks.
216
-
217
- Second, the version of omnibus we use to build chef is governed by `omnibus/Gemfile`. When software definitions or the omnibus framework is updated, this is the file that drives whether we pick it up.
218
-
219
- The omnibus tooling versions are locked down with `omnibus/Gemfile.lock`, and can be updated by running `rake dependencies`.
212
+ The external environment necessary to build omnibus (compilers, make, git, etc) is configured by the [opscode-ci cookbook](https://github.com/chef-cookbooks/opscode-ci) cookbook. In order to reliably create omnibus builds that cookbook should be used to install the prerequisites. It may be possible to install the latest version
213
+ of utilities on a suitably recent distribution and be able to build an omnibus package, but the necessary prerequisites will not be documented here. In most
214
+ cases a recent MacOS with Xcode and a few homebrew packages or a recent Ubuntu distribution with packages like `build-essentials` should suffice.
220
215
 
221
216
  ### Test Versions
222
217
 
@@ -224,67 +219,6 @@ chef is tested by the [chef-acceptance framework](https://github.com/chef/chef-a
224
219
 
225
220
  The test tooling versions are locked down with `acceptance/Gemfile.lock`, which can be updated by running `rake dependencies`.
226
221
 
227
- ## The Build Process
228
-
229
- The actual Chef build process is done with Omnibus, and has several general steps:
230
-
231
- 1. `bundle install` from `chef/Gemfile.lock`
232
- 2. Reinstall any gems that came from git or path using `rake install`
233
- 3. appbundle chef, chef, test-kitchen and berkshelf
234
- 4. Put miscellaneous powershell scripts and cleanup
235
-
236
- ### Kicking Off The Build
237
-
238
- The build is kicked off in Jenkins by running this on the machine (which is already the correct OS and already has the correct dependencies, loaded by the `omnibus` cookbook):
239
-
240
- ```
241
- load-omnibus-toolchain.bat
242
- cd chef/omnibus
243
- bundle install
244
- bundle exec omnibus build chef
245
- ```
246
-
247
- This causes the [chef project definition](omnibus/config/projects/chef.rb) to load, which runs the [chef-complete](omnibus/config/software/chef-complete.rb) software definition, the primary software definition driving the whole build process. The reason we embed it all in a software definition instead of the project is to take advantage of omnibus caching: omnibus will invalidate the entire project (and recompile ruby, openssl, and everything else) if you change anything at all in the project file. Not so with a software definition.
248
-
249
- ### Installing the Gems
250
-
251
- The primary build definition that installs the many Chef rubygems is [`software/chef.rb`](omnibus/software/chef.rb). This has dependencies on any binary libraries, ruby, rubygems and bundler. It has a lot of steps, so it uses a [library](omnibus/files/chef/build-chef.rb) to help reuse code and make it manageable to look at.
252
-
253
- What it does:
254
-
255
- 1. Depends on software defs for pre-cached gems (see "Gems and Caching" below).
256
- 2. Installs all gems from the bundle:
257
- - Sets up a `.bundle/config` ([code](omnibus/files/chef/build-chef.rb#L17-L39)) with --retries=4, --jobs=1, --without=development,no_<platform>, and `build.config.nokogiri` to pass.
258
- - Sets up a common environment, standardizing the compilers and flags we use, in [`env`](omnibus/files/chef-gem/build-chef-gem.rb#L32-L54).
259
- - [Runs](omnibus/config/software/chef.rb#L68) `bundle install --verbose`
260
- 3. Reinstalls any gems that were installed via path:
261
- - [Runs](omnibus/files/chef/build-chef.rb#L80) `bundle list --paths` to get the installed directories of all gems.
262
- - For each gem not installed in the main gem dir, [runs](omnibus/files/chef/build-chef.rb#L89) `rake install` from the installed gem directory.
263
- - [Deletes](omnibus/files/chef/build-chef.rb#L139-L143) the bundler git cache and path- and git-installed gems from the build.
264
- 4. [Creates](omnibus/files/chef/build-chef.rb#L102-L152) `/opt/chef/Gemfile` and `/opt/chef/Gemfile.lock` with the gems that were installed in the build.
265
-
266
- #### Gems and Caching
267
-
268
- Some gems take a super long time to install (particularly native-compiled ones such as nokogiri and dep-selector-libgecode) and do not change version very often. In order to avoid doing this work every time, we take advantage of omnibus caching by separating out these gems into their own software definitions. [chef-gem-dep-selector-libgecode](omnibus/config/software/chef-gem-dep-selector-libgecode.rb) for example.
269
-
270
- Each of these gems uses the `config/files/chef-gem/build-chef-gem` library to define itself. The name of the software definition itself indicates the .
271
-
272
- We only create software definitions for long-running gems. Everything else is just installed in the [chef](omnibus/config/software/chef.rb) software definition in a big `bundle install` catchall.
273
-
274
- Most gems we just install in the single `chef` software definition.
275
-
276
- The first thing
277
-
278
- ### Appbundling
279
-
280
- After the gems are installed, we *appbundle* them in [chef-appbundle](omnibus/config/software/chef-appbundle.rb). This creates binstubs that use the bundle to pin the software .
281
-
282
- During the process of appbundling, we update the gem's `Gemfile` to include the locks in the top level `/opt/chef/Gemfile.lock`, so we can guarantee they will never pick up things outside the build. We then run `bundle lock` to update the gem's `Gemfile.lock`, and `bundle check` to ensure all the gems are actually installed. The appbundler then uses these pins.
283
-
284
- ### Other Cleanup
285
-
286
- Finally, chef does several more steps including installing powershell scripts and shortcuts, and removing extra documentation to keep the build slim.
287
-
288
222
  # License
289
223
 
290
224
  Chef - A configuration management system
data/Rakefile CHANGED
@@ -34,6 +34,7 @@ require_relative "tasks/version"
34
34
  ChefConfig::PackageTask.new(File.expand_path("..", __FILE__), "Chef", "chef") do |package|
35
35
  package.component_paths = ["chef-config"]
36
36
  package.generate_version_class = true
37
+ package.use_versionstring = true
37
38
  end
38
39
 
39
40
  task :pedant, :chef_zero_spec
data/VERSION CHANGED
@@ -1 +1 @@
1
- 13.1.31
1
+ 13.2.20
@@ -19,6 +19,7 @@ driver:
19
19
  subnet_id: subnet-19ac017c
20
20
  security_group_ids: ["sg-e401eb83", "sg-96274af3"]
21
21
  instance_type: m3.large
22
+ retryable_tries: 120
22
23
  # associate_public_ip: true # Don't enable public IP, as subnet specified is behind VPN
23
24
 
24
25
  # busser installation relies on this
@@ -1,6 +1,10 @@
1
1
  suites:
2
2
  - name: docker-default
3
3
  attributes:
4
+ apt-docker:
5
+ repos:
6
+ docker-main:
7
+ keyserver: hkp://ha.pool.sks-keyservers.net
4
8
  docker:
5
9
  version: 1.10.0
6
10
  run_list:
@@ -304,6 +304,7 @@ class Chef::Application::Client < Chef::Application
304
304
  :boolean => false
305
305
 
306
306
  IMMEDIATE_RUN_SIGNAL = "1".freeze
307
+ RECONFIGURE_SIGNAL = "H".freeze
307
308
 
308
309
  attr_reader :chef_client_json
309
310
 
@@ -409,9 +410,15 @@ class Chef::Application::Client < Chef::Application
409
410
  SELF_PIPE.replace IO.pipe
410
411
 
411
412
  trap("USR1") do
412
- Chef::Log.info("SIGUSR1 received, waking up")
413
+ Chef::Log.info("SIGUSR1 received, will run now or after the current run")
413
414
  SELF_PIPE[1].putc(IMMEDIATE_RUN_SIGNAL) # wakeup master process from select
414
415
  end
416
+
417
+ # Override the trap setup in the parent so we can avoid running reconfigure during a run
418
+ trap("HUP") do
419
+ Chef::Log.info("SIGHUP received, will reconfigure now or after the current run")
420
+ SELF_PIPE[1].putc(RECONFIGURE_SIGNAL) # wakeup master process from select
421
+ end
415
422
  end
416
423
  end
417
424
 
@@ -454,14 +461,14 @@ class Chef::Application::Client < Chef::Application
454
461
  end
455
462
 
456
463
  def sleep_then_run_chef_client(sleep_sec)
457
- @signal = test_signal
458
- unless @signal == IMMEDIATE_RUN_SIGNAL
459
- Chef::Log.debug("Sleeping for #{sleep_sec} seconds")
460
- interval_sleep(sleep_sec)
461
- end
462
- @signal = nil
464
+ Chef::Log.debug("Sleeping for #{sleep_sec} seconds")
465
+
466
+ # interval_sleep will return early if we received a signal (unless on windows)
467
+ interval_sleep(sleep_sec)
463
468
 
464
469
  run_chef_client(Chef::Config[:specific_recipes])
470
+
471
+ reconfigure
465
472
  rescue SystemExit => e
466
473
  raise
467
474
  rescue Exception => e
@@ -474,10 +481,6 @@ class Chef::Application::Client < Chef::Application
474
481
  Chef::Application.fatal!("#{e.class}: #{e.message}", e)
475
482
  end
476
483
 
477
- def test_signal
478
- @signal = interval_sleep(0)
479
- end
480
-
481
484
  def time_to_sleep
482
485
  duration = 0
483
486
  duration += rand(Chef::Config[:splay]) if Chef::Config[:splay]
@@ -485,20 +488,26 @@ class Chef::Application::Client < Chef::Application
485
488
  duration
486
489
  end
487
490
 
491
+ # sleep and handle queued signals
488
492
  def interval_sleep(sec)
489
493
  unless SELF_PIPE.empty?
490
- client_sleep(sec)
494
+ # mimic sleep with a timeout on IO.select, listening for signals setup in #setup_signal_handlers
495
+ return unless IO.select([ SELF_PIPE[0] ], nil, nil, sec)
496
+
497
+ signal = SELF_PIPE[0].getc.chr
498
+
499
+ return if signal == IMMEDIATE_RUN_SIGNAL # be explicit about this behavior
500
+
501
+ # we need to sleep again after reconfigure to avoid stampeding when logrotate runs out of cron
502
+ if signal == RECONFIGURE_SIGNAL
503
+ reconfigure
504
+ interval_sleep(sleep)
505
+ end
491
506
  else
492
- # Windows
493
507
  sleep(sec)
494
508
  end
495
509
  end
496
510
 
497
- def client_sleep(sec)
498
- return unless IO.select([ SELF_PIPE[0] ], nil, nil, sec)
499
- @signal = SELF_PIPE[0].getc.chr
500
- end
501
-
502
511
  def unforked_interval_error_message
503
512
  "Unforked chef-client interval runs are disabled in Chef 12." +
504
513
  "\nConfiguration settings:" +
@@ -248,6 +248,16 @@ class Chef
248
248
  end
249
249
  end
250
250
 
251
+ class NamespaceCollisions < Base
252
+ def id
253
+ 19
254
+ end
255
+
256
+ def target
257
+ "namespace_collisions.html"
258
+ end
259
+ end
260
+
251
261
  # id 3694 was deleted
252
262
 
253
263
  class Generic < Base
@@ -155,7 +155,15 @@ class Chef
155
155
  def edit_resource(type, name, created_at: nil, run_context: self.run_context, &resource_attrs_block)
156
156
  edit_resource!(type, name, created_at: created_at, run_context: run_context, &resource_attrs_block)
157
157
  rescue Chef::Exceptions::ResourceNotFound
158
- declare_resource(type, name, created_at: created_at, run_context: run_context, &resource_attrs_block)
158
+ resource = declare_resource(type, name, created_at: created_at, run_context: run_context)
159
+ if resource_attrs_block
160
+ if defined?(new_resource)
161
+ resource.instance_exec(new_resource, &resource_attrs_block)
162
+ else
163
+ resource.instance_exec(&resource_attrs_block)
164
+ end
165
+ end
166
+ resource
159
167
  end
160
168
 
161
169
  # Lookup a resource in the resource collection by name. If the resource is not