Skip to content

Commit eee337d

Browse files
pierreln-ddclaude
andauthored
[mysql] Log warning on 1045 error when SSL not configured (DataDog#23607)
* [mysql] Log warning on 1045 error when SSL not configured When pymysql raises OperationalError(1045) and no ssl config is present, log a warning suggesting SSL may be required by the MySQL instance. This helps diagnose cases where CloudSQL or other managed MySQL services enforce SSL and return 1045 instead of a clear SSL error. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> * Rename changelog entry to match PR number 23607 * Fix log capture in 1045 SSL warning tests CheckLoggingAdapter is a data descriptor — patch.object on the instance is silently ignored. Capture warnings via check.log.logger handler instead. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> * Remove test additions from PR — fix only --------- Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
1 parent c84ac0c commit eee337d

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

mysql/changelog.d/23607.fixed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Log a warning when a 1045 access denied error occurs with no SSL configuration, hinting that SSL may be required by the MySQL instance.

mysql/datadog_checks/mysql/mysql.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,18 @@ def _connect(self):
563563
self.SERVICE_CHECK_NAME, AgentCheck.OK, tags=service_check_tags, hostname=self.reported_hostname
564564
)
565565
yield db
566+
except pymysql.err.OperationalError as e:
567+
self.service_check(
568+
self.SERVICE_CHECK_NAME, AgentCheck.CRITICAL, tags=service_check_tags, hostname=self.reported_hostname
569+
)
570+
if e.args[0] == 1045 and not self._config.ssl:
571+
self.log.warning(
572+
"Access denied error (1045) with no SSL configuration. If your MySQL instance requires SSL "
573+
"connections, configure the 'ssl' option in the check configuration "
574+
"(e.g. 'ssl.check_hostname: false' for connections without certificate verification). "
575+
"See https://docs.datadoghq.com/database_monitoring/setup_mysql/ for more details."
576+
)
577+
raise
566578
except Exception:
567579
self.service_check(
568580
self.SERVICE_CHECK_NAME, AgentCheck.CRITICAL, tags=service_check_tags, hostname=self.reported_hostname

0 commit comments

Comments
 (0)