Skip to content
Snippets Groups Projects
Commit 6f84535f authored by Remi  PLANEL's avatar Remi PLANEL
Browse files

Resolve "Cron Job to clean database and galaxy"

parent 4646b038
No related branches found
No related tags found
1 merge request!13Resolve "Cron Job to clean database and galaxy"
......@@ -29,7 +29,8 @@ from analysis.model_schemas import (
SystemOutSchema,
)
session_expiry = 2628000
# session_expiry = 2628000
session_expiry = 10
router = Router()
......
......@@ -30,11 +30,31 @@ class Command(BaseCommand):
email=options["galaxyemail"],
galaxy_instance=gi,
).first()
print(gu)
histories = AnalysisHistory.objects.filter(
analysis_owner=gu, session__expire_date__lt=datetime.now().astimezone()
)
for h in histories:
print(f"Delete expire history {h.name} expired : {h.session.expire_date}")
h.delete()
try:
h.analysis_owner.obj_gi.histories.delete(id_=h.galaxy_id, purge=True)
except ConnectionError as e:
print(e)
raise e
else:
h.delete()
# clean orphan galaxy histories
histories = gu.obj_gi.gi.histories.get_histories()
histories_from_host = [
h for h in histories if settings.DF_HOSTNAME in h["tags"]
]
for h in histories_from_host:
galaxy_id = h["id"]
# check if in database.
# if not, purge it
history = AnalysisHistory.objects.filter(galaxy_id=galaxy_id)
if not history.exists():
print(f"Delete orphan history {h['name']}.")
gu.obj_gi.gi.histories.delete_history(galaxy_id, purge=True)
......@@ -89,8 +89,8 @@ spec:
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
- mountPath: /code/public/static
name: server-static
# - mountPath: /code/public/static
# name: server-static
- mountPath: /uploaded-files
name: uploaded-files
{{- with .Values.nodeSelector }}
......@@ -106,9 +106,9 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: server-static
persistentVolumeClaim:
claimName: server-static
# - name: server-static
# persistentVolumeClaim:
# claimName: server-static
- name: uploaded-files
emptyDir:
sizeLimit: 5Gi
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: "uploaded-files"
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
storageClassName: {{ .Values.uploadedFile.storageClassName }}
status: {}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment