Skip to content

Commit c2aeeb1

Browse files
authored
Merge pull request #8980 from mhashizume/PUP-11684/main/unchanged_default
(PUP-11684) Default to exclude unchanged resources
2 parents 736798e + 5949c3a commit c2aeeb1

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

lib/puppet/defaults.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1452,7 +1452,7 @@ def self.initialize_default_settings!(settings)
14521452
To turn off reports entirely, set this to `none`",
14531453
},
14541454
:exclude_unchanged_resources => {
1455-
:default => false,
1455+
:default => true,
14561456
:type => :boolean,
14571457
:desc => 'When set to true, resources that have had no changes after catalog application
14581458
will not have corresponding unchanged resource status updates listed in the report.'

spec/unit/transaction/report_spec.rb

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,46 @@
138138
end
139139

140140
describe "when exclude_unchanged_resources is true" do
141+
let(:test_dir) { tmpdir('unchanged_resources') }
142+
let(:test_dir2) { tmpdir('unchanged_resources') }
143+
let(:test_file) { tmpfile('some_path')}
144+
it 'should still list "changed" resource statuses but remove "unchanged"' do
145+
transaction = apply_compiled_manifest(<<-END)
146+
notify { "hi": } ~>
147+
exec { "/bin/this_command_does_not_exist":
148+
command => "#{make_absolute('/bin/this_command_does_not_exist')}",
149+
refreshonly => true,
150+
}
151+
file { '#{test_dir}':
152+
ensure => directory
153+
}
154+
file { 'failing_file':
155+
path => '#{test_dir2}',
156+
ensure => file
157+
}
158+
file { 'skipped_file':
159+
path => '#{test_file}',
160+
require => File[failing_file]
161+
}
162+
END
163+
rs = transaction.report.to_data_hash['resource_statuses']
164+
expect(rs["Notify[hi]"]['out_of_sync']).to be true
165+
expect(rs["Exec[/bin/this_command_does_not_exist]"]['failed_to_restart']).to be true
166+
expect(rs["File[failing_file]"]['failed']).to be true
167+
expect(rs["File[skipped_file]"]['skipped']).to be true
168+
expect(rs).to_not have_key(["File[#{test_dir}]"])
169+
end
170+
end
171+
172+
describe"when exclude_unchanged_resources is false" do
141173
before do
142-
Puppet[:exclude_unchanged_resources] = true
174+
Puppet[:exclude_unchanged_resources] = false
143175
end
144176

145177
let(:test_dir) { tmpdir('unchanged_resources') }
146178
let(:test_dir2) { tmpdir('unchanged_resources') }
147179
let(:test_file) { tmpfile('some_path')}
148-
it 'should still list "changed" resource statuses but remove "unchanged"' do
180+
it 'should list all resource statuses' do
149181
transaction = apply_compiled_manifest(<<-END)
150182
notify { "hi": } ~>
151183
exec { "/bin/this_command_does_not_exist":
@@ -169,7 +201,7 @@
169201
expect(rs["Exec[/bin/this_command_does_not_exist]"]['failed_to_restart']).to be true
170202
expect(rs["File[failing_file]"]['failed']).to be true
171203
expect(rs["File[skipped_file]"]['skipped']).to be true
172-
expect(rs).to_not have_key(["File[#{test_dir}]"])
204+
expect(rs["File[#{test_dir}]"]['changed']).to be false
173205
end
174206
end
175207

0 commit comments

Comments
 (0)