sameersbn / docker-gitlab

Dockerized GitLab
http://www.damagehead.com/docker-gitlab/
MIT License
7.9k stars 2.14k forks source link

Permission denied /var/log/gitlab/gitlab-shell/gitlab-shell.log (Errno::EACCES) #1022

Open SebaBoler opened 7 years ago

SebaBoler commented 7 years ago

i created container Gitlab with parametres volume

... --volume /share/VM/container-station-data/gitlab/data:/home/git/data \ --volume /share/VM/container-station-data/gitlab/log/:/var/log/gitlab \

and created folders on my NAS with chmod 664 image

Why i get error on console ?? I dont have more idea. I see only one problem with script why he trying read from /home/git/gitlab-shell when folder /var/log/gitlab

Migrating to MigrateToNewShell (20140903115954)
/usr/lib/ruby/2.3.0/logger.rb:703:in initialize': Permission denied @ rb_sysopen - /var/log/gitlab/gitlab-shell/gitlab-shell.log (Errno::EACCES) from /usr/lib/ruby/2.3.0/logger.rb:703:inopen'
from /usr/lib/ruby/2.3.0/logger.rb:703:in open_logfile' from /usr/lib/ruby/2.3.0/logger.rb:695:inset_dev'
from /usr/lib/ruby/2.3.0/logger.rb:635:in initialize' from /usr/lib/ruby/2.3.0/logger.rb:353:innew'
from /usr/lib/ruby/2.3.0/logger.rb:353:in initialize' from /home/git/gitlab-shell/lib/gitlab_logger.rb:15:innew'
from /home/git/gitlab-shell/lib/gitlab_logger.rb:15:in <top (required)>' from /home/git/gitlab-shell/lib/gitlab_projects.rb:6:inrequire_relative'
from /home/git/gitlab-shell/lib/gitlab_projects.rb:6:in <top (required)>' from /home/git/gitlab-shell//bin/create-hooks:8:inrequire'
from /home/git/gitlab-shell//bin/create-hooks:8:in `

'
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

solidnerd commented 7 years ago

Hey, you could start your GitLab container with DEBUG=true and see the complete output. Probably it could be a permission problem. But our container sets the correct permission on the first initialize otherwise you can do it by hand with docker run ..... sameersbn/gitlab:8.14.5 app:sanitize

SebaBoler commented 7 years ago

Initializing logdir... Initializing datadir... Installing configuration templates... Configuring gitlab... Configuring gitlab::database Configuring gitlab::redis Configuring gitlab::secrets... Configuring gitlab::sidekiq... Configuring gitlab::gitlab-workhorse... Configuring gitlab::unicorn... Configuring gitlab::timezone... Configuring gitlab::rack_attack... Configuring gitlab::ci... Configuring gitlab::artifacts... Configuring gitlab::lfs... Configuring gitlab::project_features... Configuring gitlab::oauth... Configuring gitlab::ldap... Configuring gitlab::backups... Configuring gitlab::registry... Configuring gitlab-shell... Configuring nginx... Configuring nginx::gitlab... Migrating database... Rails Error: Unable to access log file. Please ensure that /home/git/gitlab/log/production.log exists and is writable (ie, make it writable for user and group: chmod 0664 /home/git/gitlab/log/production.log). The log level has been raised to WARN and the output directed to STDERR until the problem is fixed. ** [Raven] Raven 2.0.2 configured not to capture errors. Migrating to MigrateToNewShell (20140903115954) /usr/lib/ruby/2.3.0/logger.rb:703:ininitialize': Permission denied @ rb_sysopen - /var/log/gitlab/gitlab-shell/gitlab-shell.log (Errno::EACCES)
from /usr/lib/ruby/2.3.0/logger.rb:703:in open' from /usr/lib/ruby/2.3.0/logger.rb:703:inopen_logfile'
from /usr/lib/ruby/2.3.0/logger.rb:695:in set_dev' from /usr/lib/ruby/2.3.0/logger.rb:635:ininitialize'
from /usr/lib/ruby/2.3.0/logger.rb:353:in new' from /usr/lib/ruby/2.3.0/logger.rb:353:ininitialize'
from /home/git/gitlab-shell/lib/gitlab_logger.rb:15:in new' from /home/git/gitlab-shell/lib/gitlab_logger.rb:15:in<top (required)>'
from /home/git/gitlab-shell/lib/gitlab_projects.rb:6:in require_relative' from /home/git/gitlab-shell/lib/gitlab_projects.rb:6:in<top (required)>'
from /home/git/gitlab-shell//bin/create-hooks:8:in require' from /home/git/gitlab-shell//bin/create-hooks:8:in

'
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

Failed to rewrite gitlab-shell hooks in repositories/home/git/gitlab/db/migrate/20140903115954_migrate_to_new_shell.rb:10:in change' /home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:608:inexec_migration' /home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:592:in block (2 levels) in migrate' /home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:591:inblock in migrate'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:292:in with_connection' /home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:590:inmigrate'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:768:in migrate' /home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:998:inblock in execute_migration_in_transaction'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:1044:in block in ddl_transaction' /home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/database_statements.rb:213:inblock in transaction'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/transaction.rb:184:in within_new_transaction' /home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/database_statements.rb:213:intransaction'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/transactions.rb:220:in transaction' /home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:1044:inddl_transaction'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:997:in execute_migration_in_transaction' /home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:959:inblock in migrate'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:955:in each' /home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:955:inmigrate'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:823:in up' /home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:801:inmigrate'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:137:in migrate' /home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/railties/databases.rake:44:inblock (2 levels) in <top (required)>' Failed to rewrite gitlab-shell hooks in repositories
/home/git/gitlab/db/migrate/20140903115954_migrate_to_new_shell.rb:10:in change' /home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:608:inexec_migration'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:592:in block (2 levels) in migrate' /home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:591:inblock in migrate'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:292:in with_connection' /home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:590:inmigrate'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:768:in migrate' /home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:998:inblock in execute_migration_in_transaction'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:1044:in block in ddl_transaction' /home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/database_statements.rb:213:inblock in transaction'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/transaction.rb:184:in within_new_transaction' /home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/database_statements.rb:213:intransaction'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/transactions.rb:220:in transaction' /home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:1044:inddl_transaction'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:997:in execute_migration_in_transaction' /home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:959:inblock in migrate'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:955:in each' /home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:955:inmigrate'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:823:in up' /home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:801:inmigrate'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:137:in migrate' /home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/railties/databases.rake:44:inblock (2 levels) in <top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace) `

r2evans commented 7 years ago

@SebaBoler, not certain if they will help: since your log directory is mapped from the host, then the numeric owner id on the host needs to be mapped internally to the container. This image uses USERMAP_UID (and USERMAP_GID (Host UID/GID Mapping). So,

  1. if you have previously set those two variables and are not this time, then you will need to change ownership to 1000:1000 (the defaults) or re-set those variables;
  2. if the host's idea of uid/gid has changed, then you might need to map or change the mapping for them;
  3. can you confirm that the host is not running any added security (beyond simple unix perms)?

This is what I have in my running container:

root@ace47e405b11:/var/log/gitlab# find gitlab* -type f -iname '*log' -ls
10100872  360 -rw-r--r--   1 git      git        364115 Dec 19 12:50 gitlab/production.log
10101724    4 -rw-r--r--   1 git      git           238 Dec 19 10:46 gitlab/application.log
10100884    4 -rw-r--r--   1 git      git          2275 Dec 19 08:15 gitlab/unicorn.stderr.log
10100885    4 -rw-r--r--   1 git      git            94 Dec 19 10:46 gitlab/unicorn.stdout.log
10100876  364 -rw-r--r--   1 root     root       367993 Dec 19 12:47 gitlab/gitlab-workhorse.log
10100886   56 -rw-r--r--   1 git      git         49549 Dec 19 12:50 gitlab/sidekiq.log
10101725    4 -rw-r--r--   1 git      git          2027 Dec 19 10:54 gitlab-shell/gitlab-shell.log

(I'm not sure why workhorse is root:root ... it's working, though, despite running as user git:

root@ace47e405b11:/var/log/gitlab# ps faxu | grep '[w]orkhorse'
git         589  0.0  0.0 287148 15188 ?        Sl   Dec16   0:12 /usr/local/bin/gitlab-workhorse -listenUmask 0 -listenNetwork tcp -listenAddr :8181 -authBackend http://127.0.0.1:8080/git -authSocket /home/git/gitlab/tmp/sockets/gitlab.socket -documentRoot /home/git/gitlab/public -proxyHeadersTimeout 5m0s

*shrug*)

joaquin386 commented 6 years ago

The solution that I found it to mv /var/log/gitlab and create an empty one, but would be good to know what is the issue.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had any activity for the last 60 days. It will be closed if no further activity occurs during the next 7 days. Thank you for your contributions.

elMor3no commented 4 years ago

I solve this issue using with: # chown 998:998 /var/log/gitlab/gitaly/gitlab-shell.log

998 is the git user