Restart gitea more cleaner

Gerrit replication plugin is good about retrying replication if its
connectivity to the remote fails. It however thinks everything is happy
if it can connect and push even when gitea-web isn't running.

Make the whole replication system happier by stopping gitea-ssh before
other services and starting it after other services. This way gerrit
should fail to replicate until gitea is ready for it to ssh in.

Change-Id: I3440d8dd8a01a3aaf5d18c9c2ca48e7ead63856f
This commit is contained in:
Monty Taylor 2020-03-03 18:05:03 -06:00 committed by Clark Boylan
parent 312cadf53f
commit 77fb33f5d5
2 changed files with 37 additions and 7 deletions

View File

@ -34,13 +34,42 @@
shell:
cmd: docker-compose pull
chdir: /etc/gitea-docker/
- name: Run docker-compose up
shell:
cmd: docker-compose up -d --timeout 60
chdir: /etc/gitea-docker/
- name: Run docker prune to cleanup unneeded images
shell:
cmd: docker image prune -f
register: docker_compose_pull
- name: Stop/Start gitea safely for Gerrit replication
when: "'Downloaded newer image' in docker_compose_pull.stdout"
block:
- name: Run docker-compose stop
shell:
cmd: docker-compose stop --timeout 60
chdir: /etc/gitea-docker/
- name: Run docker-compose up mariadb gitea-web
shell:
cmd: docker-compose up -d --timeout 60 mariadb gitea-web
chdir: /etc/gitea-docker/
# We wait here for the main gitea service to start before starting
# the ssh service. This is friendly to gerrit replication.
- name: Wait until the web service is sufficiently up to start ssh
uri:
url: "https://localhost:3000/api/v1/users/root"
validate_certs: false
status_code: 200, 404
register: root_user_check
delay: 1
retries: 300
until: root_user_check and root_user_check.status in (200, 404)
- name: Run docker-compose up gitea-ssh
shell:
cmd: docker-compose up -d --timeout 60 gitea-ssh
chdir: /etc/gitea-docker/
- name: Run docker prune to cleanup unneeded images
shell:
cmd: docker image prune -f
# User management outside of service bringup to avoid confusion between
# the two stages.
- name: Check if root user exists
uri:
url: "https://localhost:3000/api/v1/users/root"

View File

@ -35,6 +35,7 @@ services:
gitea-ssh:
depends_on:
- mariadb
- gitea-web
environment:
- SSH_LISTEN_PORT=222
image: docker.io/opendevorg/gitea-openssh