[Openstack-operators] Exception dumping recon cache

Sverre Stoltenberg sverrest at opera.com
Tue Feb 7 08:51:15 UTC 2012

On a fairly standard installed wheezy machine, the os.rename in 
swift-recon-cron will spit out this exeption to syslog:

Exception dumping recon cache: #012Traceback (most recent call 
last):#012  File 
"/usr/lib/python2.7/dist-packages/swift/obj/replicator.py", line 611, in 
run_forever#012    self.recon_object)#012  File 
"/usr/lib/python2.7/dist-packages/swift/common/utils.py", line 1102, in 
dump_recon_cache#012    os.rename(tf.name, cache_file)#012OSError: 
[Errno 18] Invalid cross-device link

Creating the temp file in the same directory as the cache_file makes 
os.rename work as expected:

diff --git a/swift/common/utils.py b/swift/common/utils.py
index dc89282..8db51f3 100644
--- a/swift/common/utils.py
+++ b/swift/common/utils.py
@@ -1097,7 +1097,7 @@ def dump_recon_cache(cache_key, cache_value, 
cache_file, lock_timeout=2):
          cache_entry[cache_key] = cache_value
-            with NamedTemporaryFile(delete=False) as tf:
+            with NamedTemporaryFile(delete=False, 
dir=os.path.dirname(cache_file)) as tf:
                  tf.write(json.dumps(cache_entry) + '\n')
              os.rename(tf.name, cache_file)


More information about the Openstack-operators mailing list