Bug #100490 Docker container log doesn't make sense when configuration is mistaken

Submitted: 11 Aug 2020 8:27 Modified: 12 Aug 2020 9:07
Reporter: Tsubasa Tanaka (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Package Repos Severity:S3 (Non-critical)
Version:5.6.49, 5.7.31 OS:Any
Assigned to: CPU Architecture:Any
Tags: Contribution

[11 Aug 2020 8:27] Tsubasa Tanaka
Description:
docker-entrypoint.sh mistakes to handle wrong configuration in https://github.com/mysql/mysql-docker/blob/mysql-server/5.7/docker-entrypoint.sh#L38 .

$output is only receive "$@ --verbose --help" 's STDOUT, then the container log doesn't print about "what is wrong".

How to repeat:
### 5.6.49 and 5.7.31 miss to print $output and I can't understand "what's wrong".

$ sudo docker run mysql/mysql-server:5.7.31 --invalid-option
[Entrypoint] MySQL Docker Image 5.7.31-1.1.17
[Entrypoint] ERROR: Unable to start MySQL. Please check your configuration.
[Entrypoint]

$ sudo docker run mysql/mysql-server:5.6.49 --invalid-option
[Entrypoint] MySQL Docker Image 5.6.49-1.1.17
[Entrypoint] ERROR: Unable to start MySQL. Please check your configuration.
[Entrypoint]

### 5.5.62 is well

$ sudo docker run mysql/mysql-server:5.5.62 --invalid-option
[Entrypoint] MySQL Docker Image 5.5.62-1.1.10
[Entrypoint] ERROR: Unable to start MySQL. Please check your configuration.
[Entrypoint] 200811  8:18:30 [Note] mysqld (mysqld 5.5.62) starting as process 7 ...
200811  8:18:30 [Note] Plugin 'FEDERATED' is disabled.
mysqld: Table 'mysql.plugin' doesn't exist
200811  8:18:30 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
200811  8:18:30 [ERROR] mysqld: unknown option '--invalid-option'
200811  8:18:30 [ERROR] Aborting

### 8.0.21 misses to receive into $output but MY-000068 covers it.

$ sudo docker run mysql/mysql-server:8.0.21 --invalid-option
[Entrypoint] MySQL Docker Image 8.0.21-1.1.17
2020-08-11T08:18:59.351067Z 0 [ERROR] [MY-000068] [Server] unknown option '--invalid-option'.
2020-08-11T08:18:59.351158Z 0 [ERROR] [MY-010119] [Server] Aborting
[Entrypoint] ERROR: Unable to start MySQL. Please check your configuration.
[Entrypoint]

Suggested fix:
5.5.62 handles STDERR into $output correctly.
Fix the line of docker-entrypoint.sh like 5.5.62's one.

https://github.com/mysql/mysql-docker/blob/mysql-server/5.5/docker-entrypoint.sh#L38
[11 Aug 2020 8:31] Tsubasa Tanaka
fix as same as 5.5

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: bug100490.patch (application/octet-stream, text), 1.24 KiB.

[11 Aug 2020 8:32] Tsubasa Tanaka
The patched container works fine.

$ sudo docker run work --invalid-option
[Entrypoint] MySQL Docker Image 5.7.31-1.1.17
[Entrypoint] ERROR: Unable to start MySQL. Please check your configuration.
[Entrypoint] 2020-08-11T08:32:10.807114Z 0 [ERROR] unknown option '--invalid-option'
2020-08-11T08:32:10.810425Z 0 [ERROR] Aborting
[11 Aug 2020 9:15] MySQL Verification Team
Hello tanaka-San,

Thank you for the report and contribution.

regards,
Umesh
[12 Aug 2020 7:37] Terje Røsten
Hi!

Can you please cut and paste the patch as comment?

Current patch seems to be borken in some way.
[12 Aug 2020 7:39] Lars Tangvald
Posted by developer:
 
Thanks for the report!

When the --validate-config option was added to 8.0 (but not 5.6 and 5.7) we added the method for verifying the config as a variable to the template, but the entry used for the older versions contains an unescaped &, which is sed replaces with the name of the variable, garbling the command. Simply escaping the ampersand should fix this.

Note that the supplied patch seems corrupted
[12 Aug 2020 9:05] Tsubasa Tanaka
Sorry for broken patch.

diff --git a/5.6/docker-entrypoint.sh b/5.6/docker-entrypoint.sh
index d1b8f30..628f952 100755
--- a/5.6/docker-entrypoint.sh
+++ b/5.6/docker-entrypoint.sh
@@ -35,7 +35,7 @@ if [ "$1" = 'mysqld' ]; then
        # Test that the server can start. We redirect stdout to /dev/null so
        # only the error messages are left.
        result=0
-       output=$("$@" --verbose --help 2>%%VALIDATE_CONFIG%%1 > /dev/null) || result=$?
+       output=$("$@" --verbose --help 2>&1 > /dev/null) || result=$?
        if [ ! "$result" = "0" ]; then
                echo >&2 '[Entrypoint] ERROR: Unable to start MySQL. Please check your configuration.'
                echo >&2 "[Entrypoint] $output"
diff --git a/5.7/docker-entrypoint.sh b/5.7/docker-entrypoint.sh
index 45d13ab..b667658 100755
--- a/5.7/docker-entrypoint.sh
+++ b/5.7/docker-entrypoint.sh
@@ -35,7 +35,7 @@ if [ "$1" = 'mysqld' ]; then
        # Test that the server can start. We redirect stdout to /dev/null so
        # only the error messages are left.
        result=0
-       output=$("$@" --verbose --help 2>%%VALIDATE_CONFIG%%1 > /dev/null) || result=$?
+       output=$("$@" --verbose --help 2>&1 > /dev/null) || result=$?
        if [ ! "$result" = "0" ]; then
                echo >&2 '[Entrypoint] ERROR: Unable to start MySQL. Please check your configuration.'
                echo >&2 "[Entrypoint] $output"
[12 Aug 2020 9:06] Tsubasa Tanaka
Previous patch is broken

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: bug100490.patch (application/octet-stream, text), 1.24 KiB.

[12 Aug 2020 9:06] Tsubasa Tanaka
Sorry, fixed again..

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: bug100490.patch (application/octet-stream, text), 1.23 KiB.

[12 Aug 2020 9:07] Tsubasa Tanaka
Sorry for my mistakes..

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.043 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.