diff --git a/backend/analysis/api.py b/backend/analysis/api.py index ce4129ea5a67338cba95ac54298a93b72f0c25b3..e9cdc15e5f794f89a371bd8533d3fc35bdfddf5d 100644 --- a/backend/analysis/api.py +++ b/backend/analysis/api.py @@ -29,7 +29,8 @@ from analysis.model_schemas import ( SystemOutSchema, ) -session_expiry = 2628000 +# session_expiry = 2628000 +session_expiry = 10 router = Router() diff --git a/backend/analysis/management/commands/clear-sessions-history.py b/backend/analysis/management/commands/clear-sessions-history.py index 8a53fc6aaa9250b3e04c7340453dafbf25b1178f..928615dc21cb2307bbff031b66bb1e5f25d6a3aa 100644 --- a/backend/analysis/management/commands/clear-sessions-history.py +++ b/backend/analysis/management/commands/clear-sessions-history.py @@ -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) diff --git a/deploy/charts/djangoninja/templates/deployment.yaml b/deploy/charts/djangoninja/templates/deployment.yaml index e92f4dda2f4b13c422c0087702dfba7ca0f7c463..7eb4b594be90f95b4d14745949f0fbe111fb2756 100644 --- a/deploy/charts/djangoninja/templates/deployment.yaml +++ b/deploy/charts/djangoninja/templates/deployment.yaml @@ -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 diff --git a/deploy/templates/pvc-uploaded-files.yaml b/deploy/templates/pvc-uploaded-files.yaml deleted file mode 100644 index 8319f6699bc2570d56b6e07a7cd248f2dd4e0c99..0000000000000000000000000000000000000000 --- a/deploy/templates/pvc-uploaded-files.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: "uploaded-files" -spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 10Gi - storageClassName: {{ .Values.uploadedFile.storageClassName }} -status: {}