2013年11月28日木曜日

GitLab6系でMerge Requestが作れない

実際に使ってるのはGitLab6.2.4ですが。

えーと、GitLabで普通にMerge Requestを作ってみようとしたんだけど、
Source Brancheとしてさっきコミットしたブランチが表示されない。
というか、リポジトリ作成してから始めて作ったブランチと、
masterおよびdevelopくらいしか表示されてない。

よく見ると、commitsのページでも存在してるはずのブランチが選択出来ない状態。
どうもドロップダウンに全く反映されていない様子。

なにこれ?と思ってググったところ、
https://github.com/gitlabhq/gitlabhq/issues/4864
これが見つかった。
この中のこの投稿
I checked on various projects and it seems that all of them a broken now, If I push a new branch to any of them, it is never displayed, not in the project home page (as a link to create a new MR), not in the branch dropdown in Commits tab and not in the MR branch dropdown (which I guess is probably the same a in the Commits tab).
It seems to be a cache issue because when I cleared the cache (cd /home/git/gitlab && sudo -u git -H bundle exec rake cache:clear RAILS_ENV=production), the branch is now correctly shown in the dropdown menu.
I will make more test to check what goes on.
Where is the code for this dropdown, maybe I could tried to debug it on my setup?
ここに書いて有るとおり、railsのキャッシュをクリアするとちゃんと表示されるようになった。
え、まさかいちいちキャッシュクリアしないと反映されないとかじゃないよね…。
と思って続きを見ていって見る。

Clearing cache works because everything is generated on the first run thereafter, but any new commits afterwards will still not appear, because they are not processed. So my hunch would still be that the update hook doesn't work as intended.
Good idea would be to check all possible logs as well - maybe the hook does fire, but there is an internal error processing it.
ああうん。やっぱそうだよね。
キャッシュをクリアした後、一回全部作り直されるからちゃんと動いたように見えるが、
updateのフックがパーミッションの関係でちゃんと実行されてないので、
それ以降のブランチはやっぱり反映されないってか。

このトピックを読んでいくと、要点は以下の様な感じ。


  • キャッシュクリアすれば直る。
  • redisとgitlabを再起動しても直るし、しばらくは再現しなくなる。
  • しばらくすると再現するようになる。
  • 5.4でも同じようなバグがあり、とりあえずキャッシュクリアでなんとかしてた。
  • リポジトリのhooksからgitlab-shellへのリンクがおかしい場合も起こるが、これはリンクを正しくすれば直る。
  • gitlab-shellからredisへ接続する情報に関しても確認が必要。
  • 6.0時点でキャッシュクリアによって再現しなくなったが、6.1にupgradeしたら再現した。
  • 今の時点でもこのIssueは閉じられていない(完全には解決してない)


とりあえずのwork aroundとしては

  • キャッシュクリアする
  • gitlab関係を全部再起動する


で症状は治まるっぽい。
しばらく様子を見て、最悪cronでキャッシュクリアを回すしか無いか…。