From 12d2caf027df8a0773468922138da584601332dd Mon Sep 17 00:00:00 2001 From: JoJo Date: Fri, 18 Aug 2023 09:30:24 -0400 Subject: [PATCH] Fix InstanceConfig loading error for `ssl` config (#15611) * Fix InstanceConfig loading error * remove unnecessary ssl defaults * Set log to be default value for ssl mode * update changelog --- postgres/CHANGELOG.md | 4 ++++ postgres/assets/configuration/spec.yaml | 13 +---------- postgres/datadog_checks/postgres/config.py | 4 +--- .../postgres/config_models/defaults.py | 18 +-------------- .../postgres/data/conf.yaml.example | 22 +++++++++---------- 5 files changed, 17 insertions(+), 44 deletions(-) diff --git a/postgres/CHANGELOG.md b/postgres/CHANGELOG.md index 21d222fec3aee..eb4b3d958a6f9 100644 --- a/postgres/CHANGELOG.md +++ b/postgres/CHANGELOG.md @@ -14,6 +14,10 @@ * Update datadog-checks-base dependency version to 32.6.0 ([#15604](https://github.com/DataDog/integrations-core/pull/15604)) * Prevent `command already in progress` errors in the Postgres integration ([#15489](https://github.com/DataDog/integrations-core/pull/15489)) +***Fixed***: + +* Fix InstanceConfig loading error for `ssl` config ([#15611](https://github.com/DataDog/integrations-core/pull/15611)) + ## 14.1.0 / 2023-08-10 ***Added***: diff --git a/postgres/assets/configuration/spec.yaml b/postgres/assets/configuration/spec.yaml index cf32637f5f6ed..d76a22a355168 100644 --- a/postgres/assets/configuration/spec.yaml +++ b/postgres/assets/configuration/spec.yaml @@ -84,12 +84,9 @@ files: trusted CA and that the requested server host name matches the one in the certificate. For a detailed description of how these options work see https://www.postgresql.org/docs/current/libpq-ssl.html - - Note: `true` is an alias for `require`, and `false` is an alias for `disable`. value: type: string - display_default: "false" - example: "false" + example: "disable" - name: ssl_root_cert description: | The path to the ssl root certificate. @@ -97,8 +94,6 @@ files: For a detailed description of how this option works see https://www.postgresql.org/docs/current/libpq-ssl.html value: type: string - display_default: "false" - example: "/home/datadog/server-ca.pem" - name: ssl_cert description: | The path to the ssl certificate. @@ -106,8 +101,6 @@ files: For a detailed description of how this option works see https://www.postgresql.org/docs/current/libpq-ssl.html value: type: string - display_default: "false" - example: "/home/datadog/client-cert.pem" - name: ssl_key description: | The path to the ssl client key. @@ -115,8 +108,6 @@ files: For a detailed description of how this option works see https://www.postgresql.org/docs/current/libpq-ssl.html value: type: string - display_default: "false" - example: "/home/datadog/client-key.pem" - name: ssl_password description: | The password for the secret key specified in ssl_key, allowing client certificate private keys to be stored @@ -125,8 +116,6 @@ files: For a detailed description of how this option works see https://www.postgresql.org/docs/current/libpq-ssl.html value: type: string - display_default: "false" - example: "ssl_key_password" - name: query_timeout description: | Adds a statement_timeout https://www.postgresql.org/docs/current/runtime-config-client.html#GUC-STATEMENT-TIMEOUT diff --git a/postgres/datadog_checks/postgres/config.py b/postgres/datadog_checks/postgres/config.py index 1cc635dd0bf61..577093659f2d0 100644 --- a/postgres/datadog_checks/postgres/config.py +++ b/postgres/datadog_checks/postgres/config.py @@ -60,11 +60,9 @@ def __init__(self, instance): self.max_connections = instance.get('max_connections', 30) self.tags = self._build_tags(instance.get('tags', [])) - ssl = instance.get('ssl', "false") + ssl = instance.get('ssl', "disable") if ssl in SSL_MODES: self.ssl_mode = ssl - else: - self.ssl_mode = 'require' if ssl == "true" else 'disable' self.ssl_cert = instance.get('ssl_cert', None) self.ssl_root_cert = instance.get('ssl_root_cert', None) diff --git a/postgres/datadog_checks/postgres/config_models/defaults.py b/postgres/datadog_checks/postgres/config_models/defaults.py index 6324d036defe9..abffb7ef8feee 100644 --- a/postgres/datadog_checks/postgres/config_models/defaults.py +++ b/postgres/datadog_checks/postgres/config_models/defaults.py @@ -113,23 +113,7 @@ def instance_query_timeout(): def instance_ssl(): - return 'false' - - -def instance_ssl_cert(): - return 'false' - - -def instance_ssl_key(): - return 'false' - - -def instance_ssl_password(): - return 'false' - - -def instance_ssl_root_cert(): - return 'false' + return 'disable' def instance_table_count_limit(): diff --git a/postgres/datadog_checks/postgres/data/conf.yaml.example b/postgres/datadog_checks/postgres/data/conf.yaml.example index d087db34fab9e..487805d27ee6f 100644 --- a/postgres/datadog_checks/postgres/data/conf.yaml.example +++ b/postgres/datadog_checks/postgres/data/conf.yaml.example @@ -63,7 +63,7 @@ instances: # - rdsadmin # - azure_maintenance - ## @param ssl - string - optional - default: false + ## @param ssl - string - optional - default: disable ## This option determines whether or not and with what priority a secure SSL TCP/IP connection ## is negotiated with the server. There are six modes: ## - `disable`: Only tries a non-SSL connection. @@ -77,39 +77,37 @@ instances: ## trusted CA and that the requested server host name matches the one in the certificate. ## ## For a detailed description of how these options work see https://www.postgresql.org/docs/current/libpq-ssl.html - ## - ## Note: `true` is an alias for `require`, and `false` is an alias for `disable`. # - # ssl: 'false' + # ssl: disable - ## @param ssl_root_cert - string - optional - default: false + ## @param ssl_root_cert - string - optional ## The path to the ssl root certificate. ## ## For a detailed description of how this option works see https://www.postgresql.org/docs/current/libpq-ssl.html # - # ssl_root_cert: /home/datadog/server-ca.pem + # ssl_root_cert: - ## @param ssl_cert - string - optional - default: false + ## @param ssl_cert - string - optional ## The path to the ssl certificate. ## ## For a detailed description of how this option works see https://www.postgresql.org/docs/current/libpq-ssl.html # - # ssl_cert: /home/datadog/client-cert.pem + # ssl_cert: - ## @param ssl_key - string - optional - default: false + ## @param ssl_key - string - optional ## The path to the ssl client key. ## ## For a detailed description of how this option works see https://www.postgresql.org/docs/current/libpq-ssl.html # - # ssl_key: /home/datadog/client-key.pem + # ssl_key: - ## @param ssl_password - string - optional - default: false + ## @param ssl_password - string - optional ## The password for the secret key specified in ssl_key, allowing client certificate private keys to be stored ## in encrypted form on disk. ## ## For a detailed description of how this option works see https://www.postgresql.org/docs/current/libpq-ssl.html # - # ssl_password: ssl_key_password + # ssl_password: ## @param query_timeout - integer - optional - default: 5000 ## Adds a statement_timeout https://www.postgresql.org/docs/current/runtime-config-client.html#GUC-STATEMENT-TIMEOUT