outposts: handle error in certificate cleanup
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
b90174f153
commit
e70b486f20
|
@ -63,8 +63,6 @@ def should_backup() -> bool:
|
||||||
return False
|
return False
|
||||||
if not CONFIG.y_bool("postgresql.backup.enabled"):
|
if not CONFIG.y_bool("postgresql.backup.enabled"):
|
||||||
return False
|
return False
|
||||||
if settings.DEBUG:
|
|
||||||
return False
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -62,16 +62,21 @@ class DockerInlineSSH:
|
||||||
|
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
"""Cleanup when we're done"""
|
"""Cleanup when we're done"""
|
||||||
os.unlink(self.key_path)
|
try:
|
||||||
with open(self.config_path, "r+", encoding="utf-8") as ssh_config:
|
os.unlink(self.key_path)
|
||||||
start = 0
|
with open(self.config_path, "r+", encoding="utf-8") as ssh_config:
|
||||||
end = 0
|
start = 0
|
||||||
lines = ssh_config.readlines()
|
end = 0
|
||||||
for idx, line in enumerate(lines):
|
lines = ssh_config.readlines()
|
||||||
if line == self.header:
|
for idx, line in enumerate(lines):
|
||||||
start = idx
|
if line == self.header:
|
||||||
if start != 0 and line == f"{FOOTER}\n":
|
start = idx
|
||||||
end = idx
|
if start != 0 and line == f"{FOOTER}\n":
|
||||||
with open(self.config_path, "w+", encoding="utf-8") as ssh_config:
|
end = idx
|
||||||
lines = lines[:start] + lines[end + 2 :]
|
with open(self.config_path, "w+", encoding="utf-8") as ssh_config:
|
||||||
ssh_config.writelines(lines)
|
lines = lines[:start] + lines[end + 2 :]
|
||||||
|
ssh_config.writelines(lines)
|
||||||
|
except OSError:
|
||||||
|
# If we fail deleting a file it doesn't matter that much
|
||||||
|
# since we're just in a container
|
||||||
|
pass
|
||||||
|
|
Reference in New Issue