Commit aac3fbf0 authored by Iustin Pop's avatar Iustin Pop
Browse files

utils.FileLock: handle init errors properly



If the open of the lock file fails (due to whatever reason), 'self'
won't have the 'fd' attribute, and thus we fail in Close/__del__, which
will ruin proper error reporting:

IOError: [Errno 30] Read-only file system: '/var/lib/ganeti/queue/lock'
Exception exceptions.AttributeError: "'FileLock' object has no attribute
'fd'" in <bound method FileLock.__del__ of <ganeti.utils.FileLock object
at 0x2aaaad0bebd0>> ignored
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 8645ff83
......@@ -2258,7 +2258,7 @@ class FileLock(object):
"""Close the file and release the lock.
"""
if self.fd:
if hasattr(self, "fd") and self.fd:
self.fd.close()
self.fd = None
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment