summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKylo Ginsberg <kylo@puppetlabs.com>2014-10-09 22:23:07 -0700
committerKylo Ginsberg <kylo@puppetlabs.com>2014-10-10 00:14:52 -0700
commitd5b39c9001cdbc67d37ebb841c5fcbdad6f77d32 (patch)
tree6424b5d1ac3a95c487b924171b057028a9e56cd8
parent9f4f7e1af873b8e7ce1404c5cd4c4fdd1f33a07a (diff)
downloadpuppet-d5b39c9001cdbc67d37ebb841c5fcbdad6f77d32.tar.gz
(PUP-643) Ignore pkg's certificate expiration warning messages
When a pkg certificate is in it's last 30 days before expiration, the pkg tools emit a warning message so you can get a new certificate for some operations. The 'latest' method issues a 'pkg -Hn <package>' which trips this warning message, but the message was unexpected and 'latest' would raise, failing the catalog application. This commit simply ignores such certificate expiration warnings. While I was in there, I split a very compact line of code across a couple lines and added some spaces, in the name of readability.
-rw-r--r--lib/puppet/provider/package/pkg.rb4
-rw-r--r--spec/fixtures/unit/provider/package/pkg/dummy_solaris11.certificate_warning2
-rwxr-xr-xspec/unit/provider/package/pkg_spec.rb4
3 files changed, 9 insertions, 1 deletions
diff --git a/lib/puppet/provider/package/pkg.rb b/lib/puppet/provider/package/pkg.rb
index 4192dca85..249e46760 100644
--- a/lib/puppet/provider/package/pkg.rb
+++ b/lib/puppet/provider/package/pkg.rb
@@ -126,7 +126,9 @@ Puppet::Type.type(:package).provide :pkg, :parent => Puppet::Provider::Package d
# http://defect.opensolaris.org/bz/show_bug.cgi?id=19159%
# notes that we can't use -Ha for the same even though the manual page reads that way.
def latest
- lst = pkg(:list, "-Hn", @resource[:name]).split("\n").map{|l|self.class.parse_line(l)}
+ lst = pkg(:list, "-Hn", @resource[:name]).split("\n").
+ select { |line| line !~ /^Certificate/ }. # skip certificate expiration warnings
+ map { |line| self.class.parse_line(line) }
# Now we know there is a newer version. But is that installable? (i.e are there any constraints?)
# return the first known we find. The only way that is currently available is to do a dry run of
diff --git a/spec/fixtures/unit/provider/package/pkg/dummy_solaris11.certificate_warning b/spec/fixtures/unit/provider/package/pkg/dummy_solaris11.certificate_warning
new file mode 100644
index 000000000..83849be03
--- /dev/null
+++ b/spec/fixtures/unit/provider/package/pkg/dummy_solaris11.certificate_warning
@@ -0,0 +1,2 @@
+Certificate '/var/pkg/ssl/871b4ed0ade09926e6adf95f86bf17535f987684' for publisher 'solarisstudio', needed to access 'https://pkg.oracle.com/solarisstudio/release/', will expire in '29' days.
+dummy 1.0.6-0.175.0.0.0.2.537 i--
diff --git a/spec/unit/provider/package/pkg_spec.rb b/spec/unit/provider/package/pkg_spec.rb
index 8ddbbbfe0..9442b7f21 100755
--- a/spec/unit/provider/package/pkg_spec.rb
+++ b/spec/unit/provider/package/pkg_spec.rb
@@ -70,6 +70,10 @@ describe Puppet::Type.type(:package).provider(:pkg) do
described_class.expects(:pkg).with(:list,'-Hn','dummy').returns File.read(my_fixture('dummy_solaris11.installed'))
provider.latest.should == "1.0.6-0.175.0.0.0.2.537"
end
+ it "should work correctly for ensure latest on solaris 11 in the presence of a certificate expiration warning" do
+ described_class.expects(:pkg).with(:list,'-Hn','dummy').returns File.read(my_fixture('dummy_solaris11.certificate_warning'))
+ provider.latest.should == "1.0.6-0.175.0.0.0.2.537"
+ end
it "should work correctly for ensure latest on solaris 11(known UFOXI)" do
Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'update', '-n', 'dummy'], {:failonfail => false, :combine => true}).returns ''
$CHILD_STATUS.stubs(:exitstatus).returns 0