Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Copilot Lvl 2
Message 1 of 3

Mysql service never comes up healthy in action

Solved! Go to Solution.

At some point in the last couple weeks, the mysql:5.7 service config I was using to expose mysql to my action stopped working. Here's the config I'm using:

 

 

 

name: Run Tests
on: pull_request
jobs:
  test:
    runs-on: ubuntu-latest
    services:
      mysql:
        image: mysql:5.7
        ports: 
        - 3306
        options: --health-cmd "mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 10

    steps:
      - uses: actions/checkout@v1.0.0
        with:
          fetch-depth: 1
      - uses: actions/setup-elixir@v1.0.0
        with:
          otp-version: 22.x
          elixir-version: 1.9.x
      - run: MIX_ENV=test mix deps.get
      - name: setup db and test
        run: |
          MIX_ENV=test mix ecto.setup
          mix test
        env: 
          DATABASE_URL: "mysql2://root:root@127.0.0.1:${{ job.services.mysql.ports['3306'] }}/myapp" 

 

 

 

That config was working perfectly fine for a week or two and then, seemingly out of nowhere, it started failing consistently with the service reporting (almost immediately) that mysql is unhealthy:

 

Status: Downloaded newer image for mysql:5.7
docker.io/library/mysql:5.7
/usr/bin/docker create --name 926a41768ca34ea8b1364385026a6af1_mysql57_8b5743 --label 2e4e3a --network github_network_169d64eaca1a440991d3382af497b76f --network-alias mysql -p 3306 --health-cmd "mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 10 -e GITHUB_ACTIONS=true mysql:5.7
03afaad28cc629cb34a9507a2d19435c2c32ddc1f7fd4f94da2033c01f26c938
/usr/bin/docker start 03afaad28cc629cb34a9507a2d19435c2c32ddc1f7fd4f94da2033c01f26c938
03afaad28cc629cb34a9507a2d19435c2c32ddc1f7fd4f94da2033c01f26c938
/usr/bin/docker ps --all --filter id=03afaad28cc629cb34a9507a2d19435c2c32ddc1f7fd4f94da2033c01f26c938 --filter status=running --no-trunc --format "{{.ID}} {{.Status}}"
03afaad28cc629cb34a9507a2d19435c2c32ddc1f7fd4f94da2033c01f26c938 Up Less than a second (health: starting)
/usr/bin/docker port 03afaad28cc629cb34a9507a2d19435c2c32ddc1f7fd4f94da2033c01f26c938
/usr/bin/docker inspect --format="{{if .Config.Healthcheck}}{{print .State.Health.Status}}{{end}}" 03afaad28cc629cb34a9507a2d19435c2c32ddc1f7fd4f94da2033c01f26c938
unhealthy
##[error]Failed to initialize, mysql service is unhealthy.

As I mentioned, that final error (`Failed to initialize, mysql service is unhealthy.`) appears almost immediately, and it seems that my health cmd and interval options aren't being respected.

 

Anyone know what I might be missing to get this to work?

 

2 Replies
Solution
GitHub Partner
Message 2 of 3

Re: Mysql service never comes up healthy in action

Hi peburrows,

 

Glad to hear you in Github Community Forum!

I copied your code and reproduced the issue. After i add 'jobs.<job_id>.services.env' to the service, the error is gone, code as below, hope it helps, thanks.

     services:
      mysql:
        image: mysql:5.7
        env:
          MYSQL_ROOT_PASSWORD: password
        ports: 
        - 3306
        options: --health-cmd "mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 10

 

MySQL.png

Copilot Lvl 2
Message 3 of 3

Re: Mysql service never comes up healthy in action

Awesome, thank you! That seems to have fixed it.