Skip to content

Gitlab POD fails to start on Openshift - STDERR: mkdir: cannot create directory '/gitlab-data': Permission denied

I'm following this procedure "https://about.gitlab.com/2016/06/28/get-started-with-openshift-origin-3-and-gitlab/" to install gitlab on OpenShift but then this error is reported during pod creation

this command has been issued to allow to run the docker container using anyuid oc adm policy add-scc-to-user anyuid -z gitlab-ce-user

I looks like that there is a permission denied : "STDERR: mkdir: cannot create directory '/gitlab-data': Permission denied"

Error

Thank you for using GitLab Docker Image!
Current version: gitlab-ce=10.3.3-ce.0

Configure GitLab for your system by editing /etc/gitlab/gitlab.rb file
And restart this container to reload settings.
To do it use docker exec:

  docker exec -it gitlab vim /etc/gitlab/gitlab.rb
  docker restart gitlab

For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md 

If this container fails to start due to permission problems try to fix it by executing:

  docker exec -it gitlab update-permissions
  docker restart gitlab

Generating ssh_host_rsa_key...
Generating public/private rsa key pair.
Your identification has been saved in /etc/gitlab/ssh_host_rsa_key.
Your public key has been saved in /etc/gitlab/ssh_host_rsa_key.pub.
The key fingerprint is:
SHA256:9vMW/tmVGdeiFeMyYRx+RAoIjkH6SnrECmuW/GkiLNE root@gitlab-ce-2-zsrc8
The key's randomart image is:
+---[RSA 2048]----+
|   .o .. .. ..o  |
|   . +  .  + +   |
|  . . .     * +  |
| . .       . + o.|
|..+ .   S   o +.o|
|+*E.   . .  .= .=|
|=*o       o... o.|
|=+...      oo  o.|
|o oo       ...o .|
+----[SHA256]-----+
Generating ssh_host_ecdsa_key...
Generating public/private ecdsa key pair.
Your identification has been saved in /etc/gitlab/ssh_host_ecdsa_key.
Your public key has been saved in /etc/gitlab/ssh_host_ecdsa_key.pub.
The key fingerprint is:
SHA256:f9lkkR0+7d1411Nrv6WOenZm+v21dC+SkQfTEJTXv+A root@gitlab-ce-2-zsrc8
The key's randomart image is:
+---[ECDSA 256]---+
|           .oo o |
|            o oo+|
|             +oo=|
|            o..+O|
|        S   .+=+O|
|         .  oEoo+|
|          . o+..=|
|           .=.*oB|
|          .+oO++=|
+----[SHA256]-----+
Generating ssh_host_ed25519_key...
Generating public/private ed25519 key pair.
Your identification has been saved in /etc/gitlab/ssh_host_ed25519_key.
Your public key has been saved in /etc/gitlab/ssh_host_ed25519_key.pub.
The key fingerprint is:
SHA256:M4HOpLqUiC+iC3W+8VTeUI0rx/fFgpINiSfdKp7mIZ0 root@gitlab-ce-2-zsrc8
The key's randomart image is:
+--[ED25519 256]--+
|                 |
|       . o =     |
|      o + B o    |
|     =   * * . . |
|  . o o S B + . o|
|.o =   = @ o . o |
|+ + o o E .   .  |
|+o . = + .       |
|=oo . . .        |
+----[SHA256]-----+
Preparing services...
Starting services...
Configuring GitLab package...
/opt/gitlab/embedded/bin/runsvdir-start: line 24: ulimit: pending signals: cannot modify limit: Operation not permitted
/opt/gitlab/embedded/bin/runsvdir-start: line 34: ulimit: max user processes: cannot modify limit: Operation not permitted
/opt/gitlab/embedded/bin/runsvdir-start: line 37: /proc/sys/fs/file-max: Read-only file system
gitlab preinstall: 
gitlab preinstall: This node does not appear to be running a database
gitlab preinstall: Skipping version check, if you think this is an error exit now
gitlab preinstall: 
Configuring GitLab...
Starting Chef Client, version 12.12.15
resolving cookbooks for run list: ["gitlab"]
Synchronizing Cookbooks:
  - gitlab (0.0.1)
  - package (0.1.0)
  - registry (0.1.0)
  - mattermost (0.1.0)
  - consul (0.0.0)
  - gitaly (0.1.0)
  - runit (0.14.2)
Installing Cookbook Gems:
Compiling Cookbooks...
Recipe: gitlab::default
  * directory[/etc/gitlab] action create (skipped due to only_if)
  Converging 252 resources
  * directory[/etc/gitlab] action create (skipped due to only_if)
  * directory[Create /var/opt/gitlab] action create
    - change owner from 'git' to 'root'
    - change group from 'git' to 'root'
  * directory[/opt/gitlab/embedded/etc] action create
    - create new directory /opt/gitlab/embedded/etc
    - change mode from '' to '0755'
    - change owner from '' to 'root'
    - change group from '' to 'root'
  * template[/opt/gitlab/embedded/etc/gitconfig] action create
    - create new file /opt/gitlab/embedded/etc/gitconfig
    - update content in file /opt/gitlab/embedded/etc/gitconfig from none to 987af3
    --- /opt/gitlab/embedded/etc/gitconfig	2018-01-05 07:50:35.581130736 +0000
    +++ /opt/gitlab/embedded/etc/.chef-gitconfig20180105-37-y8gqpx	2018-01-05 07:50:35.581130736 +0000
    @@ -1 +1,11 @@
    +[pack]
    +  threads = 1
    +[receive]
    +  fsckObjects = true
    +advertisePushOptions = true
    +[repack]
    +  writeBitmaps = true
    +[transfer]
    +  hideRefs=^refs/tmp/
    +hideRefs=^refs/keep-around/
    - change mode from '' to '0755'
Recipe: gitlab::web-server
  * account[Webserver user and group] action create
    * group[Webserver user and group] action create (up to date)
    * user[Webserver user and group] action create (up to date)
     (up to date)
Recipe: gitlab::users
  * directory[/var/opt/gitlab] action create (up to date)
  * account[GitLab user and group] action create
    * group[GitLab user and group] action create (up to date)
    * user[GitLab user and group] action create (up to date)
     (up to date)
  * template[/var/opt/gitlab/.gitconfig] action create
    - create new file /var/opt/gitlab/.gitconfig
    - update content in file /var/opt/gitlab/.gitconfig from none to 9c6a72
    --- /var/opt/gitlab/.gitconfig	2018-01-05 07:50:35.611130736 +0000
    +++ /var/opt/gitlab/.chef-.gitconfig20180105-37-1peuo0l	2018-01-05 07:50:35.611130736 +0000
    @@ -1 +1,12 @@
    +# This file is managed by gitlab-ctl. Manual changes will be
    +# erased! To change the contents below, edit /etc/gitlab/gitlab.rb
    +# and run `sudo gitlab-ctl reconfigure`.
    +
    +[user]
    +        name = GitLab
    +        email = gitlab@gitlab
    +[core]
    +        autocrlf = input
    +[gc]
    +        auto = 0
    - change mode from '' to '0644'
    - change owner from '' to 'git'
    - change group from '' to 'git'
Recipe: gitlab::gitlab-shell
  * storage_directory[/gitlab-data/git-data] action create
    * ruby_block[directory resource: /gitlab-data/git-data] action run
      - execute the ruby block directory resource: /gitlab-data/git-data
  
  * storage_directory[/gitlab-data/git-data/repositories] action create
    * ruby_block[directory resource: /gitlab-data/git-data/repositories] action run
      - execute the ruby block directory resource: /gitlab-data/git-data/repositories
  
  * storage_directory[/var/opt/gitlab/.ssh] action create
    * ruby_block[directory resource: /var/opt/gitlab/.ssh] action run
      - execute the ruby block directory resource: /var/opt/gitlab/.ssh
  
  * storage_directory[/gitlab-data/ssh] action create
    * ruby_block[directory resource: /gitlab-data/ssh] action run
      
      ================================================================================
      Error executing action `run` on resource 'ruby_block[directory resource: /gitlab-data/ssh]'
      ================================================================================
      
      Mixlib::ShellOut::ShellCommandFailed
      ------------------------------------
      Expected process to exit with [0], but received '1'
      ---- Begin output of mkdir -p /gitlab-data/ssh ----
      STDOUT: 
      STDERR: mkdir: cannot create directory '/gitlab-data': Permission denied
      ---- End output of mkdir -p /gitlab-data/ssh ----
      Ran mkdir -p /gitlab-data/ssh returned 1
      
      Cookbook Trace:
      ---------------
      /opt/gitlab/embedded/cookbooks/cache/cookbooks/package/libraries/storage_directory_helper.rb:35:in `run_command'
      /opt/gitlab/embedded/cookbooks/cache/cookbooks/package/libraries/storage_directory_helper.rb:42:in `ensure_directory_exists'
      /opt/gitlab/embedded/cookbooks/cache/cookbooks/package/resources/storage_directory.rb:36:in `block (3 levels) in class_from_file'
      
      Resource Declaration:
      ---------------------
      # In /opt/gitlab/embedded/cookbooks/cache/cookbooks/package/resources/storage_directory.rb
      
       33:   ruby_block "directory resource: #{path}" do
       34:     block do
       35:       # Ensure the directory exists
       36:       storage_helper.ensure_directory_exists(path)
       37: 
       38:       # Ensure the permissions are set
       39:       storage_helper.ensure_permissions_set(path)
       40: 
       41:       # Error out if we have not achieved the target permissions
       42:       storage_helper.validate!(path)
       43:     end
       44:     not_if { storage_helper.validate(path) }
       45:   end
       46: end
      
      Compiled Resource:
      ------------------
      # Declared in /opt/gitlab/embedded/cookbooks/cache/cookbooks/package/resources/storage_directory.rb:33:in `block in class_from_file'
      
      ruby_block("directory resource: /gitlab-data/ssh") do
        action [:run]
        retries 0
        retry_delay 2
        default_guard_interpreter :default
        block_name "directory resource: /gitlab-data/ssh"
        declared_type :ruby_block
        cookbook_name "gitlab"
        block #<Proc:0x0000000005e23fb0@/opt/gitlab/embedded/cookbooks/cache/cookbooks/package/resources/storage_directory.rb:34>
        not_if { #code block }
      end
      
      Platform:
      ---------
      x86_64-linux
      
    
    ================================================================================
    Error executing action `create` on resource 'storage_directory[/gitlab-data/ssh]'
    ================================================================================
    
    Mixlib::ShellOut::ShellCommandFailed
    ------------------------------------
    ruby_block[directory resource: /gitlab-data/ssh] (/opt/gitlab/embedded/cookbooks/cache/cookbooks/package/resources/storage_directory.rb line 33) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
    ---- Begin output of mkdir -p /gitlab-data/ssh ----
    STDOUT: 
    STDERR: mkdir: cannot create directory '/gitlab-data': Permission denied
    ---- End output of mkdir -p /gitlab-data/ssh ----
    Ran mkdir -p /gitlab-data/ssh returned 1
    
    Cookbook Trace:
    ---------------
    /opt/gitlab/embedded/cookbooks/cache/cookbooks/package/libraries/storage_directory_helper.rb:35:in `run_command'
    /opt/gitlab/embedded/cookbooks/cache/cookbooks/package/libraries/storage_directory_helper.rb:42:in `ensure_directory_exists'
    /opt/gitlab/embedded/cookbooks/cache/cookbooks/package/resources/storage_directory.rb:36:in `block (3 levels) in class_from_file'
    
    Resource Declaration:
    ---------------------
    # In /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/gitlab-shell.rb
    
     55:   storage_directory dir do
     56:     owner git_user
     57:     group git_group
     58:     mode "0700"
     59:   end
     60: end
    
    Compiled Resource:
    ------------------
    # Declared in /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/gitlab-shell.rb:55:in `block in from_file'
    
    storage_directory("/gitlab-data/ssh") do
      action [:create]
      retries 0
      retry_delay 2
      default_guard_interpreter :default
      declared_type :storage_directory
      cookbook_name "gitlab"
      recipe_name "gitlab-shell"
      owner "git"
      mode "0700"
      group "git"
      path "/gitlab-data/ssh"
    end
    
    Platform:
    ---------
    x86_64-linux
    

Running handlers:
Running handlers complete
There was an error running gitlab-ctl reconfigure:

storage_directory[/gitlab-data/ssh] (gitlab::gitlab-shell line 55) had an error: Mixlib::ShellOut::ShellCommandFailed: ruby_block[directory resource: /gitlab-data/ssh] (/opt/gitlab/embedded/cookbooks/cache/cookbooks/package/resources/storage_directory.rb line 33) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of mkdir -p /gitlab-data/ssh ----
STDOUT: 
STDERR: mkdir: cannot create directory '/gitlab-data': Permission denied
---- End output of mkdir -p /gitlab-data/ssh ----
Ran mkdir -p /gitlab-data/ssh returned 1

Chef Client failed. 10 resources updated in 06 seconds