Fix replication settings

sh don't know 'echo -e', so we use bash instead.
Also, we need to wait for the container to be healthy before trying to
restart it. Otherwise that could corrupt it.
This commit is contained in:
Laurent Indermuehle 2023-01-12 13:49:34 +01:00
commit b9d0e96deb
No known key found for this signature in database
GPG key ID: 93FA944C9F34DD09
2 changed files with 20 additions and 8 deletions

View file

@ -130,18 +130,21 @@ jobs:
steps:
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
# No need to check for service health. GitHub Action took care of it.
- name: Restart MySQL server with settings for replication
run: |
docker exec ${{ job.services.db_primary.id }} sh -c 'echo -e [mysqld]\\nserver-id=1\\nlog-bin=/var/lib/mysql/primary-bin > /etc/mysql/conf.d/replication.cnf'
docker exec ${{ job.services.db_replica1.id }} sh -c 'echo -e [mysqld]\\nserver-id=2\\nlog-bin=/var/lib/mysql/replica1-bin > /etc/mysql/conf.d/replication.cnf'
docker exec ${{ job.services.db_replica2.id }} sh -c 'echo -e [mysqld]\\nserver-id=3\\nlog-bin=/var/lib/mysql/replica2-bin > /etc/mysql/conf.d/replication.cnf'
docker exec ${{ job.services.db_primary.id }} bash -c 'echo -e [mysqld]\\nserver-id=1\\nlog-bin=/var/lib/mysql/primary-bin > /etc/mysql/conf.d/replication.cnf'
docker exec ${{ job.services.db_replica1.id }} bash -c 'echo -e [mysqld]\\nserver-id=2\\nlog-bin=/var/lib/mysql/replica1-bin > /etc/mysql/conf.d/replication.cnf'
docker exec ${{ job.services.db_replica2.id }} bash -c 'echo -e [mysqld]\\nserver-id=3\\nlog-bin=/var/lib/mysql/replica2-bin > /etc/mysql/conf.d/replication.cnf'
docker restart ${{ job.services.db_primary.id }}
docker restart ${{ job.services.db_replica1.id }}
docker restart ${{ job.services.db_replica2.id }}
- name: Wait for the primary to be healthy
run: |
while ! /usr/bin/docker inspect --format="{{if .Config.Healthcheck}}{{print .State.Health.Status}}{{end}}" ${{ job.services.db_primary.id }} && [[ "$SECONDS" -lt 120 ]]; do sleep 1; done
- name: >-
Perform integration testing against
Ansible version ${{ matrix.ansible }}