Skip to content

Commit 8e9657f

Browse files
committed
(PUP-9407) Disable filebuckets by default
Previously puppet stored a copy of any file it overwrote or deleted in its local filebucket. However, the local filebucket grows unbounded over time and a cron job or tidy resource must be used to delete old files. Change the `backup` parameter's default value to false. The old behavior can be reenabled by adding a resource default: File { backup => 'puppet' }
1 parent de6de62 commit 8e9657f

File tree

6 files changed

+19
-18
lines changed

6 files changed

+19
-18
lines changed

acceptance/tests/ticket_1334_clientbucket_corrupted.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
end
1515

1616
managed_content = "managed\n"
17-
manifest = "file { '#{tmpfile}': content => '#{managed_content}', }"
17+
manifest = "file { '#{tmpfile}': content => '#{managed_content}', backup => 'puppet' }"
1818

1919
step 'create unmanaged file' do
2020
create_remote_file(agent, tmpfile, unmanaged_content)

acceptance/tests/ticket_6541_invalid_filebucket_files.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
apply_manifest_on(agent, manifest)
1616

1717
step "overwrite file, causing zero-length file to be backed up"
18-
manifest = "file { '#{target}': content => 'some text' }"
18+
manifest = "file { '#{target}': content => 'some text', backup => 'puppet' }"
1919
apply_manifest_on(agent, manifest)
2020

2121
test_name "verify invalid hashes should not change the file"
@@ -40,9 +40,9 @@
4040

4141
test_name "verify that an empty file can be retrieved from the filebucket"
4242
if fips_mode
43-
manifest = "file { '#{target}': content => '{sha256}e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' }"
43+
manifest = "file { '#{target}': content => '{sha256}e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', backup => 'puppet' }"
4444
else
45-
manifest = "file { '#{target}': content => '{md5}d41d8cd98f00b204e9800998ecf8427e' }"
45+
manifest = "file { '#{target}': content => '{md5}d41d8cd98f00b204e9800998ecf8427e', backup => 'puppet' }"
4646
end
4747

4848
apply_manifest_on(agent, manifest) do

lib/puppet/type/file.rb

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,11 @@ def self.title_patterns
8383
use copy the file in the same directory with that value as the extension
8484
of the backup. (A value of `true` is a synonym for `.puppet-bak`.)
8585
* If set to any other string, Puppet will try to back up to a filebucket
86-
with that title. See the `filebucket` resource type for more details.
87-
(This is the preferred method for backup, since it can be centralized
88-
and queried.)
86+
with that title. Puppet automatically creates a **local** filebucket
87+
named `puppet` if one doesn't already exist. See the `filebucket` resource
88+
type for more details.
8989
90-
Default value: `puppet`, which backs up to a filebucket of the same name.
91-
(Puppet automatically creates a **local** filebucket named `puppet` if one
92-
doesn't already exist.)
90+
Default value: `false`
9391
9492
Backing up to a local filebucket isn't particularly useful. If you want
9593
to make organized use of backups, you will generally want to use the
@@ -125,7 +123,7 @@ def self.title_patterns
125123
- Restrict the directory to a maximum size after which the oldest items are removed.
126124
EOT
127125

128-
defaultto "puppet"
126+
defaultto false
129127

130128
munge do |value|
131129
# I don't really know how this is happening.

spec/unit/type/file/content_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
let(:filename) { tmpfile('testfile') }
88
let(:environment) { Puppet::Node::Environment.create(:testing, []) }
99
let(:catalog) { Puppet::Resource::Catalog.new(:test, environment) }
10-
let(:resource) { Puppet::Type.type(:file).new :path => filename, :catalog => catalog }
10+
let(:resource) { Puppet::Type.type(:file).new :path => filename, :catalog => catalog, :backup => 'puppet' }
1111

1212
before do
1313
File.open(filename, 'w') {|f| f.write "initial file content"}

spec/unit/type/file_spec.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@
133133
end
134134

135135
describe "the backup parameter" do
136+
it 'should be disabled by default' do
137+
expect(file[:backup]).to eq(nil)
138+
end
139+
136140
[false, 'false', :false].each do |value|
137141
it "should disable backup if the value is #{value.inspect}" do
138142
file[:backup] = value
@@ -928,7 +932,7 @@
928932
end
929933

930934
it "should fail if it can't backup the file" do
931-
# Default: file[:backup] = true
935+
file[:backup] = true
932936
allow(file).to receive(:stat).and_return(double('stat', :ftype => 'file'))
933937
allow(file).to receive(:perform_backup).and_return(false)
934938

@@ -937,7 +941,7 @@
937941

938942
describe "backing up directories" do
939943
it "should not backup directories if backup is true and force is false" do
940-
# Default: file[:backup] = true
944+
file[:backup] = true
941945
file[:force] = false
942946
allow(file).to receive(:stat).and_return(double('stat', :ftype => 'directory'))
943947

@@ -947,7 +951,7 @@
947951
end
948952

949953
it "should backup directories if backup is true and force is true" do
950-
# Default: file[:backup] = true
954+
file[:backup] = true
951955
file[:force] = true
952956
allow(file).to receive(:stat).and_return(double('stat', :ftype => 'directory'))
953957

@@ -974,7 +978,7 @@
974978
end
975979

976980
it "should remove a directory if backup is true and force is true" do
977-
# Default: file[:backup] = true
981+
file[:backup] = true
978982
file[:force] = true
979983
allow(file).to receive(:stat).and_return(double('stat', :ftype => 'directory'))
980984

@@ -1006,6 +1010,7 @@
10061010
end
10071011

10081012
it "should fail if the file is not a directory, link, file, fifo, socket, or is unknown" do
1013+
file[:backup] = 'puppet'
10091014
allow(file).to receive(:stat).and_return(double('stat', :ftype => 'blockSpecial'))
10101015

10111016
expect(file).to receive(:warning).with("Could not back up file of type blockSpecial")

spec/unit/util/backups_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
let(:path) { make_absolute('/no/such/file') }
1717

1818
it "should noop if the file does not exist" do
19-
file = Puppet::Type.type(:file).new(:name => path)
20-
2119
expect(file).not_to receive(:bucket)
2220
expect(Puppet::FileSystem).to receive(:exist?).with(path).and_return(false)
2321

0 commit comments

Comments
 (0)