{"id":27315,"date":"2023-08-16T13:35:45","date_gmt":"2023-08-16T11:35:45","guid":{"rendered":"https:\/\/www.dbi-services.com\/blog\/?p=27315"},"modified":"2023-08-16T13:35:47","modified_gmt":"2023-08-16T11:35:47","slug":"troubleshooting-patroni-cluster-pg_hba-configuration-not-applied","status":"publish","type":"post","link":"https:\/\/www.dbi-services.com\/blog\/troubleshooting-patroni-cluster-pg_hba-configuration-not-applied\/","title":{"rendered":"Troubleshooting Patroni Cluster: pg_hba Configuration not applied"},"content":{"rendered":"\n<p>In the world of database management, high availability and data integrity are of most importance. Patroni, a robust open-source solution, offers a way to manage and maintain PostgreSQL high availability clusters seamlessly. However, even with tools like Patroni, you can face challenges.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-the-setup-patroni-cluster-installation\">The setup: Patroni Cluster Installation<\/h2>\n\n\n\n<p>I had the mission of setting up a Patroni cluster for a critical application at a customer&#8217;s site. The goal was to ensure continuous database availability, automatic failover, and streamlined management. Patroni&#8217;s reputation preceded it, promising a smooth and efficient installation process.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-encountering-the-edit-config-roadblock\">Encountering the edit-config Roadblock<\/h2>\n\n\n\n<p>As part of the installation process, I needed to configure PostgreSQL&#8217;s `pg_hba.conf` file, which manage client authentication to the databases. To make changes to this file within a Patroni-managed cluster, the command `patronictl edit-config` is typically employed. This command allows for the adjustment of various cluster-related configurations.<\/p>\n\n\n\n<p>However, I was surprised when I attempted to use `patronictl edit-config` to modify the hba configuration. The tool indicated that changes had been made but it wasn\u2019t editing the content of `pg_hba.conf` file. It was a perplexing and frustrating situation, as I was certain that our configuration adjustments weren&#8217;t being recognized.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-unraveling-the-root-cause\">Unraveling the Root Cause<\/h2>\n\n\n\n<p>After thorough investigation and consultation with Patroni&#8217;s documentation and community, we discovered that the actual issue wasn&#8217;t with the `patronictl edit-config` command itself, but rather with our initial configuration approach.<\/p>\n\n\n\n<p>When I had initialized the cluster, I had pre-populated the desired `pg_hba.conf` settings in the `patroni.yml` file under the `postgresql.pg_hba` section. This seemed to be the problem. By including these configurations in advance, I was inadvertently overwriting any subsequent changes made through the Data Center Secret (DCS) mechanism, which `patronictl edit-config` relied on.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-the-conflict-patroni-yml-vs-dcs-changes\">The Conflict: `patroni.yml` vs. DCS Changes<\/h2>\n\n\n\n<p>In the world of Patroni, the DCS is a critical component responsible for storing and managing cluster state information. This includes configurations like `pg_hba.conf`. When `patronictl edit-config` is employed, it interacts with the DCS to enact changes. However, in our case, our pre-populated `pg_hba.conf` settings in `patroni.yml` were taking precedence over the DCS changes, effectively rendering any subsequent `patronictl edit-config` attempts ineffective.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-the-solution-configuration-order-matters\">The Solution: Configuration order matters<\/h2>\n\n\n\n<p>Once the root cause was identified, here are the steps to address the issue:<\/p>\n\n\n\n<p>1. <strong>Review and Adjust `patroni.yml`<\/strong>: I revisited our `patroni.yml` file and removed the pre-existing `pg_hba.conf` configurations<\/p>\n\n\n\n<p>2. <strong>Use `patronictl edit-config`<\/strong>: With the adjustments in place, I employed `patronictl edit-config` to modify the `pg_hba.conf` file as needed. This time, the tool functioned as expected, leveraging the DCS mechanism to enact changes.<\/p>\n\n\n\n<p>3. <strong>Cluster Health Verification<\/strong>: After making the necessary `pg_hba.conf` modifications, I tested the cluster&#8217;s health to ensure the changes didn&#8217;t negatively impact overall functionality.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-another-possible-root-cause\">Another possible root cause<\/h2>\n\n\n\n<p>There was another possible root cause: the settings hba_file in the patroni.yml file under the section postgresql.hba_file has been configured.<br>In case you set this parameter, which should have as a value a path for pg_hba.conf file, the postgres.pg_hba section or the change made with Patroni through DCS will be ignored.<br>In my case, this parameter was not set.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2>\n\n\n\n<p>My encounter with this configuration conflict provided valuable insights into the various way of working with Patroni clusters. Lessons learned from this experience include:<\/p>\n\n\n\n<p>&#8211; <strong>Configuration Order Matters<\/strong>: The order in which configurations are applied can significantly impact the behavior of cluster management tools like Patroni.<\/p>\n\n\n\n<p>&#8211; <strong>DCS and `patronictl edit-config`<\/strong>: Understanding the role of the Data Center Secret (DCS) and its interaction with `patronictl edit-config` is crucial for smooth cluster management.<\/p>\n\n\n\n<p>By sharing my experience, I hope to help others in navigating similar hurdles and optimizing their Patroni-managed clusters.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the world of database management, high availability and data integrity are of most importance. Patroni, a robust open-source solution, offers a way to manage and maintain PostgreSQL high availability clusters seamlessly. However, even with tools like Patroni, you can face challenges. The setup: Patroni Cluster Installation I had the mission of setting up a [&hellip;]<\/p>\n","protected":false},"author":87,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[229,198,83],"tags":[3058,1543,77],"type_dbi":[3059,3060,2749],"class_list":["post-27315","post","type-post","status-publish","format-standard","hentry","category-database-administration-monitoring","category-database-management","category-postgresql","tag-hba","tag-patroni","tag-postgresql","type-hba","type-patroni","type-postgresql"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.2 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Troubleshooting Patroni Cluster: pg_hba Configuration not applied - dbi Blog<\/title>\n<meta name=\"description\" content=\"Troubleshoot and resolve pg_hba issues in Patroni. Discover, understand the root causes and solutions.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.dbi-services.com\/blog\/troubleshooting-patroni-cluster-pg_hba-configuration-not-applied\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Troubleshooting Patroni Cluster: pg_hba Configuration not applied\" \/>\n<meta property=\"og:description\" content=\"Troubleshoot and resolve pg_hba issues in Patroni. Discover, understand the root causes and solutions.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.dbi-services.com\/blog\/troubleshooting-patroni-cluster-pg_hba-configuration-not-applied\/\" \/>\n<meta property=\"og:site_name\" content=\"dbi Blog\" \/>\n<meta property=\"article:published_time\" content=\"2023-08-16T11:35:45+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-08-16T11:35:47+00:00\" \/>\n<meta name=\"author\" content=\"Joan Frey\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Joan Frey\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/troubleshooting-patroni-cluster-pg_hba-configuration-not-applied\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/troubleshooting-patroni-cluster-pg_hba-configuration-not-applied\\\/\"},\"author\":{\"name\":\"Joan Frey\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/c03c47649664fe73b27ce457e99f5b06\"},\"headline\":\"Troubleshooting Patroni Cluster: pg_hba Configuration not applied\",\"datePublished\":\"2023-08-16T11:35:45+00:00\",\"dateModified\":\"2023-08-16T11:35:47+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/troubleshooting-patroni-cluster-pg_hba-configuration-not-applied\\\/\"},\"wordCount\":638,\"commentCount\":0,\"keywords\":[\"hba\",\"Patroni\",\"PostgreSQL\"],\"articleSection\":[\"Database Administration &amp; Monitoring\",\"Database management\",\"PostgreSQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/troubleshooting-patroni-cluster-pg_hba-configuration-not-applied\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/troubleshooting-patroni-cluster-pg_hba-configuration-not-applied\\\/\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/troubleshooting-patroni-cluster-pg_hba-configuration-not-applied\\\/\",\"name\":\"Troubleshooting Patroni Cluster: pg_hba Configuration not applied - dbi Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#website\"},\"datePublished\":\"2023-08-16T11:35:45+00:00\",\"dateModified\":\"2023-08-16T11:35:47+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/c03c47649664fe73b27ce457e99f5b06\"},\"description\":\"Troubleshoot and resolve pg_hba issues in Patroni. Discover, understand the root causes and solutions.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/troubleshooting-patroni-cluster-pg_hba-configuration-not-applied\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/troubleshooting-patroni-cluster-pg_hba-configuration-not-applied\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/troubleshooting-patroni-cluster-pg_hba-configuration-not-applied\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Troubleshooting Patroni Cluster: pg_hba Configuration not applied\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/\",\"name\":\"dbi Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/c03c47649664fe73b27ce457e99f5b06\",\"name\":\"Joan Frey\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/1e650cf665b4d44dd186355827c0b049d2f95c8cbb45fd10d4e7cb255be67ecb?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/1e650cf665b4d44dd186355827c0b049d2f95c8cbb45fd10d4e7cb255be67ecb?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/1e650cf665b4d44dd186355827c0b049d2f95c8cbb45fd10d4e7cb255be67ecb?s=96&d=mm&r=g\",\"caption\":\"Joan Frey\"},\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/author\\\/joanfrey\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Troubleshooting Patroni Cluster: pg_hba Configuration not applied - dbi Blog","description":"Troubleshoot and resolve pg_hba issues in Patroni. Discover, understand the root causes and solutions.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.dbi-services.com\/blog\/troubleshooting-patroni-cluster-pg_hba-configuration-not-applied\/","og_locale":"en_US","og_type":"article","og_title":"Troubleshooting Patroni Cluster: pg_hba Configuration not applied","og_description":"Troubleshoot and resolve pg_hba issues in Patroni. Discover, understand the root causes and solutions.","og_url":"https:\/\/www.dbi-services.com\/blog\/troubleshooting-patroni-cluster-pg_hba-configuration-not-applied\/","og_site_name":"dbi Blog","article_published_time":"2023-08-16T11:35:45+00:00","article_modified_time":"2023-08-16T11:35:47+00:00","author":"Joan Frey","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Joan Frey","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.dbi-services.com\/blog\/troubleshooting-patroni-cluster-pg_hba-configuration-not-applied\/#article","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/troubleshooting-patroni-cluster-pg_hba-configuration-not-applied\/"},"author":{"name":"Joan Frey","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/c03c47649664fe73b27ce457e99f5b06"},"headline":"Troubleshooting Patroni Cluster: pg_hba Configuration not applied","datePublished":"2023-08-16T11:35:45+00:00","dateModified":"2023-08-16T11:35:47+00:00","mainEntityOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/troubleshooting-patroni-cluster-pg_hba-configuration-not-applied\/"},"wordCount":638,"commentCount":0,"keywords":["hba","Patroni","PostgreSQL"],"articleSection":["Database Administration &amp; Monitoring","Database management","PostgreSQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.dbi-services.com\/blog\/troubleshooting-patroni-cluster-pg_hba-configuration-not-applied\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.dbi-services.com\/blog\/troubleshooting-patroni-cluster-pg_hba-configuration-not-applied\/","url":"https:\/\/www.dbi-services.com\/blog\/troubleshooting-patroni-cluster-pg_hba-configuration-not-applied\/","name":"Troubleshooting Patroni Cluster: pg_hba Configuration not applied - dbi Blog","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/#website"},"datePublished":"2023-08-16T11:35:45+00:00","dateModified":"2023-08-16T11:35:47+00:00","author":{"@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/c03c47649664fe73b27ce457e99f5b06"},"description":"Troubleshoot and resolve pg_hba issues in Patroni. Discover, understand the root causes and solutions.","breadcrumb":{"@id":"https:\/\/www.dbi-services.com\/blog\/troubleshooting-patroni-cluster-pg_hba-configuration-not-applied\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dbi-services.com\/blog\/troubleshooting-patroni-cluster-pg_hba-configuration-not-applied\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.dbi-services.com\/blog\/troubleshooting-patroni-cluster-pg_hba-configuration-not-applied\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/www.dbi-services.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Troubleshooting Patroni Cluster: pg_hba Configuration not applied"}]},{"@type":"WebSite","@id":"https:\/\/www.dbi-services.com\/blog\/#website","url":"https:\/\/www.dbi-services.com\/blog\/","name":"dbi Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/c03c47649664fe73b27ce457e99f5b06","name":"Joan Frey","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/1e650cf665b4d44dd186355827c0b049d2f95c8cbb45fd10d4e7cb255be67ecb?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/1e650cf665b4d44dd186355827c0b049d2f95c8cbb45fd10d4e7cb255be67ecb?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1e650cf665b4d44dd186355827c0b049d2f95c8cbb45fd10d4e7cb255be67ecb?s=96&d=mm&r=g","caption":"Joan Frey"},"url":"https:\/\/www.dbi-services.com\/blog\/author\/joanfrey\/"}]}},"_links":{"self":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/27315","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/users\/87"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/comments?post=27315"}],"version-history":[{"count":1,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/27315\/revisions"}],"predecessor-version":[{"id":27316,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/27315\/revisions\/27316"}],"wp:attachment":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media?parent=27315"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/categories?post=27315"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/tags?post=27315"},{"taxonomy":"type","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/type_dbi?post=27315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}