Svn remote import error - Failed to dump the remote repository


#1

Hello:

I am using:

 - NAME: community-1
 - STATUS: RUNNING
   logs:/home/user/.rccontrol/community-1/community.log
 - VERSION: 4.13.1 Community
 - VCS: vcsserver-1
 - URL: http://0.0.0.0:10020

 - NAME: vcsserver-1
 - STATUS: RUNNING
   logs:/home/user/.rccontrol/vcsserver-1/vcsserver.log
 - VERSION: 4.13.1 VCSServer
 - URL: http://127.0.0.1:10010

I am trying to import a SVN remote respository. I am not sure if it is possible or not.

When I am doing that it said:

Traceback (most recent call last):
File “/opt/rhodecode/store/byf8dqp9k5ji1hmh68cjja2s993rb889-python2.7-rhodecode-vcsserver-4.13.1/lib/python2.7/site-packages/vcsserver/http_main.py”, line$
resp = getattr(remote, method)(*args, **kwargs)
File “/opt/rhodecode/store/byf8dqp9k5ji1hmh68cjja2s993rb889-python2.7-rhodecode-vcsserver-4.13.1/lib/python2.7/site-packages/vcsserver/svn.py”, line 382, reason) Exception: ('Failed to dump the remote repository from http://user:password@svn/repos/testProject

I have read that it is using svnadmin (and I saw in svn.py line 382) so it is not possible to import a repository that is not in the same server using http. Is it possible? Am I doing something wrong?

Thank you very much.


#2

You can import remote repository.

As you pointed out there are two commands used:

        rdump = subprocess.Popen(
            ['svnrdump', 'dump', '--non-interactive', src_url],
            stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        load = subprocess.Popen(
            ['svnadmin', 'load', repo_path], stdin=rdump.stdout)

Before that there’s a error log: 'svnrdump dump failed: statuscode %s: message: %s'
Can you look for that in /home/user/.rccontrol/community-1/community.log


#3

Hello:

Thank you very much for your fast answer.

2018-09-14 06:22:37.625 [1695] INFO  [rhodecode.model.repo] Removing repository /home/user/repos/test
2018-09-14 06:22:37.635 [1695] INFO  [rhodecode.task.create_repo] Cleanup of repo test finished
2018-09-14 06:22:37.636 [1695] ERROR [rhodecode.apps._base] Exception creating a repository
Traceback (most recent call last):
  File "/opt/rhodecode/store/fprkw03six5j8rihml3ckn4cddhhyy7v-python2.7-rhodecode-enterprise-ce-4.13.1/lib/python2.7/site-packages/rhodecode/apps/admin/views/repositories.py", line 159, in repository_create
    task = RepoModel().create(form_result, self._rhodecode_user.user_id)
  File "/opt/rhodecode/store/fprkw03six5j8rihml3ckn4cddhhyy7v-python2.7-rhodecode-enterprise-ce-4.13.1/lib/python2.7/site-packages/rhodecode/model/repo.py", line 520, in create
    return run_task(tasks.create_repo, form_data, cur_user)
  File "/opt/rhodecode/store/fprkw03six5j8rihml3ckn4cddhhyy7v-python2.7-rhodecode-enterprise-ce-4.13.1/lib/python2.7/site-packages/rhodecode/lib/celerylib/__init__.py", line 69, in run_task
    return ResultWrapper(task(*args, **kwargs))
  File "/opt/rhodecode/store/qzc4qngwq5via2wm9fqywgzwqqanjw70-python2.7-celery-4.1.1/lib/python2.7/site-packages/celery/local.py", line 193, in __call__
    return self._get_current_object()(*a, **kw)
  File "/opt/rhodecode/store/fprkw03six5j8rihml3ckn4cddhhyy7v-python2.7-rhodecode-enterprise-ce-4.13.1/lib/python2.7/site-packages/rhodecode/lib/celerylib/loader.py", line 286, in __call__
    return super(RequestContextTask, self).__call__(*args, **kwargs)
  File "/opt/rhodecode/store/qzc4qngwq5via2wm9fqywgzwqqanjw70-python2.7-celery-4.1.1/lib/python2.7/site-packages/celery/app/task.py", line 379, in __call__
    return self.run(*args, **kwargs)
  File "/opt/rhodecode/store/fprkw03six5j8rihml3ckn4cddhhyy7v-python2.7-rhodecode-enterprise-ce-4.13.1/lib/python2.7/site-packages/rhodecode/lib/celerylib/tasks.py", line 149, in create_repo
    clone_uri=clone_uri,
  File "/opt/rhodecode/store/fprkw03six5j8rihml3ckn4cddhhyy7v-python2.7-rhodecode-enterprise-ce-4.13.1/lib/python2.7/site-packages/rhodecode/model/repo.py", line 865, in _create_filesystem_repo
    repo_path, config=config, create=True, src_url=clone_uri)
  File "/opt/rhodecode/store/fprkw03six5j8rihml3ckn4cddhhyy7v-python2.7-rhodecode-enterprise-ce-4.13.1/lib/python2.7/site-packages/rhodecode/lib/vcs/backends/svn/repository.py", line 76, in __init__
    self._init_repo(create, src_url)
  File "/opt/rhodecode/store/fprkw03six5j8rihml3ckn4cddhhyy7v-python2.7-rhodecode-enterprise-ce-4.13.1/lib/python2.7/site-packages/rhodecode/lib/vcs/backends/svn/repository.py", line 92, in _init_repo
    self._remote.import_remote_repository(src_url)
  File "/opt/rhodecode/store/fprkw03six5j8rihml3ckn4cddhhyy7v-python2.7-rhodecode-enterprise-ce-4.13.1/lib/python2.7/site-packages/rhodecode/lib/vcs/client_http.py", line 126, in f
    return self._call(name, *args, **kwargs)
  File "/opt/rhodecode/store/fprkw03six5j8rihml3ckn4cddhhyy7v-python2.7-rhodecode-enterprise-ce-4.13.1/lib/python2.7/site-packages/rhodecode/lib/vcs/client_http.py", line 146, in _call_with_logging
    return RemoteRepo._call(self, name, *args, **kwargs)
  File "/opt/rhodecode/store/fprkw03six5j8rihml3ckn4cddhhyy7v-python2.7-rhodecode-enterprise-ce-4.13.1/lib/python2.7/site-packages/rhodecode/lib/vcs/exceptions.py", line 181, in wrapper
    return func(*args, **kwargs)
  File "/opt/rhodecode/store/fprkw03six5j8rihml3ckn4cddhhyy7v-python2.7-rhodecode-enterprise-ce-4.13.1/lib/python2.7/site-packages/rhodecode/lib/vcs/client_http.py", line 140, in _call
    return _remote_call(self.url, payload, EXCEPTIONS_MAP, self._session)
  File "/opt/rhodecode/store/fprkw03six5j8rihml3ckn4cddhhyy7v-python2.7-rhodecode-enterprise-ce-4.13.1/lib/python2.7/site-packages/rhodecode/lib/vcs/client_http.py", line 237, in _remote_call
    raise exc
Exception
 +--- This exception occured remotely on VCSServer - Remote traceback:

Traceback (most recent call last):
  File "/opt/rhodecode/store/byf8dqp9k5ji1hmh68cjja2s993rb889-python2.7-rhodecode-vcsserver-4.13.1/lib/python2.7/site-packages/vcsserver/http_main.py", line 306, in vcs_view
    resp = getattr(remote, method)(*args, **kwargs)
  File "/opt/rhodecode/store/byf8dqp9k5ji1hmh68cjja2s993rb889-python2.7-rhodecode-vcsserver-4.13.1/lib/python2.7/site-packages/vcsserver/svn.py", line 382, in import_remote_repository
    reason)
Exception: ('Failed to dump the remote repository from http://user:password@svn/repos/test.', 'UNKNOWN')

This is the complete output. I don´t see that it fails.


#4

Those should be in vcsserver.log actually, sorry i forgot to mention that


#5

Hello:

svnadmin: E200003: Premature end of content data in dumpstream
2018-09-14 06:22:37.430 [1684] ERROR [vcsserver.svn] svnrdump dump failed: statuscode 1: message: svnrdump: E170013: Unable to connect to a repository at URL 'http://user:pwd@svn/repos/test'
svnrdump: E215004: No more credentials or we tried too many times.
Authentication failed

There is a problem with the authentication. I am accessing as http.//suer:pwd@RepoUrl. Using a webbrowser I am able to access but here it says it is not posible. Could you let me know how to access to the repo with credentials properly?. It is not possible to disable them.

Thank you for your help and fast answer.


#6

I believe this could be an problem on our side. the svnrdump doesn’t handle auth correctly via url.

We should change the logic and provide explicit ['--username', username, '--password', password] in addition to current cmd.


#7

In case you’re interested here’s a patch for svn.py that should enable import from auth based url:

diff --git a/vcsserver/svn.py b/vcsserver/svn.py
--- a/vcsserver/svn.py
+++ b/vcsserver/svn.py
@@ -13,17 +13,19 @@
 #
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software Foundation,
 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA

 from __future__ import absolute_import

 import os
+import subprocess
 from urllib2 import URLError
+import urlparse
 import logging
 import posixpath as vcspath
 import StringIO
 import urllib
 import traceback

 import svn.client
 import svn.core
@@ -345,25 +347,37 @@ class SvnRemote(object):
         size = svn.fs.file_length(root, path)
         return size

     def create_repository(self, wire, compatible_version=None):
         log.info('Creating Subversion repository in path "%s"', wire['path'])
         self._factory.repo(wire, create=True,
                            compatible_version=compatible_version)

+    def get_url_and_credentials(self, src_url):
+        obj = urlparse.urlparse(src_url)
+        username = obj.username or None
+        password = obj.password or None
+        return username, password, src_url
+
     def import_remote_repository(self, wire, src_url):
         repo_path = wire['path']
         if not self.is_path_valid_repository(wire, repo_path):
             raise Exception(
                 "Path %s is not a valid Subversion repository." % repo_path)

-        import subprocess
+        username, password, src_url = self.get_url_and_credentials(src_url)
+        rdump_cmd = ['svnrdump', 'dump', '--non-interactive',
+                     '--trust-server-cert-failures=unknown-ca']
+        if username and password:
+            rdump_cmd += ['--username', username, '--password', password]
+        rdump_cmd += [src_url]
+
         rdump = subprocess.Popen(
-            ['svnrdump', 'dump', '--non-interactive', src_url],
+            rdump_cmd,
             stdout=subprocess.PIPE, stderr=subprocess.PIPE)
         load = subprocess.Popen(
             ['svnadmin', 'load', repo_path], stdin=rdump.stdout)

         # TODO: johbo: This can be a very long operation, might be better
         # to track some kind of status and provide an api to check if the
         # import is done.
         rdump.wait()