August 5, 2010

Dealing with stale cached apt manifests in Chef-run apt transactions

I have a 'base' Chef recipe whose job is to do global basic bootstrapping tasks to EC2 slices. One of the first things that this recipe does on Ubuntu slices is update the apt caches using 'apt get update.' Without that step, it generally fails, because the AMIs I use don't have complete and up-to-date apt repo information in them.

Well, today, I ran the recipe on a new slice and it tanked. apt was exiting with status 100, and when I checked, it was producing the following error:

 IP ADDRESS apt-get update returned 100, expected 0

...and running apt-get update manually returned an error complaining that it couldn't update the repo information. It complained:

W: Failed to fetch  (the problem archive file): Hash Sum mismatch

The problem here, it turns out, is that the archive in question I was attempting to get updated manifests for had been updated - but the checksum (Hash Sum) for that archive had been *cached* by something in between my slice and the archive (likely some form of proxy). As a result, they didn't match, and bam.

The Fix: The fix came from here. Essentially, mod your apt-get command to include an option for 'no-cache', either during the call:

apt-get update -o Acquire::http::No-Cache

...or by putting the option into your apt config (see the post linked above for how-to).

Whew. Another day, another thing.

Posted by jbz at August 5, 2010 2:40 PM | TrackBack

Post a comment

Remember personal info?