Skip to content

Commit

Permalink
Add SALOBJ logging for staging area and butler cleanup messages
Browse files Browse the repository at this point in the history
  • Loading branch information
srp3rd committed Apr 29, 2024
1 parent 2ad7a12 commit 15900b4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
12 changes: 8 additions & 4 deletions python/lsst/ctrl/oods/cacheCleaner.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ class CacheCleaner(object):
details on which directories to clean, and how often
"""

def __init__(self, config):
def __init__(self, config, csc=None):
self.config = config
self.csc = csc
self.files_and_directories = self.config["clearEmptyDirectoriesAndOldFiles"]
self.only_empty_directories = []
if "clearEmptyDirectories" in self.config:
Expand All @@ -55,13 +56,16 @@ async def run_tasks(self):
self.terminate = False
loop = asyncio.get_running_loop()
while True:
LOGGER.info("Cleaning %s", self.files_and_directories)
if self.csc:
self.csc.log.info("Cleaning %s", self.files_and_directories)
try:
with concurrent.futures.ThreadPoolExecutor(max_workers=1) as pool:
await loop.run_in_executor(pool, self.clean)
except Exception as e:
LOGGER.info("Clean failure: %s", e)
LOGGER.info("done cleaning; waiting %d seconds", self.seconds)
if self.csc:
self.csc.log.info("Clean failure: %s", e)
if self.csc:
self.csc.log.info("done cleaning; waiting %d seconds", self.seconds)
await asyncio.sleep(self.seconds)
if self.terminate:
return
Expand Down
9 changes: 6 additions & 3 deletions python/lsst/ctrl/oods/gen3ButlerIngester.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,17 @@ async def clean_task(self):
"""run the clean() method at the configured interval"""
seconds = TimeInterval.calculateTotalSeconds(self.scanInterval)
while True:
LOGGER.info("butler repo cleaning started")
if self.csc:
self.csc.log.info("butler repo cleaning started")
try:
loop = asyncio.get_running_loop()
with concurrent.futures.ThreadPoolExecutor(max_workers=1) as pool:
await loop.run_in_executor(pool, self.clean)
except Exception as e:
LOGGER.info("Exception: %s", e)
LOGGER.info("done cleaning butler repo; sleeping for %d seconds", seconds)
if self.csc:
self.csc.log.info("Exception: %s", e)
if self.csc:
self.csc.log.info("done cleaning butler repo; sleeping for %d seconds", seconds)
await asyncio.sleep(seconds)

def clean(self):
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/ctrl/oods/oods_csc.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def __init__(self, name, initial_state=salobj.State.STANDBY):
self.ingester_config = self.config["ingester"]

cache_config = self.config["cacheCleaner"]
self.cache_cleaner = CacheCleaner(cache_config)
self.cache_cleaner = CacheCleaner(cache_config, self)

async def send_imageInOODS(self, info):
"""Send SAL message that the images has been ingested into the OODS
Expand Down

0 comments on commit 15900b4

Please sign in to comment.