Remove unnecessary usage of relpath (#1002)

`os.path.relpath` depends on being able to resolve the working directory.
This will fail if Patroni is started in a directory that is later unlinked from the filesystem, creating an unnecessary exception when loading from DCS.
This commit is contained in:
Ants Aasma
2019-03-11 12:31:06 +01:00
committed by Alexander Kukushkin
parent 9e19b43869
commit 2204454094
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -299,7 +299,7 @@ class Consul(AbstractDCS):
nodes = {}
for node in results:
node['Value'] = (node['Value'] or b'').decode('utf-8')
nodes[os.path.relpath(node['Key'], path).replace('\\', '/')] = node
nodes[node['Key'][len(path):].lstrip('/')] = node
# get initialize flag
initialize = nodes.get(self._INITIALIZE)
+1 -1
View File
@@ -454,7 +454,7 @@ class Etcd(AbstractDCS):
def _load_cluster(self):
try:
result = self.retry(self._client.read, self.client_path(''), recursive=True)
nodes = {os.path.relpath(node.key, result.key).replace('\\', '/'): node for node in result.leaves}
nodes = {node.key[len(result.key):].lstrip('/'): node for node in result.leaves}
# get initialize flag
initialize = nodes.get(self._INITIALIZE)