Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error transferring project #66

Closed
logicminds opened this issue Jan 21, 2015 · 17 comments
Closed

error transferring project #66

logicminds opened this issue Jan 21, 2015 · 17 comments

Comments

@logicminds
Copy link
Contributor

I am not sure why this is happening. But when I add new projects, gitlab-mirrors clone the remote repo and create a project in the gitmirror users namespace in gitlab but fails to transfer the project and push the mirrored code. Any ideas how to fix this?

E, [2015-01-21T12:10:13.771207 #31781] ERROR -- : Resolving gitlab remote.
Traceback (most recent call last):
  File "lib/manage_gitlab_project.py", line 109, in <module>
    found_project=createproject(project_name)
  File "lib/manage_gitlab_project.py", line 98, in createproject
    new_project=git.group(found_group.id).transfer_project(new_project.id)
AttributeError: 'bool' object has no attribute 'id'
There was an unknown issue with manage_gitlab_project.py

@samrocketman
Copy link
Owner

Sounds like you didn't make the GitLab user gitmirrors a GitLab Administrator. I also need more info about what versions of the software you're using (GitLab, gitlab-mirrors, python-gitlab3, etc).

@logicminds
Copy link
Contributor Author

@samrocketman

just getting back to this.

gitlab-mirrors: 0.5.0
OS: oel 6.5
GitLab 7.1.1 facfec4
python-gitlab3: 0.5.4 (via pip)
python 2.6.6

@samrocketman
Copy link
Owner

What does your gitlab logs say about this? Is your gitmirrors user in GitLab an Administrator?

See Using your own user; it details what happens when you attempt to use a user that is not an Administrator.

@logicminds
Copy link
Contributor Author

I, [2015-02-02T16:40:09.608846 #1745]  INFO -- : Adding mirror https://github.com/biemond/biemond-orawls.git
I, [2015-02-02T16:40:09.609007 #1745]  INFO -- : /home/gitmirror/gitlab-mirrors/add_mirror.sh --git --project-name biemond-orawls --mirror https://github.com/biemond/biemond-orawls.git 2>&1
E, [2015-02-02T16:40:09.609048 #1745] ERROR -- : Resolving gitlab remote.
Traceback (most recent call last):
  File "lib/manage_gitlab_project.py", line 109, in <module>
    found_project=createproject(project_name)
  File "lib/manage_gitlab_project.py", line 95, in createproject
    new_project=git.add_project(pname,description=description,**project_options)
  File "/usr/lib/python2.6/site-packages/gitlab3/__init__.py", line 184, in fn
    data = parent._post(api._uq_url, data=kwargs)
  File "/usr/lib/python2.6/site-packages/gitlab3/__init__.py", line 418, in _post
    return self._request(requests.post, api_url, addl_keys, data)
  File "/usr/lib/python2.6/site-packages/gitlab3/__init__.py", line 435, in _request
    self._check_status_code(r.status_code, url, data)
  File "/usr/lib/python2.6/site-packages/gitlab3/__init__.py", line 411, in _check_status_code
    raise self._code_to_exc[status_code](msg)
gitlab3.exceptions.ResourceNotFound: URL: http://git.corp.ositax.com/api/v3/projects, Data: {'wall_enabled': 'false', 'snippets_enabled': 'false', 'merge_requests_enabled': 'false', 'name': 'biemond-orawls', 'issues_enabled': 'false', 'wiki_enabled': 'false', 'public': 'true', 'description': 'Mirror of https://github.com/biemond/biemond-orawls.git'}

The user does have full admin access.
Also the logs at the top are from my ruby script.

@logicminds
Copy link
Contributor Author

I think what needs to happen is in the lib/manage_gitlab_project.py script you need to check to see if a local project exists first. If it does exist that it needs to be transferred to the destination group. The manual fix for this is to transfer the gitmirror's project to the destination group.

@samrocketman
Copy link
Owner

I think what needs to happen is in the lib/manage_gitlab_project.py script you need to check to see if a local project exists first. If it does exist that it needs to be transferred to the destination group.

That's not a bad idea. There might be a way to obtain from the GitLab API whether or not the user is an admin as well. It would be good to give a helpful message and gracefully exit for that as well.

@samrocketman
Copy link
Owner

I'll label this as an enhancement because it's possible for the add_mirror.sh to quit halfway through in which it only needs to complete the action later.

@samrocketman
Copy link
Owner

The latest API supports looking up if a single user is an admin. The logic of that would be something along the lines of:

#variable x is a returned user entry from the GitLab api (a python dictionary)
if (not 'is_admin' in x) or ('is_admin' in x and (not x['is_admin'])):
  print "The gitmirrors user is not an admin"

From there we could do additional checking. If gitlab_namespace != gitlab_user in config.sh when the user is not an administrator then output the warning. Additionally, do not try to create a project and transfer it but instead exit with an error when a non-Admin user tries to create a project in a namespace that is not their user.

@samrocketman
Copy link
Owner

Actually, that non-sense logic is no longer required. In old versions of GitLab, you could only create projects under your own user. However, in the latest GitLab API documentation you can pass in the parameter namespace_id which creates said project within that namespace. That would be best.

Doesn't look like python-gitlab3 supports the latest API interfaces for GitLab. A feature request will need to be opened with the upstream library. Either that or adopt a new library that is maintained.

@samrocketman
Copy link
Owner

In summary the resolution for this is: adopt the new GitLab API and use the namespace_id when creating a project. That would mean the gitmirrors user will no longer be required to be an Administrator. Administrator was only required because of the transfer project limitation. So looks like we can kill two birds with one stone on that one.

@logicminds
Copy link
Contributor Author

or just dump the python/bash script and create a wrapper around this:

https://github.com/NARKOZ/gitlab

@samrocketman
Copy link
Owner

Yeah, before that I'd have to figure out how to do ruby things like a gem. We could just categorize this with the rewrite. ref link #63.

@samrocketman samrocketman modified the milestone: gitlab-mirrors 0.6 Feb 3, 2015
@samrocketman samrocketman removed this from the gitlab-mirrors 0.6 milestone Mar 25, 2015
@ghost
Copy link

ghost commented Jun 18, 2015

Really love the work here. Any chance there is any updates on either the transferring project error or ruby rewrite?

@samrocketman
Copy link
Owner

No updates at the moment in either space. But I think I can slice some time to work on getting it to work with the latest version of GitLab. Currently the library used to talk with GitLab has largely been abandoned. Just need to change the library to pyapi-gitlab which is currently maintained to the latest version of GitLab last I checked.

@ghost
Copy link

ghost commented Jun 22, 2015

That sounds awesome, and that should also make future maintenance more efficient. Smart approach!

@logicminds
Copy link
Contributor Author

Ok, trying to resolve this again with a newer version of gitlab. I have rewritten some code but there still seems to be an issue with gitlab and transferring projects. I then stumbled upon https://gitlab.com/gitlab-org/gitlab-ce/issues/1522. Seems to me that once this issue is fixed, the transfer project work.

logicminds added a commit to logicminds/gitlab-mirrors that referenced this issue Jul 15, 2015
  * this attempts to fix the issue however
    the problem is now a gitlab api issue
    https://gitlab.com/gitlab-org/gitlab-ce/issues/1522
logicminds added a commit to logicminds/gitlab-mirrors that referenced this issue Jul 15, 2015
  * this attempts to fix the issue however
    the problem is now a gitlab api issue
    https://gitlab.com/gitlab-org/gitlab-ce/issues/1522
  * fixes the creation of the project in the correct namespace
    thus doesn't need to transfer the project
logicminds added a commit to logicminds/gitlab-mirrors that referenced this issue Jul 15, 2015
  * this attempts to fix the issue however
    the problem is now a gitlab api issue
    https://gitlab.com/gitlab-org/gitlab-ce/issues/1522
  * fixes the creation of the project in the correct namespace
    thus doesn't need to transfer the project
logicminds added a commit to logicminds/gitlab-mirrors that referenced this issue Jul 15, 2015
  * this attempts to fix the issue however
    the problem is now a gitlab api issue
    https://gitlab.com/gitlab-org/gitlab-ce/issues/1522
  * fixes the creation of the project in the correct namespace
    thus doesn't need to transfer the project
logicminds added a commit to logicminds/gitlab-mirrors that referenced this issue Jul 15, 2015
  * this attempts to fix the issue however
    the problem is now a gitlab api issue
    https://gitlab.com/gitlab-org/gitlab-ce/issues/1522
  * fixes the creation of the project in the correct namespace
    thus doesn't need to transfer the project
samrocketman added a commit that referenced this issue Jul 17, 2015
fixes #66 - error transferring project
@logicminds
Copy link
Contributor Author

https://gitlab.com/gitlab-org/gitlab-ce/issues/1522

Looks like this was just fixed in 7.13 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants