Skip to content

Commit

Permalink
Fix cronjob + add more verbose logs
Browse files Browse the repository at this point in the history
  • Loading branch information
benoit74 committed Nov 24, 2023
1 parent 15a729f commit 8426f3f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
19 changes: 13 additions & 6 deletions zim/tmp-kiwix/cleanup-old-files.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,24 @@ def process_deletion(
):
"""Process file and directory deletion based on the dry-run status."""
if dry_run:
print(f"These files would be deleted:")
print("\n".join(sorted(str(path) for path in files_to_delete)))
print("\nEmpty subdirectories that would be deleted:")
print(f"{len(files_to_delete)} files would be deleted:")
print(
"\n".join(
sorted(f"{path} ({path.stat().st_mtime})" for path in files_to_delete)
)
)
print(
f"\n{len(empty_directories_to_delete)} empty subdirectories would be deleted:"
)
print("\n".join(sorted(str(path) for path in empty_directories_to_delete)))
else:
print(f"Deleting files:")
print(f"Deleting {len(files_to_delete)} files:")
for file_path in files_to_delete:
message = f"Deleted: {file_path} ({file_path.stat().st_mtime})"
file_path.unlink()
print(f"Deleted: {file_path}")
print(message)

print(f"\nDeleting empty subdirectories:")
print(f"\nDeleting {len(empty_directories_to_delete)} empty subdirectories:")
for directory_path in empty_directories_to_delete:
try:
directory_path.rmdir()
Expand Down
8 changes: 4 additions & 4 deletions zim/tmp-kiwix/tmp-kiwix-cleanup.cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ spec:
- image: ghcr.io/kiwix/maintenance:latest
imagePullPolicy: Always
name: jobrunner
environment:
env:
- name: INSTALL_SCRIPTS
value: github://kiwix/k8s/zim/tmp-kiwix/cleanup-old-files.py\n
value: github://kiwix/k8s/zim/tmp-kiwix/cleanup-old-files.py
volumeMounts:
- mountPath: "/data/tmp"
name: tmp-kiwix-volume
readOnly: true
workingDir: /data/tmp
args: ["cleanup-old-files", "-f", "/data/tmp/ci/dev_preview", "-n", "30", "-d"]
workingDir: /data/tmp
args: ["cleanup-old-files.py", "-f", "/data/tmp/ci/dev_preview", "-n", "30", "-d"]
resources:
requests:
cpu: 100m
Expand Down

0 comments on commit 8426f3f

Please sign in to comment.