Skip to content

Commit

Permalink
Allow config override for backup constants
Browse files Browse the repository at this point in the history
  • Loading branch information
DiegoTavares committed Dec 11, 2024
1 parent 991f309 commit 7968673
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion rqd/rqd/rqconstants.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@

# Backup running frames cache. Backup cache is turned off if this path is set to
# None or ""
BACKUP_CACHE_PATH = "/tmp/opencue/running_frames_backup.dat"
BACKUP_CACHE_PATH = ""
BACKUP_CACHE_TIME_TO_LIVE_SECONDS = 60

try:
Expand Down Expand Up @@ -248,6 +248,11 @@
if config.has_section(__host_env_var_section):
RQD_HOST_ENV_VARS = config.options(__host_env_var_section)

if config.has_option(__override_section, "BACKUP_CACHE_PATH"):
BACKUP_CACHE_PATH = config.get(__override_section, "BACKUP_CACHE_PATH")
if config.has_option(__override_section, "BACKUP_CACHE_TIME_TO_LIVE_SECONDS"):
BACKUP_CACHE_TIME_TO_LIVE_SECONDS = config.getint(__override_section, "BACKUP_CACHE_TIME_TO_LIVE_SECONDS")

__docker_mounts = "docker.mounts"
__docker_config = "docker.config"
__docker_images = "docker.images"
Expand Down
4 changes: 4 additions & 0 deletions rqd/rqd/rqcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def __init__(self, optNimbyoff=False):
self.backup_cache_path = rqd.rqconstants.BACKUP_CACHE_PATH
if not os.path.exists(os.path.dirname(self.backup_cache_path)):
os.makedirs(os.path.dirname(self.backup_cache_path))
self.recoverCache()

signal.signal(signal.SIGINT, self.handleExit)
signal.signal(signal.SIGTERM, self.handleExit)
Expand Down Expand Up @@ -232,6 +233,7 @@ def recoverCache(self):
# Ignore frames that failed to be parsed
try:
run_frame.ParseFromString(message_data)
log.warning("Recovered frame %s.%s", run_frame.job_name, run_frame.frame_name)
running_frame = rqd.rqnetwork.RunningFrame(self, run_frame)
running_frame.frameAttendantThread = FrameAttendantThread(
self, run_frame, running_frame, recovery_mode=True)
Expand Down Expand Up @@ -1484,6 +1486,8 @@ def recoverDocker(self):
raise RuntimeError("Invalid state: recovered frame does't contain a container id")
container_id = runFrame.attributes.get("container_id")

# Recovered frame will stream back logs into a new file, therefore write a new header
self.__writeHeader()
try:
log_stream = None
with self.rqCore.docker_lock:
Expand Down

0 comments on commit 7968673

Please sign in to comment.