Bug #113196 MySQL Operator - Metrics provider doesn't take command line arguments

Submitted: 23 Nov 2023 11:49 Modified: 23 Nov 2023 14:16
Reporter: Prasad Kris Email Updates:
Status: Documenting Impact on me:
None 
Category:MySQL Operator Severity:S3 (Non-critical)
Version:8.2.0-2.1.1 OS:Any
Assigned to: CPU Architecture:Any
Tags: innodb, mysql-operator

[23 Nov 2023 11:49] Prasad Kris
Description:
Greetings,

It looks like there is an issue or bug with the metrics provider. According to the documentation (https://dev.mysql.com/doc/mysql-operator/en/mysql-operator-properties.html#mysql-operator-...), we should be able to pass the exporter command-line arguments as options (InnoDBCluster.spec.metrics.options). I attempted this with the prom/mysqld_exporter image, including the required command-line arguments as options, the metrics: section form the manifest is furnished below.

metrics:
enable: true
image: prom/mysqld-exporter
monitor: true
monitorSpec:
  labels:
    release: prometheus-operator
options:
- --mysqld.address=localhost:3306
- --mysqld.username=metrics

However, it just ignores the operations, resulting in the metrics sidecar crash-looping with the below messages.

ts=2023-11-23T10:07:05.058Z caller=config.go:150 level=error msg="failed to validate config" section=client err="no user specified in section or parent"
ts=2023-11-23T10:07:05.058Z caller=mysqld_exporter.go:225 level=info msg="Error parsing host config" file=.my.cnf err="no configuration found" 

It is because the command line arguments specified in the options: are not being recognized by the sidecar pod, resulting in the sidecar just running the mysql-process as shown below.

k run test --image prom/mysqld-exporter --command sleep infinity        
pod/test created
k exec  test -- mysqld_exporter                              
ts=2023-11-23T11:34:22.610Z caller=config.go:150 level=error msg="failed to validate config" section=client err="no user specified in section or parent"
ts=2023-11-23T11:34:22.610Z caller=mysqld_exporter.go:225 level=info msg="Error parsing host config" file=.my.cnf err="no configuration found"

The labels specified in the monitorSpec are also being ignored, resulting in the creation of a ServiceMonitor object without the mentioned labels.

monitorSpec:
  labels:
    release: prometheus-operator

How to repeat:
Enable metrics with the following parameters on an InnoDB cluster resource.

metrics:
enable: true
image: prom/mysqld-exporter
monitor: true
monitorSpec:
  labels:
    release: prometheus-operator
options:
- --mysqld.address=localhost:3306
- --mysqld.username=metrics

Once applied, the InnoDB pods will enter a crash loop due to issues with the metrics sidecar container. The metrics sidecar will display the following logs:

ts=2023-11-23T10:07:05.058Z caller=config.go:150 level=error msg="failed to validate config" section=client err="no user specified in section or parent"
ts=2023-11-23T10:07:05.058Z caller=mysqld_exporter.go:225 level=info msg="Error parsing host config" file=.my.cnf err="no configuration found" 

Suggested fix:
[23 Nov 2023 14:16] MySQL Verification Team
Thanks for the report
[28 May 1:13] MySQL Admin
Posted by developer: Bug status updated to 'Patch approved'
[11 Jun 2:48] MySQL Admin
Posted by developer: Bug status updated to 'Documenting'

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

Page generated in 0.042 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.