Search code examples
ruby-on-railsgithubmariadbcontainers

MariaDB Container not starting - Task on Github


I am attempting to create a MariaDB container for a workflow on GitHub. The workflow file is:

name: Rails 7.0 Test with MariaDB

on:
  workflow_dispatch:
  push:
    branches:
      - main
  pull_request:
    branches:
      - '*'

jobs:
  build:
    runs-on: ubuntu-20.04

    services:
      mariadb:
        image: mariadb:latest
        ports:
          - 3306:3306
        env:
          MYSQL_ROOT_PASSWORD: root_password
          MYSQL_DATABASE: test_db
          MYSQL_USER: test_user
          MYSQL_PASSWORD: test_password
        options: --health-cmd="mysqladmin ping --silent" --health-interval=10s --health-timeout=5s --health-retries=3

    steps:
      - name: Checkout Repository
        uses: actions/checkout@v2

      - name: Set up Ruby
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: 3.1

      - name: Install Dependencies
        run: |
          gem install bundler
          bundle install

      - name: Set up Database
        run: |
          cp config/database.yml.ci config/database.yml
          sed -i "s/username: root/username: test_user/g" config/database.yml
          sed -i "s/password:$/password: test_password/g" config/database.yml

      - name: Prepare Database
        run: |
          bundle exec rails db:create
          bundle exec rails db:migrate

      - name: Run Tests
        run: |
          bundle exec rspec

When the container starts, it gets the following warnings, but they are just that - warnings, no errors:

Warning: 14 19:05:57 0 [Warning] 'user' entry 'root@34b47ecf4f5d' ignored in --skip-name-resolve mode.
Warning: 14 19:05:57 0 [Warning] 'proxies_priv' entry '@% root@34b47ecf4f5d' ignored in --skip-name-resolve mode.

The logfile for the task shows:

Service container mariadb failed.
  /usr/bin/docker logs --details 34b47ecf4f5d8d2907f3a9dd7b35ad4b1be86e4b986a8fdf3950bbb1b8e94c69
   2023-08-14 19:05:56+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:11.0.2+maria~ubu2204 started.
   2023-08-14 19:05:56+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
   2023-08-14 19:05:56+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:11.0.2+maria~ubu2204 started.
   2023-08-14 19:05:56+00:00 [Note] [Entrypoint]: Initializing database files
   
   
   PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
   To do so, start the server, then issue the following command:
   
   '/usr/bin/mariadb-secure-installation'
   
   which will also give you the option of removing the test
   databases and anonymous user created by default.  This is
   strongly recommended for production servers.
   
   See the MariaDB Knowledgebase at https://mariadb.com/kb
   
   Please report any problems at https://mariadb.org/jira
   
   The latest information about MariaDB is available at https://mariadb.org/.
   
   Consider joining MariaDB's strong and vibrant community:
   https://mariadb.org/get-involved/
   
   2023-08-14 19:05:57+00:00 [Note] [Entrypoint]: Database files initialized
   2023-08-14 19:05:57+00:00 [Note] [Entrypoint]: Starting temporary server
   2023-08-14 19:05:57+00:00 [Note] [Entrypoint]: Waiting for server startup
   2023-08-14 19:05:57 0 [Note] Starting MariaDB 11.0.2-MariaDB-1:11.0.2+maria~ubu2204 source revision 0005f2f06c8e1aea4915887decad67885108a929 as process 95
   2023-08-14 19:05:57 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
   2023-08-14 19:05:57 0 [Note] InnoDB: Using transactional memory
   2023-08-14 19:05:57 0 [Note] InnoDB: Number of transaction pools: 1
   2023-08-14 19:05:57 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
   2023-08-14 19:05:57 0 [Note] mariadbd: O_TMPFILE is not supported on /tmp (disabling future attempts)
   2023-08-14 19:05:57 0 [Note] InnoDB: Initializing buffer pool, total size = 128.000MiB, chunk size = 2.000MiB
   2023-08-14 19:05:57 0 [Note] InnoDB: Completed initialization of buffer pool
   2023-08-14 19:05:57 0 [Note] InnoDB: File system buffers for log disabled (block size=4096 bytes)
   2023-08-14 19:05:57 0 [Note] InnoDB: Opened 3 undo tablespaces
   2023-08-14 19:05:57 0 [Note] InnoDB: 128 rollback segments in 3 undo tablespaces are active.
   2023-08-14 19:05:57 0 [Note] InnoDB: Setting file './ibtmp1' size to 12.000MiB. Physically writing the file full; Please wait ...
   2023-08-14 19:05:57 0 [Note] InnoDB: File './ibtmp1' size is now 12.000MiB.
   2023-08-14 19:05:57 0 [Note] InnoDB: log sequence number 46151; transaction id 14
   2023-08-14 19:05:57 0 [Note] Plugin 'FEEDBACK' is disabled.
   2023-08-14 19:05:57 0 [Note] Plugin 'wsrep-provider' is disabled.
  Warning: 14 19:05:57 0 [Warning] 'user' entry 'root@34b47ecf4f5d' ignored in --skip-name-resolve mode.
  Warning: 14 19:05:57 0 [Warning] 'proxies_priv' entry '@% root@34b47ecf4f5d' ignored in --skip-name-resolve mode.
   2023-08-14 19:05:57 0 [Note] mariadbd: ready for connections.
   Version: '11.0.2-MariaDB-1:11.0.2+maria~ubu2204'  socket: '/run/mysqld/mysqld.sock'  port: 0  mariadb.org binary distribution
   2023-08-14 19:05:58+00:00 [Note] [Entrypoint]: Temporary server started.
   2023-08-14 19:05:59+00:00 [Note] [Entrypoint]: Creating database test_db
   2023-08-14 19:05:59+00:00 [Note] [Entrypoint]: Creating user test_user
   2023-08-14 19:05:59+00:00 [Note] [Entrypoint]: Giving user test_user access to schema test_db
   2023-08-14 19:05:59+00:00 [Note] [Entrypoint]: Securing system users (equivalent to running mysql_secure_installation)
   
   2023-08-14 19:05:59+00:00 [Note] [Entrypoint]: Stopping temporary server
   2023-08-14 19:05:59 0 [Note] mariadbd (initiated by: unknown): Normal shutdown
   2023-08-14 19:05:59 0 [Note] InnoDB: FTS optimize thread exiting.
   2023-08-14 19:05:59 0 [Note] InnoDB: Starting shutdown...
   2023-08-14 19:05:59+00:00 [Note] [Entrypoint]: Temporary server stopped
   2023-08-14 19:05:59 0 [Note] InnoDB: Dumping buffer pool(s) to /var/lib/mysql/ib_buffer_pool
   2023-08-14 19:05:59 0 [Note] InnoDB: Buffer pool(s) dump completed at 230814 19:05:59
   2023-08-14 19:05:59 0 [Note] InnoDB: Removed temporary tablespace data file: "./ibtmp1"
   2023-08-14 19:05:59 0 [Note] InnoDB: Shutdown completed; log sequence number 47401; transaction id 15
   2023-08-14 19:05:59 0 [Note] mariadbd: Shutdown complete
   
   
   2023-08-14 19:05:59+00:00 [Note] [Entrypoint]: MariaDB init process done. Ready for start up.
   
   2023-08-14 19:05:59 0 [Note] Starting MariaDB 11.0.2-MariaDB-1:11.0.2+maria~ubu2204 source revision 0005f2f06c8e1aea4915887decad67885108a929 as process 1
   2023-08-14 19:05:59 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
   2023-08-14 19:05:59 0 [Note] InnoDB: Using transactional memory
   2023-08-14 19:05:59 0 [Note] InnoDB: Number of transaction pools: 1
   2023-08-14 19:05:59 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
   2023-08-14 19:05:59 0 [Note] mariadbd: O_TMPFILE is not supported on /tmp (disabling future attempts)
   2023-08-14 19:05:59 0 [Note] InnoDB: Initializing buffer pool, total size = 128.000MiB, chunk size = 2.000MiB
   2023-08-14 19:05:59 0 [Note] InnoDB: Completed initialization of buffer pool
   2023-08-14 19:05:59 0 [Note] InnoDB: File system buffers for log disabled (block size=4096 bytes)
   2023-08-14 19:05:59 0 [Note] InnoDB: Opened 3 undo tablespaces
   2023-08-14 19:05:59 0 [Note] InnoDB: 128 rollback segments in 3 undo tablespaces are active.
   2023-08-14 19:05:59 0 [Note] InnoDB: Setting file './ibtmp1' size to 12.000MiB. Physically writing the file full; Please wait ...
   2023-08-14 19:05:59 0 [Note] InnoDB: File './ibtmp1' size is now 12.000MiB.
   2023-08-14 19:05:59 0 [Note] InnoDB: log sequence number 47401; transaction id 14
   2023-08-14 19:05:59 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
   2023-08-14 19:05:59 0 [Note] Plugin 'FEEDBACK' is disabled.
   2023-08-14 19:05:59 0 [Note] Plugin 'wsrep-provider' is disabled.
   2023-08-14 19:05:59 0 [Note] InnoDB: Buffer pool(s) load completed at 230814 19:05:59
   2023-08-14 19:05:59 0 [Note] Server socket created on IP: '0.0.0.0'.
   2023-08-14 19:05:59 0 [Note] Server socket created on IP: '::'.
   2023-08-14 19:05:59 0 [Note] mariadbd: ready for connections.
   Version: '11.0.2-MariaDB-1:11.0.2+maria~ubu2204'  socket: '/run/mysqld/mysqld.sock'  port: 3306  mariadb.org binary distribution
  Error: Failed to initialize container mariadb:latest
Error: One or more containers failed to start.

Can anyone see why this container fails to start? Are the warnings being considered failures?


Solution

  • By the blog, mysqladmin ping is the wrong healthcheck (returned true too early), and mysqladmin and all mysql* named executables have been removed from the 11.0+ container.

    Replace with:

            options: --health-cmd="healthcheck.sh --connect --innodb_initialized" --health-interval=10s --health-timeout=5s --health-retries=3
    

    Also MariaDB names can be used:

            env:
              MARIADB_ROOT_PASSWORD: root_password
              MARIADB_DATABASE: test_db
              MARIADB_USER: test_user
              MARIADB_PASSWORD: test_password
    

    Yes I still need to clean up those two warnings in the container image.

    Thanks for testing with MariaDB!