gitlabhq/gitlabhq — Issue #220: Unable to Save Public Key with Large Number of Repos
Author: mutewinter
Created: 2011-12-20 14:17:46+00:00
State: open

With a large number of repos (> 100), saving a pubic key fails. This is due to the timeout in the `Gitlabhq::Gitolite.configure` method being too short.

Here's the [responsible code](https://github.com/gitlabhq/gitlabhq/blob/master/lib/gitlabhq/gitolite.rb#L27)

```ruby
def configure
status = Timeout::timeout(20) do
File.open(File.join(Dir.tmpdir,"gitlabhq-gitolite.lock"), "w+") do |f|
begin
f.flock(File::LOCK_EX)
pull
yield(self)
push
ensure
f.flock(File::LOCK_UN)
end
end
end
rescue Exception => ex
raise Gitolite::AccessDenied.new("gitolite timeout")
end
```

The problem is that this fails silently because the Gitolite error page is returned to the POST request initiated by JavaScript. Here's the error returned from the POST at /keys

```html

We're sorry, but we cant get access to your gitosis

Gitolite Error

We're sorry, but we cant get access to your gitolite system.

1. Check 'config/gitlab.yml' for correct settings.

2. Be sure web server user has access to gitolite.

```

This error message is only visible when running Chrome Developer Tools with the Network tab loaded. Selecting the POST request after the 20 second timeout displays the above error html.

The temporary solution to this problem is to increase the timeout to allow for the update_project method to finish being called for all 200 projects. The long term solution would be some sort of background job system so that the updates take place off the web request thread.