[chef] Recover from a yum error


Chronological Thread 
  • From: Michael Glenney < >
  • To:
  • Subject: [chef] Recover from a yum error
  • Date: Tue, 18 Oct 2011 15:39:11 -0700

We have an error that crops up from time to time (often enough to be really annoying) with yum in which something get's corrupted with a metadata.xml file. Error looks like this:

[Tue, 18 Oct 2011 21:59:44 +0000] ERROR: package[libxslt-devel] (cloudwatch_monitoring::default line 27) has had an error
[Tue, 18 Oct 2011 21:59:44 +0000] ERROR: package[libxslt-devel] (/var/chef/cache/cookbooks/cloudwatch_monitoring/recipes/default.rb:27:in `block in from_file') had an error:
package[libxslt-devel] (cloudwatch_monitoring::default line 27) had an error: yum -d0 -e0 -y install libxslt-devel-1.1.26-2.6.amzn1 returned 1, expected 0

Several yum packages installed before this one so the corruption is happening in flight.  Not blaming chef because I'm sure it's not a chef problem, just want to know if I can handle it in-flight instead of scraping the entire deploy.

If I try to run the command on the command line of the host I get:

Error: File /var/cache/yum/x86_64/latest/epel/metalink.xml is not XML

If I run a 'yum clean all' it fixes the issue and I back up and running.  Except this is after the chef run has failed.  What I'm looking for is some fancy way to catch the exception, have it run 'yum clean all', and then retry the yum.  Anyone have any cool ideas?

MG



Archive powered by MHonArc 2.6.16.

§