Skip to content

Commit

Permalink
add debug logging to AnsibleRunnerCleanUpService
Browse files Browse the repository at this point in the history
  • Loading branch information
dangel101 authored and mwperina committed Feb 7, 2023
1 parent f21a4b1 commit fbdcebf
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ public void scheduleJob() {
}

private void checkExecutionTimeStamp() {
log.debug("Started AnsibleRunnerCleanUp Service");
int artifactsLifeTime = Config.<Integer> getValue(ConfigValues.AnsibleRunnerArtifactsLifetimeInDays);
Stream.of(new File(AnsibleConstants.ANSIBLE_RUNNER_PATH.toString()).listFiles()).forEach(file -> {
log.debug("Evaluating if '{}' should be removed", file.getAbsolutePath());
long creationInDays;
try {
creationInDays = Files.readAttributes(file.toPath(), BasicFileAttributes.class)
Expand All @@ -61,6 +63,7 @@ private void checkExecutionTimeStamp() {
}
long todayInDays = FileTime.fromMillis(new Date().getTime()).to(TimeUnit.DAYS);
if (todayInDays - creationInDays > artifactsLifeTime) {
log.debug("Deleting directory '{}'", file.getAbsolutePath());
try {
Files.walk(Paths.get(file.getAbsolutePath()))
.sorted(Comparator.reverseOrder())
Expand All @@ -72,5 +75,6 @@ private void checkExecutionTimeStamp() {
}
}
});
log.debug("Finished AnsibleRunnerCleanUp Service");
}
}

0 comments on commit fbdcebf

Please sign in to comment.