Skip to content

entrypoint.sh: MySQL's clone plugin support and less restrictive init practice #640

Closed
@nickb937

Description

@nickb937

When initiating, from a slave, the clone of another server, the command CLONE INSTANCE FROM will restart mysqld on the slave.

The command fails because the Docker image runs mysqld directly rather than through the mysqld_safe wrapper and so the clone_plugin cannot restart mysqld.

The entrypoint.sh script is useful because it pre-initialises the MySQL environment. It is a handy starting point for creating MySQL Group Replication clusters on-the-fly with Kubernetes but it is a little restrictive for use.

Two issues exist:

  1. The entrypoint.sh only works for mysqld and not mysqld_safe.
  2. There is logic to prevent entrypoint.sh being run from another script. I cannot create a Kubernetes initContainer that runs /entrypoint.sh to initialise the DB environment

My current workaround is to run this sed script in a Kubernetes initContainer to modify entrypoint not to run mysqld upon completion and invert the _is_sourced check, I'm therefore using entrypoint.sh to initialise the environment and leaving process control to the main mysql container in the Pod.

sed -e 's/exec "$@"/###/' -e 's/ _is_sourced;/ false;/' -i /entrypoint.sh 

Suggested fix:
_main():

  • support 'init' as an parameter to initialise the DB (as well as existing mysqld). I can therefore run /entrypoint.sh init from an initContainer.
  • don't run exec "$@" if "$1" == "init"
  • drop the _is_sourced check that wraps the call to _main().

procps is also an additional package dependency to use mysqld_safe

Metadata

Metadata

Assignees

No one assigned

    Labels

    RequestRequest for image modification or feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions