System configuration for OpenStack Infrastructure
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4.4 KiB




Gitea is running on

At a Glance

  • :git_file:`playbooks/roles/gitea`
  • :git_file:`playbooks/roles/haproxy`
  • :git_file:`inventory/service/group_vars/gitea-lb.yaml`


The OpenDev Git repositories are hosted on a pool of servers. They are served via https using Gitea behind HAProxy which handles load balancing across the nodes.

Backend Maintenance

To temporarily remove a git backend from the HAProxy load balancer, you can put it in "maintenance" mode. This can be done interactively on the HAProxy host. Note that long-term changes to the topology should be made via configuration management. These commands must be run as root.

To see the current status of all servers:

echo "show stat" | socat /var/haproxy/run/stats stdio

To disable a server (eg, gitea08):

echo "disable server balance_git_http/" | socat /var/haproxy/run/stats stdio
echo "disable server balance_git_https/" | socat /var/haproxy/run/stats stdio

To re-enable a server:

echo "enable server balance_git_http/" | socat /var/haproxy/run/stats stdio
echo "enable server balance_git_https/" | socat /var/haproxy/run/stats stdio

To run these commands and others interactively, issue the prompt command to haproxy:

socat readline /var/haproxy/run/stats

Deploy a New Backend

Our gitea servers do maintain a small amount of state (they remember repo rename redirects) so there is a small amount of process required to deploy a new Gitea backend.

To deploy a new Gitea backend we add it to the ansible inventory, but exclude it from the manage-projects.yaml playbook. This will full provision an empty Gitea server with running Gitea and database processes. Then we can manually restore the database from another node, create all of the bare git repos, and replicate all of the repo content.

When these steps are done the new gitea backend can be added to the haproxy config and its exclusion from "Create repos on gitea servers" can be removed.

Restore the Gitea Database

The first step in restoring the database is to determine which container is running the database:

docker ps -a

Make note of the container id for the container running the mariadb image.

Next we stop the gitea services:


With services stopped and the container id captured we are ready to restore the database. First find the database to restore; it is backed up in /var/backups/gitea-mariadb on gitea hosts. You can copy and uncompress it.

Then restore the database (note we use docker exec and not docker-compose exec for performance reasons):

docker exec -i $DB_CONTAINER_ID bash -c '/usr/bin/mysql -uroot -p"$MYSQL_ROOT_PASSWORD"' < /root/gitea-mariadb.sql

When that is completed you can restart the docker containers that were stopped:

# Check that containers are still stopped
docker ps -a

Create All Bare Git Repos

Gitea's admin dashboard includes a useful button to create all missing git repos. At this point in the deployment we have recovered the DB contents so Gitea knows there are missing repos and will happily create empty replacements if we ask it to.

Login to Gitea as root via The credentials can be found in hiera's group vars for the gitea group. Navigate to and click the run button for Reinitialize all missing Git repositories for which records exist.

Replicate Git Repo Content from Gerrit

First we must accept the RSA host key for the Gerrit server (not the ecdsa key):$ ssh -o HostKeyAlgorithms=ssh-rsa -p222

Then we can ask Gerrit to replicate all repo content into our new empty repos:

ssh -p 29418 $ gerrit replication start --url

You can monitor the progress of this with:

ssh -p 29418 $ gerrit show-queue

Once this is complete, add the server back into the haproxy as discussed above.