File: avoid_overwriting_configuration_during_boostrap.patch

package info (click to toggle)
patroni 4.0.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,708 kB
  • sloc: python: 28,942; sh: 565; makefile: 29
file content (41 lines) | stat: -rw-r--r-- 2,111 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
commit a3776e0dfb2f0c5a9e5174f948122b8fb33ceebc
Author: Michael Banck <michael.banck@credativ.de>
Date:   Fri Jul 29 14:55:15 2022 +0200

    Make backup copies of configuration files in config_dir.
    
    Before, the .backup files were always done in the data directory. However, if
    there is a distinct configuration directory, it seems logical to put them
    there. If config_dir is not configured, it defaults back to the data directory,
    so this will not change things for setups where postgresql.conf is in the data
    directory.
    
    On the other hand, it will help with setups where postgresql.conf is outside
    the data directory and has local changes. In this case, those no longer get
    overwritten on boostrap/clone from the primary's backup configuration file that
    is streamed to the boostrapped node.
    
    Close #2370

Index: patroni/patroni/postgresql/config.py
===================================================================
--- patroni.orig/patroni/postgresql/config.py
+++ patroni/patroni/postgresql/config.py
@@ -510,7 +510,7 @@ class ConfigHandler(object):
             try:
                 for f in self._configuration_to_save:
                     config_file = os.path.join(self._config_dir, f)
-                    backup_file = os.path.join(self._postgresql.data_dir, f + '.backup')
+                    backup_file = os.path.join(self._config_dir, f + '.backup')
                     if os.path.isfile(config_file):
                         shutil.copy(config_file, backup_file)
                         self.set_file_permissions(backup_file)
@@ -523,7 +523,7 @@ class ConfigHandler(object):
         try:
             for f in self._configuration_to_save:
                 config_file = os.path.join(self._config_dir, f)
-                backup_file = os.path.join(self._postgresql.data_dir, f + '.backup')
+                backup_file = os.path.join(self._config_dir, f + '.backup')
                 if not os.path.isfile(config_file):
                     if os.path.isfile(backup_file):
                         shutil.copy(backup_file, config_file)