#4258 Capture stdout/stderr from svn import failures

v1.0.0
closed
nobody
42cc (432)
SCM
Cory Johns
2015-08-20
2012-05-21
No

This error isn't very useful on its own. This is from the "SourceForge Repo Clone Failure" email, which occurs after using the SVN admin option for importing a repo.

Traceback (most recent call last):
 File "/var/local/allura/Allura/allura/tasks/repo_tasks.py", line 31, in clone
   cloned_from_url)
 File "/var/local/allura/Allura/allura/model/repository.py", line 227, in init_as_clone
   self._impl.clone_from(source_url)
 File "/var/local/allura/ForgeSVN/forgesvn/model/svn.py", line 176, in clone_from
   subprocess.check_call(['svnsync', 'init', self._url, source_url])
 File "/usr/lib64/python2.7/subprocess.py", line 511, in check_call
   raise CalledProcessError(retcode, cmd)
CalledProcessError: Command '['svnsync', 'init', u'file:///svn/p/testupgradetool/code', u'http://testupgradetool.svn.sourceforge.net/svnroot/testupgradetool']' returned non-zero exit status 1

Related

Tickets: #4258

Discussion

  • Dave Brondsema

    Dave Brondsema - 2012-05-31
    • labels: --> 42cc

    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,4 +1,4 @@
    -This error isn't very useful on its own.  This is from the "SourceForge Repo Clone Failure" email.
    +This error isn't very useful on its own.  This is from the "SourceForge Repo Clone Failure" email, which occurs after using the SVN admin option for importing a repo.
    
     ~~~~
     Traceback (most recent call last):
    
     
  • Yaroslav Luzin - 2012-06-05

    created #75: [#4258] Capture stdout/stderr from svn import failures (2cp)

     

    Related

    Tickets: #4258

  • Yaroslav Luzin - 2012-06-07

    closed #75, branch - 42cc_4258

    • status: open --> code-review
     
  • Dave Brondsema

    Dave Brondsema - 2012-06-11
    • qa: Cory Johns
     
  • Cory Johns - 2012-06-12
    • status: code-review --> in-progress
     
  • Cory Johns - 2012-06-12

    This could suffer from the issue mentioned in wait, namely that the OS pipe buffer could fill up and block the call.


    It should either use communicate or check_output.

     
  • Yaroslav Luzin - 2012-06-13

    created #84: [#4258] Use communicate or check_output instead of wait

     

    Related

    Tickets: #4258

  • Anonymous - 2012-06-14

    Originally by: tramadolmen

    You are wrong :)

     
  • Dave Brondsema

    Dave Brondsema - 2012-06-14

    What do you mean? Please explain more.

     
  • Anonymous - 2012-06-15

    Originally by: tramadolmen

    Without waiting for command complete some tests are failed. If i right remember problem was in commits save. My first version was without wait() :). After broken test - i read the source of subprocess.py file and find that:

    def call(*popenargs, **kwargs):
        return Popen(*popenargs, **kwargs).wait()
    
    def check_call(*popenargs, **kwargs):
        retcode = call(*popenargs, **kwargs)
        cmd = kwargs.get("args")
        if cmd is None:
            cmd = popenargs[0]
        if retcode:
            raise CalledProcessError(retcode, cmd)
        return retcode
    

    You see in call function called wait command. So in my code i simply copy paste original check_call function code and add stdout, stderr read

     
  • Cory Johns - 2012-06-15

    The problem is not with the fact that it waits, but that if you wait without reading any of the input from a pipe, the OS pipe buffer could fill up and the OS will block the process until some input is read from it, resulting in a deadlock. This is mentioned in the warning for wait as well as the note for check_call. It won't always, or even usually, of course, but it's a definite possibility, especially with large repos.


    The solution is to read the output to prevent blocking, which can be done using either communicate or check_output (communicate allows you to separate the stdout and stderr but you have to do more boiler-plate, while check_output will only return stdout so you have to pipe stderr into stdout if you want to retrieve it, which we do).

     
  • Anonymous - 2012-06-15

    Originally by: tramadolmen

    I checked what you say about process blocking. Yes you are right

     
  • Yaroslav Luzin - 2012-06-19
    • status: in-progress --> code-review
     
  • Yaroslav Luzin - 2012-06-19

    Updated the branch 42cc_4258 and closed #84

     
  • Cory Johns - 2012-06-20
    • status: code-review --> closed
     
  • Cory Johns - 2012-06-20

    Perfect

     
  • Cory Johns - 2012-06-22
    • milestone: forge-backlog --> forge-jun-29
     

Log in to post a comment.