outposts: handle error in certificate cleanup

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2022-01-04 22:53:37 +01:00
parent b90174f153
commit e70b486f20
2 changed files with 18 additions and 15 deletions

View File

@ -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

View File

@ -62,6 +62,7 @@ class DockerInlineSSH:
def cleanup(self): def cleanup(self):
"""Cleanup when we're done""" """Cleanup when we're done"""
try:
os.unlink(self.key_path) os.unlink(self.key_path)
with open(self.config_path, "r+", encoding="utf-8") as ssh_config: with open(self.config_path, "r+", encoding="utf-8") as ssh_config:
start = 0 start = 0
@ -75,3 +76,7 @@ class DockerInlineSSH:
with open(self.config_path, "w+", encoding="utf-8") as ssh_config: with open(self.config_path, "w+", encoding="utf-8") as ssh_config:
lines = lines[:start] + lines[end + 2 :] lines = lines[:start] + lines[end + 2 :]
ssh_config.writelines(lines) 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