gitlab-rake gitlab:shell:create_hooks - Not a directory @ realpath_rec
Summary
Not impacting us that we know, but noticed that on our instance (just converted from MySQL+Source to Docker/Omnibus) - running this task fails with this trace:
root@git-dkr-p1:~ $ docker exec -it gitlab gitlab-rake gitlab:shell:create_hooks
Creating/Repairing hooks symlinks for all repositories
Traceback (most recent call last):
8: from /opt/gitlab/embedded/service/gitlab-shell/bin/create-hooks:40:in `<main>'
7: from /opt/gitlab/embedded/service/gitlab-shell/bin/create-hooks:40:in `each'
6: from /opt/gitlab/embedded/service/gitlab-shell/bin/create-hooks:41:in `block in <main>'
5: from /opt/gitlab/embedded/service/gitlab-shell/bin/create-hooks:41:in `each'
4: from /opt/gitlab/embedded/service/gitlab-shell/bin/create-hooks:43:in `block (2 levels) in <main>'
3: from /opt/gitlab/embedded/service/gitlab-shell/lib/gitlab_metrics.rb:50:in `measure'
2: from /opt/gitlab/embedded/service/gitlab-shell/bin/create-hooks:44:in `block (3 levels) in <main>'
1: from /opt/gitlab/embedded/service/gitlab-shell/bin/create-hooks:21:in `create_hooks'
/opt/gitlab/embedded/service/gitlab-shell/bin/create-hooks:21:in `realpath': Not a directory @ realpath_rec - /var/opt/gitlab/git-data/repositories/FormulaElectric/FE04-Dash.git/refs/heads/FE04-Dash.git/hooks (Errno::ENOTDIR)
done
From what I can see - it looks like it occurs due to that particular user creating a messed up tag/branch name that looks like a repo directory name. While this is a weird/messed up thing to do - the rake task shouldn't choke on it.
Reproduced with gitlab-ce:latest as of 2/28/2019
Steps to reproduce
Create a branch named "blah.git" in a repo, run the rake task.
What is the current bug behavior?
Above trace.
What is the expected correct behavior?
No error.
Possible fixes
The issue is this line in gitlab-shell/bin/create-hooks:
Dir["#{repo_path.chomp('/')}/**/*.git"].each do |repo|
Simplest quick fix - continue in the loop if the repo matches *.git/**/*.git
Edited by 🤖 GitLab Bot 🤖