oliverguenther / openproject-revisions_git

An OpenProject plugin for managing Git repositories through Gitolite.
MIT License
13 stars 4 forks source link

problems with the settings #3

Closed alex1702 closed 10 years ago

alex1702 commented 10 years ago

Hi,

I have the problem that the settings are not apparently taken properly. I have another user set in the options, but in the logs I see "git" as user.

Log output when calling the repository page for a project

Started GET "/projects/test/repository" for 10.44.100.24 at 2014-10-23 23:44:36 +0200
Processing by RepositoriesController#show as HTML
  Parameters: {"project_id"=>"test"}
sudo call with 'git --git-dir repositories/test.git -c core.quotepath=false -c log.decorate=no branch --no-color' returned exit 128. Error was: fatal: Not a git repository: 'repositories/test.git'

sudo call with 'git --git-dir repositories/test.git -c core.quotepath=false -c log.decorate=no log --no-color --encoding=UTF-8 --raw --date=iso --pretty=fuller --reverse --all' returned exit 128. Error was: fatal: Not a git repository: 'repositories/test.git'

sudo call with 'git --git-dir repositories/test.git -c core.quotepath=false -c log.decorate=no ls-tree -l HEAD:' returned exit 128. Error was: fatal: Not a git repository: 'repositories/test.git'

sudo call with 'git --git-dir repositories/test.git -c core.quotepath=false -c log.decorate=no log --no-color --encoding=UTF-8 --raw --date=iso --pretty=fuller -n 10' returned exit 128. Error was: fatal: Not a git repository: 'repositories/test.git'

sudo call with 'git --git-dir repositories/test.git -c core.quotepath=false -c log.decorate=no tag' returned exit 128. Error was: fatal: Not a git repository: 'repositories/test.git'

sudo call with 'git --git-dir repositories/test.git -c core.quotepath=false -c log.decorate=no tag' returned exit 128. Error was: fatal: Not a git repository: 'repositories/test.git'

  Rendered repositories/_navigation.html.erb (326.4ms)
  Rendered /home/openproject/.rvm/gems/ruby-2.1.3/bundler/gems/openproject-revisions_git-2fda32b8d1b3/app/views/repositories/show.html.erb within layouts/base (327.0ms)
Completed 500 Internal Server Error in 974.2ms

ActionView::Template::Error (undefined method 'length' for true:TrueClass):
    44:       <%= l(:label_branch) %>:
    45:       <%= select_tag :branch, options_for_select([''] + @repository.branches,@rev), :id => 'branch' %> |
    46:     <% end -%>
    47: 
    48:     <% if !@repository.tags.nil? && @repository.tags.length > 0 -%>
    49:       <%= l(:label_tag) %>:
    50:       <%= select_tag :tag, options_for_select([''] + @repository.tags,@rev), :id => 'tag' %> |
  app/views/repositories/_navigation.html.erb:47:in 'block (2 levels) in _app_views_repositories__navigation_html_erb__1569265889253554907_70338870420680'
  app/views/repositories/_navigation.html.erb:41:in 'block in _app_views_repositories__navigation_html_erb__1569265889253554907_70338870420680'
  app/views/repositories/_navigation.html.erb:34:in '_app_views_repositories__navigation_html_erb__1569265889253554907_70338870420680'
  app/controllers/repositories_controller.rb:101:in 'show'

The output of the settings ConfigTest page:

OpenProject username    openproject
Gitolite username   openproject
Redmine user is able to sudo to Git user?   Redmine user is able to sudo to Git user?
Git version     1.9.1
Gitolite version    true

Gitolite banner

Error while getting Gitolite banner: ScmException(ssh) -> Non-zero exit code pid 24930 exit 255 for `ssh -T -o BatchMode=yes git@localhost -p 22 -i /home/openproject/.ssh/id_rsa info`

PATH directories

/home/openproject/.rvm/gems/ruby-2.1.3/bin
/home/openproject/.rvm/gems/ruby-2.1.3@global/bin
/home/openproject/.rvm/rubies/ruby-2.1.3/bin
/home/openproject/bin
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/home/openproject/.rvm/bin

Thanks for your help. And sorry for my bad english. xD

oliverguenther commented 10 years ago

It seems that gitolite isn't running correctly or not set up to use from openproject. This would result in the project 'test.git' to not be created through OpenProject and thus it fails to display it.

You need a correctly set up gitolite that runs as a seperate user than openproject (you specified the gitolite user as openproject, which will not work.

Ensure you've followed all steps in the installation tutorial and execute the following commands on the shell, as the user running openproject.

I'm assuming your gitolite user is named git, if its named otherwise, you'll need to update the following commands respectively

  1. openproject$ sudo -n -i -u git ls repositories should display all repositories located under the gitolite user's $HOME/repositories.
  2. openproject$ ssh -i git@localhost info
    hello openproject, this is git@dev running gitolite3 v3.x-x on git x.x.x.
        R W  gitolite-admin
        R W  testing

If these commands both work fine, please show me your revisions_git configuration.

alex1702 commented 10 years ago

ok, now i have the user "opgit" and the commands works. the configtest shows the same error

OpenProject username    openproject
Gitolite username   opgit
Redmine user is able to sudo to Git user?   Redmine user is able to sudo to Git user?
Git version     1.9.1
Gitolite version    true

Gitolite banner

Error while getting Gitolite banner: ScmException(ssh) -> Non-zero exit code pid 24930 exit 255 for `ssh -T -o BatchMode=yes git@localhost -p 22 -i /home/openproject/.ssh/id_rsa info`

PATH directories

/home/openproject/.rvm/gems/ruby-2.1.3/bin
/home/openproject/.rvm/gems/ruby-2.1.3@global/bin
/home/openproject/.rvm/rubies/ruby-2.1.3/bin
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/home/openproject/.rvm/bin

output of sudo -n -i -u opgit ls repositories:

openproject@elaon:~$ sudo -n -i -u opgit ls repositories
gitolite-admin.git  testing.git

and ssh -i ~/.ssh/openproject opgit@localhost info:

openproject@elaon:~$ ssh -i ~/.ssh/openproject opgit@localhost info
hello openproject, this is opgit@elaon running gitolite3 v3.6.1-6-gdc8b590 on git 1.9.1

 R W    gitolite-admin
 R W    testing
oliverguenther commented 10 years ago

Ah, yes. The config tests are cached through Rails.cache, you can clear them through rake tmp:clear, or get the latest commit (bb9d3cd10912faf82d6f512d0db07ba4e1bbb0b5) which fixes just that.

alex1702 commented 10 years ago

ok, so the problem is solved with the configtest. But apparently he created me no repositories, if I do the settings under project settings. Settings:

Gitolite Storage Configuration

Gitolite Admin repository: /home/opgit/repositories/gitolite-admin.git/
Location of the Gitolite Admin repository

Gitolite repositories base path: home/opgit/repositories/
(Relative to Gitolite user home) 

error log when I create the git repo in project settings:

Started POST "/repositories/edit/test" for 80.133.31.108 at 2014-10-24 18:31:08 +0200
Processing by RepositoriesController#edit as JS
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"EUyoR55eJIDhv3/6QVw60GuLEYT1Uu0/lUwYoOH3nP4=", "repository_scm"=>"Git", "repository"=>{"extra_attributes"=>{"git_daemon"=>"0", "git_http"=>"0"}}, "commit"=>"Anlegen", "id"=>"test"}
Automatic initialization of RepositoryGitExtra failed.
Automatic initialization of RepositoryGitExtra failed.
  Rendered /home/openproject/.rvm/gems/ruby-2.1.3/bundler/gems/openproject-revisions_git-2fda32b8d1b3/app/views/projects/settings/_git.html.erb (2.7ms)
  Rendered projects/settings/_repository.html.erb (7.2ms)
User 'admin' created a         new repository 'test'
Creating gitolite action for 'add_repository'
Completed 200 OK in 68.9ms (Views: 27.3ms | ActiveRecord: 19.9ms)
oliverguenther commented 10 years ago

I assume the delayed_jobs worker isn't running. I'll have to add this to the installation tutorial to ensure it is loaded, as the plugin relies on it for all I/O access.

Try RAILS_ENV=production script/delayed_job start.

/edit: I've updated the installation tutorial: https://github.com/oliverguenther/openproject-revisions_git/blob/dev/README.md#4-starting-delayed_jobs

alex1702 commented 10 years ago

hmm, now i get permission errors. has the plugin directly access to the folder?

Running delayed job 'delete_repositories'
Acessing gitolite-admin.git at '/home/opgit/repositories/gitolite-admin.git/'
2014-10-24T18:44:24+0200: [Worker(delayed_job host:elaon.de pid:6990)] OpenProject::Revisions::Git::GitoliteWrapper::Repositories#run_without_delay failed with Rugged::OSError: Failed to make directory '/home/opgit/repositories/gitolite-admin.git': Permission denied - 3 failed attempts
oliverguenther commented 10 years ago

The gitolite-admin.git must be cloned locally using the openproject user. This is due to the fact that openproject acts on the (cloned) gitolite-admin.git repository and commits changes to gitolite, which then adds the project and sets up any ssh keys configured with it.

This is part of the preliminary setup for this plugin (cite: you have successfully cloned the gitolite-admin.git repository from the user running OpenProject.) In my setup this worked as follows:

  1. git clone ssh://git@localhost:gitolite-admin /home/openproject/gitolite-admin.git
  2. Change the setting Gitolite Admin repository of OpenProject Revisions/Git to that path /home/openproject/gitolite-admin.git
  3. Try again.
alex1702 commented 10 years ago
Running delayed job 'add_repository'
Acessing gitolite-admin.git at '/home/openproject/gitolite-admin.git/'
2014-10-24T19:14:47+0200: [Worker(delayed_job host:elaon.de pid:6990)] OpenProject::Revisions::Git::GitoliteWrapper::Repositories#run_without_delay failed with Rugged::NetworkError: This transport isn't implemented. Sorry - 3 failed attempts
2014-10-24T19:14:47+0200: [Worker(delayed_job host:elaon.de pid:6990)] 2 jobs processed at 19.2750 j/s, 2 failed ...
oliverguenther commented 10 years ago

Aha , one step further :laughing: You need to rebuild libgit2/rugged with SSH support, see this issue: https://github.com/libgit2/rugged/issues/299

Under Debian/Ubuntu this currently is libssh2.1-dev. Simple reinstall the rugged gem afterwards:

$ gem uninstall foo
$ bundle update

I'll have another thing to add to the preliminary step of the tutorial ;)