Skip to content

Commit bb8421d

Browse files
Merge pull request #8597 from joshcooper/recursive_pluginsync_10946
(PUP-10946) Ignore max file warnings during pluginsync
2 parents 113ba4d + 849b281 commit bb8421d

File tree

5 files changed

+21
-5
lines changed

5 files changed

+21
-5
lines changed

lib/puppet/configurer/downloader.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ def default_arguments
7373
:purge => true,
7474
:force => true,
7575
:backup => false,
76-
:noop => false
76+
:noop => false,
77+
:max_files => -1
7778
}
7879
if !Puppet::Util::Platform.windows?
7980
defargs[:owner] = Process.uid

lib/puppet/file_serving/fileset.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def files
6161
files = perform_recursion
6262
soft_max_files = 1000
6363

64-
if max_files != 0 && files.size > max_files
64+
if max_files > 0 && files.size > max_files
6565
raise Puppet::Error.new _("The directory '%{path}' contains %{entries} entries, which exceeds the limit of %{max_files} specified by the max_files parameter for this resource. The limit may be increased, but be aware that large number of file resources can result in excessive resource consumption and degraded performance. Consider using an alternate method to manage large directory trees") % { path: path, entries: files.size, max_files: max_files }
6666
elsif max_files == 0 && files.size > soft_max_files
6767
Puppet.warning _("The directory '%{path}' contains %{entries} entries, which exceeds the default soft limit %{max_files} and may cause excessive resource consumption and degraded performance. To remove this warning set a value for `max_files` parameter or consider using an alternate method to manage large directory trees") % { path: path, entries: files.size, max_files: soft_max_files }

lib/puppet/type/file.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,12 @@ def self.title_patterns
229229
will eventually be created and will raise a resource argument error if the
230230
limit will be exceeded.
231231
232-
Use value `0` to disable the check. In this case, a warning is logged if
233-
the number of files exceeds 1000."
232+
Use value `0` to log a warning instead of raising an error.
233+
234+
Use value `-1` to disable errors and warnings due to max files."
234235

235236
defaultto 0
236-
newvalues(/^[0-9]+$/)
237+
newvalues(/^[0-9]+$/, /^-1$/)
237238
end
238239

239240
newparam(:replace, :boolean => true, :parent => Puppet::Parameter::Boolean) do

spec/unit/configurer/downloader_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ def generate_file_resource(options = {})
8181
expect(file[:source_permissions]).to eq(:ignore)
8282
end
8383

84+
it "should ignore the max file limit" do
85+
file = generate_file_resource
86+
87+
expect(file[:max_files]).to eq(-1)
88+
end
89+
8490
describe "on POSIX", :if => Puppet.features.posix? do
8591
it "should allow source_permissions to be overridden" do
8692
file = generate_file_resource(:source_permissions => :use)

spec/unit/file_serving/fileset_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,14 @@ def directory?
302302
expect { @fileset.files }.to_not raise_error
303303
end
304304

305+
it "does not emit a warning if max_files is -1" do
306+
mock_big_dir_structure(@path)
307+
@fileset.recurse = true
308+
@fileset.max_files = -1
309+
expect(Puppet).to receive(:warning).never
310+
@fileset.files
311+
end
312+
305313
it "ignores files that match a pattern given as a boolean" do
306314
mock_dir_structure(@path)
307315
@fileset.recurse = true

0 commit comments

Comments
 (0)