Skip to content

Commit d86dc2a

Browse files
committed
(PUP-10946) Allow max_files warning to be disabled
Allow max_files to be set to negative, and if so, don't error or warn, which was the behavior prior to commit d07d37a.
1 parent b21bd8d commit d86dc2a

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

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/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)