Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
1c37cff
migrated - add object store clean up script - to sn09
gsaudade99 Nov 27, 2025
76be6f5
migrate to maintenance instead
gsaudade99 Nov 27, 2025
fc16410
add crontab to the cleanup script
gsaudade99 Nov 27, 2025
85a8530
Update roles/usegalaxy-eu.galaxy-cleanup/defaults/main.yml
gsaudade99 Dec 3, 2025
79ea697
Update group_vars/maintenance.yml
gsaudade99 Dec 3, 2025
254be6b
Update roles/usegalaxy-eu.galaxy-cleanup/templates/galaxy_cleanup_obj…
gsaudade99 Dec 3, 2025
745dbe2
Update roles/usegalaxy-eu.galaxy-cleanup/defaults/main.yml
gsaudade99 Dec 3, 2025
2914b70
Update roles/usegalaxy-eu.galaxy-cleanup/tasks/main.yml
gsaudade99 Dec 3, 2025
e715b08
Update roles/usegalaxy-eu.galaxy-cleanup/tasks/main.yml
gsaudade99 Dec 3, 2025
0e0b09b
Update roles/usegalaxy-eu.galaxy-cleanup/templates/galaxy_cleanup_obj…
gsaudade99 Dec 3, 2025
16b5891
Update roles/usegalaxy-eu.galaxy-cleanup/tasks/main.yml
gsaudade99 Dec 3, 2025
f3e3b10
Update roles/usegalaxy-eu.galaxy-cleanup/tasks/main.yml
gsaudade99 Dec 3, 2025
cc7f9b6
Update roles/usegalaxy-eu.galaxy-cleanup/tasks/main.yml
gsaudade99 Dec 3, 2025
fc12672
change dir name
gsaudade99 Dec 3, 2025
5199a0d
add check to scratchstorage + warning message
gsaudade99 Dec 4, 2025
7e0842a
Update roles/usegalaxy_eu.galaxy_cleanup/tasks/main.yml
gsaudade99 Dec 4, 2025
539498e
Update roles/usegalaxy_eu.galaxy_cleanup/tasks/main.yml
gsaudade99 Dec 4, 2025
932572e
Update roles/usegalaxy_eu.galaxy_cleanup/tasks/main.yml
gsaudade99 Dec 4, 2025
2d91941
change role name on playbook
gsaudade99 Dec 4, 2025
7e9c087
use reject condition instead
gsaudade99 Dec 10, 2025
a40f5c5
fail when galaxy_cleanup_scratchstorage is not defined
gsaudade99 Dec 10, 2025
15d56b5
Update roles/usegalaxy_eu.galaxy_cleanup/templates/clean_scratch_stor…
gsaudade99 Dec 10, 2025
6f5e991
rm block + change file name
gsaudade99 Dec 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions group_vars/maintenance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ galaxy_user:
uid: 999
shell: /bin/bash

# *****************************************************************************************
# WARNING: Adding or modifying entries in `galaxy_cleanup_scratchstorage` will cause data
# in the specified object stores to be **deleted** after the defined retention
# period (e.g., `days: 60`). Ensure you only include object stores that are meant
# to be cleaned up, and double‑check the `objectstore_id` values before saving.
# *****************************************************************************************
galaxy_cleanup_scratchstorage:
- objectstore_id: 's3_scratch_netapp01'
days: 60

# Role: hxr.postgres-connection
# Role: usegalaxy-eu.galaxy-slurp
postgres_user: galaxy
Expand Down
1 change: 1 addition & 0 deletions maintenance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
- galaxyproject.gxadmin
- usegalaxy-eu.galaxy-slurp
- usegalaxy_eu.fs_maintenance
- usegalaxy_eu.galaxy_cleanup # Cleanup the Galaxy objectstores and old datasets
# - usegalaxy-eu.htcondor_release
# - usegalaxy-eu.fix-unscheduled-workflows
- usegalaxy-eu.fix-ancient-ftp-data
Expand Down
13 changes: 0 additions & 13 deletions roles/usegalaxy-eu.galaxy-cleanup/tasks/main.yml

This file was deleted.

18 changes: 18 additions & 0 deletions roles/usegalaxy_eu.galaxy_cleanup/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
# Example:
# galaxy_cleanup_scratchstorage:
# - objectstore_id: ''
# days: 60

# *****************************************************************************************
# WARNING: Adding or modifying entries in `galaxy_cleanup_objectstores` will cause data
# in the specified object stores to be **deleted** after the defined retention
# period (e.g., `days: 60`). Ensure you only include object stores that are meant
# to be cleaned up, and double‑check the `objectstore_id` values before saving.
# *****************************************************************************************
galaxy_cleanup_scratchstorage: []

# Cron schedule for galaxy cleanup objectstores script
# Default: runs daily at 1:00 AM
galaxy_cleanup_minute: 0
galaxy_cleanup_hour: 1
25 changes: 25 additions & 0 deletions roles/usegalaxy_eu.galaxy_cleanup/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
- name: Check that all objectstore_id include 'scratch'
assert:
that:
- galaxy_cleanup_scratchstorage | length > 0
- galaxy_cleanup_scratchstorage
| rejectattr('objectstore_id', 'search', 'scratch')
| list
| length == 0
fail_msg: "Found objectstore_id entries that do NOT contain 'scratch'"
success_msg: "All objectstore_id values contain 'scratch'"

- name: Install cleanup scratch script
template:
src: "clean_scratch_storage.sh.j2"
dest: "/usr/local/bin/clean_scratch_storage.sh"
mode: "0555"

- name: Schedule Galaxy cleanup objectstore script
ansible.builtin.cron:
name: "Galaxy cleanup scratch"
job: "/usr/local/bin/clean_scratch_storage.sh"
minute: "{{ galaxy_cleanup_minute }}"
hour: "{{ galaxy_cleanup_hour }}"
user: "{{ galaxy_user.name }}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
##
## This file is maintained by Ansible - CHANGES WILL BE OVERWRITTEN
##
set -e

{% for item in galaxy_cleanup_scratchstorage %}
{{ galaxy_venv_dir }}/bin/python {{ galaxy_server_dir }}/scripts/cleanup_datasets/pgcleanup.py -c {{ galaxy_config_file }} -o {{ item.days }} -l {{ galaxy_log_dir }} -w 128MB --object-store-id {{ item.objectstore_id }} purge_old_hdas 2>&1 | tee -a {{ galaxy_log_dir }}/cleanup-$(date --rfc-3339=seconds)-purge_old_hdas.log
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if item.objectstore_id is empty or wrong/does-not-exist?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that the jinja will try to render nothing (empty string, thus becoming --object-store-id purge_old_hdas). Looking at pgcleanup.py script it would fail because there is no args.actions for parsing.

We can add and extra tasks that checks if galaxy_cleanup_objectstores is empty and galaxy_cleanup_objectstores.objectstore_id does not include "scracth". And if we still don't feel "safe" we can add this condition inside the template

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This template task should not be executed if galaxy_cleanup_scratchstorage does not match the expression in the assertion task above:
galaxy_cleanup_scratchstorage | selectattr('objectstore_id', 'search', 'scratch') | list | length > 0

Copy link
Contributor

@kysrpex kysrpex Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the following failures are expected in these kind of cases (so we should be fine).

fatal: [localhost]: FAILED! => {"changed": false, "msg": "Task failed: Finalization of task args for 'ansible.builtin.copy' failed: Error while resolving value for 'content': object of type 'dict' has no attribute 'key_missing'"}

fatal: [localhost]: FAILED! => {"changed": false, "msg": "Task failed: Finalization of task args for 'ansible.builtin.copy' failed: Error while resolving value for 'content': 'missing_var' is undefined"}

Copy link
Contributor

@mira-miracoli mira-miracoli Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a complete playbook failure is the only way we can reliably see broken roles / variables in Jenkins.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we pass a faulty --object-store-id to the pgcleanup.py, do we know how it will behave?

Copy link
Contributor Author

@gsaudade99 gsaudade99 Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It failed pretty quickly and just roolbacks the changes

(venv) galaxy@sn09:~$ /opt/galaxy/venv/bin/python /opt/galaxy/server/scripts/cleanup_datasets/pgcleanup.py --dry-run -c /opt/galaxy/config/galaxy.yml -o 60 -l /var/log/galaxy -w 128MB --object-store-id im-wrong purge_old_hdas 2>&1 | tee -a /var/log/galaxy/cleanup-$(date --rfc-3339=seconds)-purge_old_hdas.log
tee: '15:00:42+01:00-purge_old_hdas.log': Permission denied
2025-12-10 15:00:46,801 WARNING _update_raw_config_from_kwargs(): Option openai_api_key has been deprecated in favor of ai_api_key
2025-12-10 15:00:46,802 WARNING resolve(): Trying to resolve path for the 'email_ban_file' option but it's empty/None
2025-12-10 15:00:48,109 INFO  run(): Running action 'purge_old_hdas':
2025-12-10 15:00:48,439 INFO  _init(): Initializing object store for action purge_old_hdas
2025-12-10 15:00:48,440 INFO  conn(): Connecting to database with URL: postgresql://galaxy:***@sn11.galaxyproject.eu/galaxy
2025-12-10 15:00:48,535 INFO  conn(): Setting work_mem to 128MB
2025-12-10 15:00:48,538 INFO  _dry_run_event(): Not executing event creation (increments sequence even when rolling back), using an old event ID (46003) for dry run
2025-12-10 15:00:48,539 INFO  _execute(): Executing SQL
2025-12-10 15:00:48,552 INFO  _execute(): Database status: SELECT 0
2025-12-10 15:00:48,552 INFO  _update(): Update resulted in no changes, rolling back transaction
2025-12-10 15:00:48,552 INFO  recalculate_disk_usage(): Recalculating disk usage for users whose data were purged
2025-12-10 15:00:48,553 INFO  run(): Finished purge_old_hdas

{% endfor %}
Loading