Unable to load application: Errno::EACCES: Permission denied @ rb_sysopen - /opt/gitlab/embedded/service/gitlab-rails/.gitlab_workhorse_secret"}

502 Error

Everytime running
sudo gitlab-ctl reconfigure

results in `Unable to load application: Errno::EACCES: Permission denied @ rb_sysopen - /opt/gitlab/embedded/service/gitlab-rails/.gitlab_workhorse_secret"}

2024-05-10_11:28:08.01621 bundler: failed to load command: puma (/opt/gitlab/embedded/bin/puma)

2024-05-10_11:28:08.01665 /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/jwt_authenticatable.rb:49:in initialize': Permission denied @ rb_sysopen - /opt/gitlab/embedded/service/gitlab-rails/.gitlab_workhorse_secret (Errno::EACCES)

Following Code changes ownership of file

`templatesymlink[Create a gitlab_workhorse_secret and create a symlink to Rails root] action create
* template[/var/opt/gitlab/gitlab-rails/etc/gitlab_workhorse_secret] action create[2024-05-10T17:01:12+05:30] INFO: template[/var/opt/gitlab/gitlab-rails/etc/gitlab_workhorse_secret] backed up to /opt/gitlab/embedded/cookbooks/cache/backup/var/opt/gitlab/gitlab-rails/etc/gitlab_workhorse_secret.chef-20240510170112.237981
[2024-05-10T17:01:12+05:30] INFO: template[/var/opt/gitlab/gitlab-rails/etc/gitlab_workhorse_secret] removed backup at /opt/gitlab/embedded/cookbooks/cache/backup/var/opt/gitlab/gitlab-rails/etc/gitlab_workhorse_secret.chef-20240509172547.633666
[2024-05-10T17:01:12+05:30] INFO: template[/var/opt/gitlab/gitlab-rails/etc/gitlab_workhorse_secret] updated file contents /var/opt/gitlab/gitlab-rails/etc/gitlab_workhorse_secret

  - update content in file /var/opt/gitlab/gitlab-rails/etc/gitlab_workhorse_secret from 775295 to 1beaf0
  - suppressed sensitive resource[2024-05-10T17:01:12+05:30] INFO: template[/var/opt/gitlab/gitlab-rails/etc/gitlab_workhorse_secret] owner changed to 0

[2024-05-10T17:01:12+05:30] INFO: template[/var/opt/gitlab/gitlab-rails/etc/gitlab_workhorse_secret] mode changed to 644

  - change mode from '0600' to '0644'
  - change owner from 'git' to 'root'
* link[Link /opt/gitlab/embedded/service/gitlab-rails/.gitlab_workhorse_secret to /var/opt/gitlab/gitlab-rails/etc/gitlab_workhorse_secret] action create (up to date)`

Self-managed CE 16.0.1 on Ubuntu 22.04.2 LTS

Even after upgrading to CE 16.11.2 problem still persists.

After
sudo gitlab-ctl reconfigure
Everytime need to change ownership and restart after that.

sudo chown git:git /opt/gitlab/embedded/service/gitlab-rails/.gitlab_workhorse_secret

What is ideal solution for this ?

I have changed code of
/opt/gitlab/embedded/cookbooks/gitlab/recipes/gitlab-rails.rb

for “[Create a gitlab_workhorse_secret and create a symlink to Rails root]”

from
owner "root" group "root"
to
owner gitlab_user group gitlab_group

Please help