[Bug 1216921] [NEW] util.ignore_missing() does not work

Launchpad Bug Tracker 1216921 at bugs.launchpad.net
Tue Sep 24 12:54:35 UTC 2013


You have been subscribed to a public bug by Louis Bouchard (louis-bouchard):

SRU justification :

Without this fix, there is a potential for crash during execution of
duplicity

Impact :

Renders duplicity potentially unusable dues to spurious crashes

Fix :

Backport upstream fix for this problem merged in 
https://code.launchpad.net/~mterry/duplicity/ignore-missing

Test Case :

A session must be run within the python debugger to systematically
reproduce the context.

1) Run a duplicity session as outlined in comment #8 inside the debugger
2) break at duplicity/path:568 instead of 567
3) When the program breaks, manually remove the file that ends in "...manifest.gpg"
4) continue execution

Without the fix, duplicity will crash with the outlined backtrace. With
the fix, duplicity will terminate normally.

Regression :

Minimal as the modification changes exception handling only for a
function only used twice to delete files/directories (path.py &
tempdir.py)

Description of the problem :

Duplicity can potentially crash while attempting to delete a file that
no longer exists.

Original description

duplicity version: 0.6.18-0ubuntu3
python version: 2.7.3
Distro: ubuntu precise 12.04
target file system: ftp

I happen to encounter failed backups with tracebacks like this:

Traceback (most recent call last):
  File "/usr/bin/duplicity", line 1403, in <module>
     with_tempdir(main)
  File "/usr/bin/duplicity", line 1396, in with_tempdir
     fn()
   File "/usr/bin/duplicity", line 1366, in main
     full_backup(col_stats)
   File "/usr/bin/duplicity", line 504, in full_backup
     sig_outfp.to_remote()
   File "/usr/lib/python2.7/dist-packages/duplicity/dup_temp.py", line 184, in to_remote
     globals.backend.move(tgt) #@UndefinedVariable
   File "/usr/lib/python2.7/dist-packages/duplicity/backend.py", line 364, in move
     source_path.delete()
   File "/usr/lib/python2.7/dist-packages/duplicity/path.py", line 567, in delete
     util.ignore_missing(os.unlink, self.name)
   File "/usr/lib/python2.7/dist-packages/duplicity/util.py", line 116, in ignore_missing
     fn(filename)
 OSError: [Errno 2] No such file or directory: '/BACKUP/.duplycache/duply_foo/duplicity-full-signatures.20130825T140002Z.sigtar.gpg'

Now running test code like

#!/usr/bin/env python
#
# Do what util.ignore_missing(os.unlink, self.name) tries to do and
# fails to achieve

import os
import sys
import errno

if __name__ == "__main__":
        try:
                os.unlink("/tmp/doesnotexist")
        except Exception:
                # "type" is a reserved keyword, replaced with "mytype"
                mytype, value, tb = sys.exc_info()
                print "-" * 78
                print "mytype: ", mytype
                print "value: ", value
                print "value[0]:", value[0]
                print "errno.ENOENT: ", errno.ENOENT
                print "isinstance(mytype, OSError): ", isinstance(mytype, OSError)
                print "-" * 78
                if isinstance(mytype, OSError) and value[0] == errno.ENOENT:
                        print "Gotcha!"
                        pass
                print "Ooops, missed it ..."
                raise

will always raise the exception and not ignore it, because
isinstance(mytype, OSError) is always False.

What I expect ignore_missing to look like is:

def ignore_missing(fn, filename):
    """
    Execute fn on filename.  Ignore ENOENT errors, otherwise raise exception.

    @param fn: callable
    @param filename: string
    """
    try:
        fn(filename)
    except OSError, ex:
        if ex.errno == errno.ENOENT:
            pass
        else:
            raise
    else:
        raise

** Affects: duplicity
     Importance: High
         Status: Fix Committed

** Affects: duplicity (Ubuntu)
     Importance: High
     Assignee: Michael Terry (mterry)
         Status: Fix Released

** Affects: duplicity (Ubuntu Precise)
     Importance: High
     Assignee: Louis Bouchard (louis-bouchard)
         Status: In Progress

** Affects: duplicity (Ubuntu Quantal)
     Importance: High
     Assignee: Louis Bouchard (louis-bouchard)
         Status: In Progress

** Affects: duplicity (Ubuntu Raring)
     Importance: High
     Assignee: Louis Bouchard (louis-bouchard)
         Status: In Progress

-- 
util.ignore_missing() does not work
https://bugs.launchpad.net/bugs/1216921
You received this bug notification because you are a member of Ubuntu Sponsors Team, which is subscribed to the bug report.



More information about the Ubuntu-sponsors mailing list