What should be the ownership of /var/opt/gitlab/grafana?

Several months back I accidentally did a chown at the wrong level on our gitlab host and accidentally changed the user for all gitlab files !! My solution at the time was to create a docker container, look at the ownership of the various directories and then changed them to these. So far so good. However I was tracing earlier and noticed repeated errors of the form:

2020-11-30_17:48:38.78046 Service init failed: failed to connect to database: can’t check for existence of “/var/opt/gitlab/grafana/data/grafana.db”: stat /var/opt/gitlab/grafana/data/grafana.db: permission denied

I assume this is a left over from that issue and that the ownership under
/var/opt/gitlab/grafana is wrong. I have the following, can anybody tell me what it should be?

-rw-------. 1 git gitlab-prometheus 577536 Sep 1 2019 /var/opt/gitlab/grafana/data.bak.2019-09-01/grafana.db
-rw-------. 1 git gitlab-prometheus 741376 Aug 20 09:13 /var/opt/gitlab/grafana/data/grafana.db
-rw-r–r--. 1 gitlab-prometheus root 12597 Sep 19 11:40 /var/opt/gitlab/grafana/grafana.ini
-rw-r–r--. 1 gitlab-prometheus root 225 Jun 29 2019 /var/opt/gitlab/grafana/provisioning/dashboards/gitlab_dashboards.yml
-rw-r–r--. 1 gitlab-prometheus root 136 Jun 29 2019 /var/opt/gitlab/grafana/provisioning/datasources/gitlab_datasources.yml

BTW: This directory does not seem to exist out-of-the-box in a docker image.

I would say the ownership of grafana.db is wrong, mine looks like this:

-rw------- 1 gitlab-prometheus gitlab-prometheus 764K Dec  1 12:38 grafana.db

as you can see, you have the user as git, whereas I have as gitlab-prometheus. You can fix this with:

chown gitlab-prometheus:gitlab-prometheus grafana.db

and see if that helps. The remaining permissions for the other files are the same as mine. Also check permissions of the data directory itself where grafana.db is:

drwx------  4 gitlab-prometheus gitlab-prometheus 4.0K Dec  1 12:38 data

it should look like that.

1 Like

Thankyou.