From 78c9a2fe6cd0deb4cd46b54001049cd8a239d82f Mon Sep 17 00:00:00 2001
From: Alexander Kukushkin <cyberdemn@gmail.com>
Date: Tue, 3 Jan 2023 15:22:49 +0100
Subject: [PATCH 1/2] Compatibility with some old modules

- old click differently handles argument names
- old pytest doesn't like `from mock import call`

Close: https://github.com/zalando/patroni/issues/2508
Close: https://github.com/zalando/patroni/issues/2512
---
 patroni/ctl.py           | 2 +-
 tests/test_ctl.py        | 2 +-
 tests/test_kubernetes.py | 5 +++--
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/patroni/ctl.py b/patroni/ctl.py
index 2568f83ee..ec780731c 100644
--- a/patroni/ctl.py
+++ b/patroni/ctl.py
@@ -143,7 +143,7 @@ def load_config(path, dcs_url):
 @click.group()
 @click.option('--config-file', '-c', help='Configuration file',
               envvar='PATRONICTL_CONFIG_FILE', default=CONFIG_FILE_PATH)
-@click.option('--dcs-url', '--dcs', '-d', help='The DCS connect url', envvar='DCS_URL')
+@click.option('--dcs-url', '--dcs', '-d', 'dcs_url', help='The DCS connect url', envvar='DCS_URL')
 @option_insecure
 @click.pass_context
 def ctl(ctx, config_file, dcs_url, insecure):
diff --git a/tests/test_ctl.py b/tests/test_ctl.py
index dbb77c4df..87b8e6ca9 100644
--- a/tests/test_ctl.py
+++ b/tests/test_ctl.py
@@ -39,7 +39,7 @@ def test_load_config(self, mock_logger_debug):
             self.assertRaises(PatroniCtlException, load_config, './non-existing-config-file', None)
 
         with patch('os.path.exists', Mock(return_value=True)), \
-             patch('patroni.config.Config._load_config_path', Mock(return_value={})):
+                patch('patroni.config.Config._load_config_path', Mock(return_value={})):
             load_config(CONFIG_FILE_PATH, None)
             mock_logger_debug.assert_called_once()
             self.assertEqual(('Ignoring configuration file "%s". It does not exists or is not readable.',
diff --git a/tests/test_kubernetes.py b/tests/test_kubernetes.py
index 2dd1fd70f..27238a1c1 100644
--- a/tests/test_kubernetes.py
+++ b/tests/test_kubernetes.py
@@ -1,11 +1,12 @@
 import base64
 import datetime
 import json
+import mock
 import socket
 import time
 import unittest
 
-from mock import call, Mock, PropertyMock, mock_open, patch
+from mock import Mock, PropertyMock, mock_open, patch
 from patroni.dcs.kubernetes import k8s_client, k8s_config, K8sConfig, K8sConnectionFailed,\
         K8sException, K8sObject, Kubernetes, KubernetesError, KubernetesRetriableException,\
         Retry, RetryFailedError, SERVICE_HOST_ENV_NAME, SERVICE_PORT_ENV_NAME
@@ -134,7 +135,7 @@ def test_load_kube_config(self):
             mock_atexit.assert_called_once()
             mock_remove.side_effect = OSError
             mock_atexit.call_args[0][0]()  # call _cleanup_temp_files
-            mock_remove.assert_has_calls([call('1.tmp'), call('2.tmp')])
+            mock_remove.assert_has_calls([mock.call('1.tmp'), mock.call('2.tmp')])
 
 
 @patch('urllib3.PoolManager.request')

From d44d32123cae4d607956b5b62ccf0b1dfdb8a546 Mon Sep 17 00:00:00 2001
From: Alexander Kukushkin <cyberdemn@gmail.com>
Date: Tue, 3 Jan 2023 15:38:20 +0100
Subject: [PATCH 2/2] Bump version and update release notes

---
 docs/releases.rst  | 10 ++++++++++
 patroni/version.py |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/docs/releases.rst b/docs/releases.rst
index 48c298372..17828e1b8 100644
--- a/docs/releases.rst
+++ b/docs/releases.rst
@@ -3,6 +3,16 @@
 Release notes
 =============
 
+Version 2.1.7
+-------------
+
+**Bugfixes**
+
+- Fixed little incompatibilities with legacy python modules (Alexander Kukushkin)
+
+  They prevented from building/running Patroni on Debian buster/Ubuntu bionic.
+
+
 Version 2.1.6
 -------------
 
diff --git a/patroni/version.py b/patroni/version.py
index da04cc33c..bc6379c18 100644
--- a/patroni/version.py
+++ b/patroni/version.py
@@ -1 +1 @@
-__version__ = '2.1.6'
+__version__ = '2.1.7'
