Issue
I have a peculiar use case of Gitlab for a research project, where I have to load some data to Gitlab (users, projects and merge requests) and then gather the app metrics (memory usage, latency and some others). Is there a way to completely delete the database of GitLab? I need an empty start on each run.
Through Gitlab's API I wrote a code to delete everything but sometimes seems not to be the best method. For example, after deleting everything, I get "ghost users", or can't create a user with a name that already existed on a previous run.
Also, I have to delete the metrics database from Prometheus. I'm doing:
sudo gitlab-ctl restart
sudo su -
cd /var/opt/gitlab/prometheus/data
rm -rf 0* wal/0* wal/checkpoint.0*
But sometimes it doesn't work and I have to re-install or sometimes it takes a very long time for Gitlab to restart Prometheus.
I'm using Gitlab CE 15.3.3 on an ARM64 Virtual Machine with Ubuntu 22 on it. Any thoughts or advice?
Solution
Ideally, you would use GitLab as a Docker image.
That means the GitLab container would then use host mounted volumes to store persistent data.
That includes $GITLAB_HOME/data
, where you could delete the right subfolder, and check that, upon restarting the GitLab image, you end up with a clean slate.
The OP Francisco Zanartu confirms this approach in the comments, using "How to access Gitlab's metrics (Prometheus and Grafana) from Docker installation?"
docker run --network=host --env GITLAB_OMNIBUS_CONFIG="external_url 'http://localhost'"
(From "Grafana fails GitLab OAuth when token url is not accessible")
Answered By - VonC Answer Checked By - Robin (WPSolving Admin)