Skip to content

Commit a101a2c

Browse files
Calling "pkg update -n" on Solaris too frequently causes problems with zones
On a Solaris system, running "pkg update -n" in the global zone at the same time that it is running in a non-global zone, can cause the command to fail in one or the other. If we have puppet running this command, it causes the puppet run to fail for that specific resource. This patch removes some unnecessary calls to this command, and appropriately updates rspec.
1 parent 1a53bf7 commit a101a2c

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

lib/puppet/provider/package/pkg.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ def insync?(is)
160160
warning(_("Implicit version %{should} has %{n} possible matches") % { should: should, n: n })
161161
end
162162
potential_matches.each { |p|
163+
# If the version that we match is installed then we don't need
164+
# to check if it's installed (or installable), just return true
165+
return true if is != :absent && p[:status] == 'installed'
166+
163167
command = is == :absent ? 'install' : 'update'
164168
options = ['-n']
165169
options.concat(join_options(@resource[:install_options])) if @resource[:install_options]

spec/unit/provider/package/pkg_spec.rb

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -286,13 +286,7 @@ def self.it_should_respond_to(*actions)
286286

287287
it "should install specific version(2)" do
288288
resource[:ensure] = '0.0.8'
289-
expect(provider).to receive(:properties).and_return({:mark => :hold})
290-
expect(Puppet::Util::Execution).to receive(:execute)
291-
.with(['/bin/pkg', 'unfreeze', 'dummy'], {:failonfail => false, :combine => true})
292-
.and_return(Puppet::Util::Execution::ProcessOutput.new('', 0))
293-
expect(Puppet::Util::Execution).to receive(:execute)
294-
.with(['/bin/pkg', 'list', '-Hv', 'dummy'], {:failonfail => false, :combine => true})
295-
.and_return(Puppet::Util::Execution::ProcessOutput.new('pkg://foo/[email protected],5.11-0.151006:20131230T130000Z installed -----', 0))
289+
expect(provider).to receive(:query).with(no_args).and_return({:ensure => '0.0.7,5.11-0.151006:20131230T130000Z'}).exactly(2).times
296290
expect(Puppet::Util::Execution).to receive(:execute)
297291
.with(['/bin/pkg', 'update', *hash[:flags], '[email protected]'], {:failonfail => false, :combine => true})
298292
.and_return(Puppet::Util::Execution::ProcessOutput.new('', 0))
@@ -301,11 +295,7 @@ def self.it_should_respond_to(*actions)
301295

302296
it "should downgrade to specific version" do
303297
resource[:ensure] = '0.0.7'
304-
expect(provider).to receive(:properties).and_return({:mark => :hold})
305-
expect(provider).to receive(:query).with(no_args).and_return({:ensure => '0.0.8,5.11-0.151106:20131230T130000Z'})
306-
expect(Puppet::Util::Execution).to receive(:execute)
307-
.with(['/bin/pkg', 'unfreeze', 'dummy'], {:failonfail => false, :combine => true})
308-
.and_return(Puppet::Util::Execution::ProcessOutput.new('', 0))
298+
expect(provider).to receive(:query).with(no_args).and_return({:ensure => '0.0.8,5.11-0.151106:20131230T130000Z'}).exactly(2).times
309299
expect(Puppet::Util::Execution).to receive(:execute)
310300
.with(['/bin/pkg', 'update', *hash[:flags], '[email protected]'], {:failonfail => false, :combine => true})
311301
.and_return(Puppet::Util::Execution::ProcessOutput.new('', 0))

0 commit comments

Comments
 (0)