Skip to content

Commit 98c15c4

Browse files
committed
feat: add a cronjob and its documentation
1 parent 84506c5 commit 98c15c4

3 files changed

Lines changed: 76 additions & 0 deletions

File tree

docs/admin/how-to/install/installing.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,3 +353,11 @@ helm install --timeout 3600s <release-name> ./diracx-charts/diracx/ -f my_values
353353
!!! success "Congrats, you have installed DiracX"
354354

355355
However, it does not do anything so far... See the [following steps](register-the-admin-vo.md)
356+
357+
## AuthDB Cleanup CronJob
358+
359+
Expired refresh tokens and device flows will accumulate in the AuthDB over time.
360+
This CronJob must be deployed to periodically remove them on the 1st of every month:
361+
```bash
362+
kubectl apply -f ./diracx-charts/k3s/manifests/cleanup-authdb-cronjob.yaml
363+
```

k3s/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,14 @@ git add default.yml
263263
git commit -m 'Initial config'
264264
```
265265

266+
## AuthDB Cleanup CronJob
267+
268+
Expired refresh tokens and device flows will accumulate in the AuthDB over time.
269+
This CronJob must be deployed to periodically remove them on the 1st of every month:
270+
```bash
271+
kubectl apply -f ./manifest/cleanup-authdb-cronjob.yaml
272+
```
273+
266274
## Post-install tips
267275

268276
In case you would like to make us of the services installed (e.g. MySQL or OpenSearch) from outisde the kubernetes cluster, there are different solutions and configurations to make. LoadBalancer, NodePort, or Ingress are the options. One of these would need to be set out.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
apiVersion: batch/v1
2+
kind: CronJob
3+
metadata:
4+
name: diracx-cleanup-authdb
5+
namespace: diracx
6+
spec:
7+
schedule: "0 0 1 * *"
8+
jobTemplate:
9+
spec:
10+
template:
11+
spec:
12+
restartPolicy: OnFailure
13+
containers:
14+
- name: cleanup
15+
image: ghcr.io/diracgrid/diracx/services:dev
16+
command:
17+
- /bin/sh
18+
- -c
19+
- |
20+
/opt/conda/bin/python -c "
21+
import asyncio
22+
import os
23+
from diracx.core.settings import AuthSettings
24+
from diracx.db.sql import AuthDB
25+
from diracx.logic.auth.token import cleanup_expired_data
26+
import logging
27+
28+
logging.basicConfig(
29+
level=logging.INFO
30+
)
31+
32+
async def main():
33+
db_url = os.getenv('DIRACX_DB_URL_AUTHDB')
34+
settings = AuthSettings()
35+
db = AuthDB(db_url)
36+
37+
async with db.engine_context():
38+
async with db:
39+
await cleanup_expired_data(db, settings)
40+
41+
asyncio.run(main())
42+
"
43+
envFrom:
44+
- secretRef:
45+
name: diracx-secrets
46+
- secretRef:
47+
name: diracx-sql-connection-urls
48+
- secretRef:
49+
name: diracx-dynamic-secrets
50+
volumeMounts:
51+
- name: keystore
52+
mountPath: /keystore/jwks.json
53+
subPath: jwks.json
54+
volumes:
55+
- name: keystore
56+
secret:
57+
secretName: diracx-jwks
58+
items:
59+
- key: jwks.json
60+
path: jwks.json

0 commit comments

Comments
 (0)