Skip to content

Commit

Permalink
[issue-1227] remove before patching
Browse files Browse the repository at this point in the history
Signed-off-by: Katarzyna kulpa <[email protected]>
  • Loading branch information
katarzynakulpa committed Sep 30, 2024
1 parent d742eb4 commit a5efe82
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions pkg/scheduler/patcher/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from filecmp import clear_cache, cmp
from os import makedirs, remove
from os.path import basename, dirname, isfile , join
from shutil import copy, move
from shutil import copy
from signal import SIGINT, SIGTERM, signal

import yaml
Expand Down Expand Up @@ -160,8 +160,9 @@ def run():
if manifest.changed:
manifest.backup()
manifest.remove()
log.info('manifest file({}) was removed'.format(manifest.path))
manifest.flush()
log.info('manifest file({}) was patched'.format(manifest.copyPath))
log.info('manifest file({}) was patched'.format(manifest.path))
first_try = False

if first_try:
Expand Down Expand Up @@ -227,7 +228,6 @@ def compile_config(self):
class ManifestFile(File):
def __init__(self, path, volumes, config_path, backup_folder, config_unschedulable_pods):
self.path = path
self.copyPath = path + "_1"
self.backup_folder = backup_folder
self.volumes = volumes
self.config_path = config_path
Expand All @@ -238,14 +238,6 @@ def backup(self):
backup_path = join(self.backup_folder,basename(self.path))
copy(self.path, backup_path)

def moveManifest(self):
move(self.path, self.copyPath)
log.info('{} moved to {}'.format(self.path, self.copyPath))

def restoreManifest(self):
move(self.copyPath, self.path)
log.info('{} restored from {}'.format(self.copyPath, self.path))

def restore(self):
backup_path = join(self.backup_folder,basename(self.path))
copy(backup_path, self.path)
Expand All @@ -260,11 +252,6 @@ def load(self):
log.debug('manifest {} loaded'.format(self.path))
self.changed = False

def flushMovedManifest(self):
with open(self.copyPath, 'w') as f:
yaml.dump(self.content, f)
log.debug('manifest {} dumped'.format(self.copyPath))

def flush(self):
with open(self.path, 'w') as f:
yaml.dump(self.content, f)
Expand Down

0 comments on commit a5efe82

Please sign in to comment.