`git_data_dir` permission check fails on reconfigure

In 8.12, we changed the way we're checking permissions on the git_data_dir. I originally talked about this issue with @twk3 and it appears we weren't correctly checking permissions in the past so now some users are getting errors. The actual issue is that the command to change the permissions is silently failing. The customer provided the following additional information:

I was able to recreate the same permissions issue I saw on our NAS with the data location residing locally (/gitlab) on our server. When I change the permission of the folder to chmod -R ug+srwx,o+rwx (777 + sticky bit) and run the script it would fail, but when I remove sticky bit (chmod -R -s) and run the script it completes successfully both locally (/gitlab) and on our NAS (/NAS/gitlab), setting the permissions to git.root 700.

Hopefully this gives us enough information to decide how to handle it.

@twk3 I look forward to your comments.

Original error:

* ruby_block[directory resource: /nas/gitlab] action run 

================================================================================ 
Error executing action `run` on resource 'ruby_block[directory resource: /nas/gitlab]' 
================================================================================ 

Mixlib::ShellOut::ShellCommandFailed 
------------------------------------ 
Expected process to exit with [0], but received '1' 
---- Begin output of test -d "/nas/gitlab" -a "$(stat --printf='%U %04a' /nas/gitlab)" = 'git 0700' ---- 
STDOUT: 
STDERR: 
---- End output of test -d "/nas/gitlab" -a "$(stat --printf='%U %04a' /nas/gitlab)" = 'git 0700' ---- 
Ran test -d "/nas/gitlab" -a "$(stat --printf='%U %04a' /nas/gitlab)" = 'git 0700' returned 1 

Cookbook Trace: 
--------------- 
/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/storage_directory_helper.rb:35:in `run_command' 
/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/storage_directory_helper.rb:89:in `validate' 
/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/storage_directory_helper.rb:82:in `validate!' 
/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/definitions/storage_directory.rb:35:in `block (3 levels) in from_file' 

Resource Declaration: 
--------------------- 
# In /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/definitions/storage_directory.rb 

26: ruby_block "directory resource: #{params[:path]}" do 
27: block do 
28: # Ensure the directory exists 
29: storage_helper.ensure_directory_exists(params[:path]) 
30: 
31: # Ensure the permissions are set 
32: storage_helper.ensure_permissions_set(params[:path]) 
33: 
34: # Error out if we have not achieved the target permissions 
35: storage_helper.validate!(params[:path]) 
36: end 
37: not_if { storage_helper.validate(params[:path]) } 
38: end 
39: end 

Compiled Resource: 
------------------ 
# Declared in /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/definitions/storage_directory.rb:26:in `block in from_file' 

ruby_block("directory resource: /nas/gitlab") do 
params {:path=>"/nas/gitlab", :owner=>"git", :group=>nil, :mode=>"0700", :name=>"/nas/gitlab"} 
action [:run] 
retries 0 
retry_delay 2 
default_guard_interpreter :default 
block_name "directory resource: /nas/gitlab" 
declared_type :ruby_block 
cookbook_name "gitlab" 
recipe_name "gitlab-shell" 
block #<Proc:0x0000000411fdd8@/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/definitions/storage_directory.rb:27> 
not_if { #code block } 
end 

Platform: 
--------- 
x86_64-linux