Add required quotes in port variable
Agent is unable to connect to SQL Server on AWS RDS when set up with k8s annotations because the python driver cannot concatenate the port int value to str.
What does this PR do?
Adds quotes in port variable value in k8s annotations.
Motivation
Agent is unable to connect to SQL Server on AWS RDS when set up with k8s annotations because the python driver cannot concatenate the port int value to str. See error below as taken from agent logs:
[
{
"message": "can only concatenate str (not \"int\") to str",
"traceback": "Traceback (most recent call last):\n File \"/opt/datadog-agent/embedded/lib/python3.8/site-packages/datadog_checks/base/checks/base.py\", line 1116, in run\n self.check(instance)\n File \"/opt/datadog-agent/embedded/lib/python3.8/site-packages/datadog_checks/sqlserver/sqlserver.py\", line 624, in check\n self.load_static_information()\n File \"/opt/datadog-agent/embedded/lib/python3.8/site-packages/datadog_checks/sqlserver/sqlserver.py\", line 236, in load_static_information\n with self.connection.open_managed_default_connection():\n File \"/opt/datadog-agent/embedded/lib/python3.8/contextlib.py\", line 113, in __enter__\n return next(self.gen)\n File \"/opt/datadog-agent/embedded/lib/python3.8/site-packages/datadog_checks/sqlserver/connection.py\", line 276, in open_managed_default_connection\n with self._open_managed_db_connections(self.DEFAULT_DB_KEY, key_prefix=key_prefix):\n File \"/opt/datadog-agent/embedded/lib/python3.8/contextlib.py\", line 113, in __enter__\n return next(self.gen)\n File \"/opt/datadog-agent/embedded/lib/python3.8/site-packages/datadog_checks/sqlserver/connection.py\", line 281, in _open_managed_db_connections\n self.open_db_connections(db_key, db_name, key_prefix=key_prefix)\n File \"/opt/datadog-agent/embedded/lib/python3.8/site-packages/datadog_checks/sqlserver/connection.py\", line 294, in open_db_connections\n conn_key = self._conn_key(db_key, db_name, key_prefix)\n File \"/opt/datadog-agent/embedded/lib/python3.8/site-packages/datadog_checks/sqlserver/connection.py\", line 495, in _conn_key\n dsn, host, username, password, database, driver = self._get_access_info(db_key, db_name)\n File \"/opt/datadog-agent/embedded/lib/python3.8/site-packages/datadog_checks/sqlserver/connection.py\", line 447, in _get_access_info\n host = self._get_host_with_port()\n File \"/opt/datadog-agent/embedded/lib/python3.8/site-packages/datadog_checks/sqlserver/connection.py\", line 491, in _get_host_with_port\n return split_host + \",\" + port\nTypeError: can only concatenate str (not \"int\") to str\n"
}
]
It's probably better to amend the driver to be able to correctly concatenate the port int value, but as is the docs are misleading. This PR adds quotes only in the k8s annotations sections, it's not tested if they are needed in the alternative configurations.
Additional Notes
Reviewer checklist
- [ ] Review the changed files.
- [ ] Review the URLs listed in the Preview section.
- [ ] Check images for PII
- [ ] Review any mentions of "Contact Datadog support" for internal support documentation.
Thanks @theofanis for opening this PR! We're reviewing it and will be back in touch.
@theofanis Thanks again for submitting this PR.