From 80c5274e77ed6ad7494fac6b8ff140fe2e621e98 Mon Sep 17 00:00:00 2001 From: rjhornsby Date: Tue, 3 Oct 2023 13:25:27 -0500 Subject: [PATCH] Support pool setting 'recycling.periodicRestart.requests' --- CHANGELOG.md | 1 + documentation/iis_pool.md | 1 + resources/pool.rb | 6 +++++- test/cookbooks/test/recipes/pool.rb | 1 + test/integration/pool/controls/pool_spec.rb | 1 + test/integration/pool/libraries/iis_pool.rb | 4 ++++ 6 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e578db90..18754aa3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ This file is used to list changes made in each version of the iis cookbook. - Change CI to test on Windows Latest This clarfies that we are testing on the latest version of Windows and not a specific version as per `platform: windows-latest` in ci.yml +- Add support for IIS pool setting `recycling.periodicRestart.requests` ## 8.1.0 - *2023-10-03* diff --git a/documentation/iis_pool.md b/documentation/iis_pool.md index a36167b8..a3d33869 100644 --- a/documentation/iis_pool.md +++ b/documentation/iis_pool.md @@ -62,6 +62,7 @@ Creates an application pool in IIS. | `recycle_schedule_clear` | String | `false` | No | specifies a pool to clear all scheduled recycle times. | | | `log_event_on_recycle` | true, false | `node['iis']['recycle']['log_events']`| No | configure IIS to log an event when one or more of the following configured events cause an application pool to recycle (for additional information about [logging events] (). | | | `recycle_after_time` | String | | No | specifies a pool to recycle at regular time intervals, d.hh:mm:ss. | | +| `recycle_after_requests` | Integer | | No | specifies the number of requests after which you want the pool to recycle. | | | `periodic_restart_schedule` | Array, String | | No | schedule a pool to recycle at specific times. | | | `private_memory` | Integer | | No | specifies the amount of private memory (in kilobytes) after which you want the pool to recycle. | | | `virtual_memory` | Integer | | No | specifies the amount of virtual memory (in kilobytes) after which you want the pool to recycle. | | diff --git a/resources/pool.rb b/resources/pool.rb index a2034cfc..c44c5de9 100644 --- a/resources/pool.rb +++ b/resources/pool.rb @@ -60,6 +60,7 @@ property :recycle_schedule_clear, [true, false], default: false property :log_event_on_recycle, String, default: lazy { node['iis']['recycle']['log_events'] } property :recycle_after_time, String +property :recycle_after_requests, Integer, coerce: proc { |v| v.to_i } property :periodic_restart_schedule, [Array, String], default: [], coerce: proc { |v| Array(v).sort } property :private_memory, Integer, coerce: proc { |v| v.to_i } property :virtual_memory, Integer, coerce: proc { |v| v.to_i } @@ -150,6 +151,7 @@ disallow_overlapping_rotation bool(value(doc.root, 'APPPOOL/add/recycling/@disallowOverlappingRotation')) disallow_rotation_on_config_change bool(value(doc.root, 'APPPOOL/add/recycling/@disallowRotationOnConfigChange')) recycle_after_time value doc.root, 'APPPOOL/add/recycling/periodicRestart/@time' + recycle_after_requests value(doc.root, 'APPPOOL/add/recycling/periodicRestart/@requests').to_i periodic_restart_schedule get_value(doc.root, 'APPPOOL/add/recycling/periodicRestart/schedule/add/@value').map(&:value) private_memory value(doc.root, 'APPPOOL/add/recycling/periodicRestart/@privateMemory').to_i virtual_memory value(doc.root, 'APPPOOL/add/recycling/periodicRestart/@memory').to_i @@ -351,7 +353,9 @@ def configure converge_if_changed :recycle_after_time do cmd << configure_application_pool("recycling.periodicRestart.time:#{new_resource.recycle_after_time}") end - + converge_if_changed :recycle_after_requests do + cmd << configure_application_pool("recycling.periodicRestart.requests:#{new_resource.recycle_after_requests}") + end converge_if_changed :log_event_on_recycle do cmd << configure_application_pool("recycling.logEventOnRecycle:#{new_resource.log_event_on_recycle}") end diff --git a/test/cookbooks/test/recipes/pool.rb b/test/cookbooks/test/recipes/pool.rb index 2d6fcbd9..7ec1c80f 100644 --- a/test/cookbooks/test/recipes/pool.rb +++ b/test/cookbooks/test/recipes/pool.rb @@ -53,6 +53,7 @@ start_mode :OnDemand identity_type :SpecificUser periodic_restart_schedule ['06:00:00', '14:00:00', '17:00:00'] + recycle_after_requests '1024' environment_variables ['HELLO=WORLD', 'FOO=BAR', 'ALPHA=BETA2'] username "#{node['hostname']}\\vagrant" password 'vagrant' diff --git a/test/integration/pool/controls/pool_spec.rb b/test/integration/pool/controls/pool_spec.rb index b2fd7e21..21679f8d 100644 --- a/test/integration/pool/controls/pool_spec.rb +++ b/test/integration/pool/controls/pool_spec.rb @@ -26,6 +26,7 @@ its('start_mode') { should eq 'OnDemand' } its('identity_type') { should eq 'SpecificUser' } its('periodic_restart_schedule') { should eq ['06:00:00', '14:00:00', '17:00:00'] } + its('recycle_after_requests') { should eq 1024 } its('environment_variables') { should eq ['ALPHA=BETA2', 'FOO=BAR', 'HELLO=WORLD'] } its('username') { should include('\\vagrant') } its('password') { should eq 'vagrant' } diff --git a/test/integration/pool/libraries/iis_pool.rb b/test/integration/pool/libraries/iis_pool.rb index 49837b83..d975bf0d 100644 --- a/test/integration/pool/libraries/iis_pool.rb +++ b/test/integration/pool/libraries/iis_pool.rb @@ -100,6 +100,10 @@ def periodic_restart_schedule iis_pool[:recycling][:periodic_restart][:schedule] end + def recycle_after_requests + iis_pool[:recycling][:periodic_restart][:requests] + end + def environment_variables iis_pool[:environment_variables] end