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

Merge branch 'script-clean-database-and-gx-histories' into 'main'

Resolve "Cron Job to clean database and galaxy"

Closes #15

See merge request !13
parents 4646b038 6f84535f
No related branches found
No related tags found
1 merge request!13Resolve "Cron Job to clean database and galaxy"
Pipeline #125218 passed
...@@ -29,7 +29,8 @@ from analysis.model_schemas import ( ...@@ -29,7 +29,8 @@ from analysis.model_schemas import (
SystemOutSchema, SystemOutSchema,
) )
session_expiry = 2628000 # session_expiry = 2628000
session_expiry = 10
router = Router() router = Router()
......
...@@ -30,11 +30,31 @@ class Command(BaseCommand): ...@@ -30,11 +30,31 @@ class Command(BaseCommand):
email=options["galaxyemail"], email=options["galaxyemail"],
galaxy_instance=gi, galaxy_instance=gi,
).first() ).first()
print(gu)
histories = AnalysisHistory.objects.filter( histories = AnalysisHistory.objects.filter(
analysis_owner=gu, session__expire_date__lt=datetime.now().astimezone() analysis_owner=gu, session__expire_date__lt=datetime.now().astimezone()
) )
for h in histories: for h in histories:
print(f"Delete expire history {h.name} expired : {h.session.expire_date}") 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: ...@@ -89,8 +89,8 @@ spec:
resources: resources:
{{- toYaml .Values.resources | nindent 12 }} {{- toYaml .Values.resources | nindent 12 }}
volumeMounts: volumeMounts:
- mountPath: /code/public/static # - mountPath: /code/public/static
name: server-static # name: server-static
- mountPath: /uploaded-files - mountPath: /uploaded-files
name: uploaded-files name: uploaded-files
{{- with .Values.nodeSelector }} {{- with .Values.nodeSelector }}
...@@ -106,9 +106,9 @@ spec: ...@@ -106,9 +106,9 @@ spec:
{{- toYaml . | nindent 8 }} {{- toYaml . | nindent 8 }}
{{- end }} {{- end }}
volumes: volumes:
- name: server-static # - name: server-static
persistentVolumeClaim: # persistentVolumeClaim:
claimName: server-static # claimName: server-static
- name: uploaded-files - name: uploaded-files
emptyDir: emptyDir:
sizeLimit: 5Gi 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.
Finish editing this message first!
Please register or to comment