Skip to content

Feat: authdb tables cleanup#815

Merged
aldbr merged 6 commits intoDIRACGrid:mainfrom
HeloiseJoffe:feat/authdb-tables-cleanup
Mar 18, 2026
Merged

Feat: authdb tables cleanup#815
aldbr merged 6 commits intoDIRACGrid:mainfrom
HeloiseJoffe:feat/authdb-tables-cleanup

Conversation

@HeloiseJoffe
Copy link
Copy Markdown
Contributor

Closes DIRACGrid/diracx-charts#222

Changes:

  • Add functions to cleanup expired refresh tokens and flows from the AuthDB
  • Add tests for each cleanup function in the DB

The global cleanup function can be called with this kubernetes cronjob :

metadata:
  name: diracx-cleanup-authdb
  namespace: diracx
spec:
  schedule: "0 0 1 * *"
  jobTemplate:
    spec:
      template:
        spec:
          restartPolicy: OnFailure
          containers:
            - name: cleanup
              image: ghcr.io/diracgrid/diracx/services:dev
              command:
                - /bin/sh
                - -c
                - |
                  /opt/conda/bin/python -c "
                  import asyncio
                  import os
                  from diracx.core.settings import AuthSettings
                  from diracx.db.sql import AuthDB
                  from diracx.logic.auth.token import cleanup_expired_data
                  import logging

                  logging.basicConfig(
                    level=logging.INFO
                  )

                  async def main():
                    db_url = os.getenv('DIRACX_DB_URL_AUTHDB')
                    settings = AuthSettings()
                    db = AuthDB(db_url)

                    async with db.engine_context():
                      async with db:
                        await cleanup_expired_data(db, settings)

                  asyncio.run(main())
                  "
              envFrom:
                - secretRef:
                    name: diracx-secrets
                - secretRef:
                    name: diracx-sql-connection-urls
                - secretRef:
                    name: diracx-dynamic-secrets
              volumeMounts:
                - name: keystore
                  mountPath: /keystore/jwks.json
                  subPath: jwks.json
          volumes:
            - name: keystore
              secret: 
                secretName: diracx-jwks
                items:
                  - key: jwks.json
                    path: jwks.json

Where could I add documentation to guide administrators in setting up the cronjob?

@read-the-docs-community
Copy link
Copy Markdown

read-the-docs-community bot commented Mar 3, 2026

Documentation build overview

📚 diracx | 🛠️ Build #31863030 | 📁 Comparing a23e7a5 against latest (4fd5ce8)


🔍 Preview build

Show files changed (1 files in total): 📝 1 modified | ➕ 0 added | ➖ 0 deleted
File Status
admin/reference/env-variables/index.html 📝 modified

@aldbr aldbr requested a review from natthan-pigoux March 4, 2026 08:17
@aldbr
Copy link
Copy Markdown
Contributor

aldbr commented Mar 4, 2026

I have not started to review it, but could you also open a PR in diracx-charts with the cron job and the documentation please?

@HeloiseJoffe HeloiseJoffe force-pushed the feat/authdb-tables-cleanup branch from db91f3a to db5091d Compare March 5, 2026 08:07
@HeloiseJoffe HeloiseJoffe marked this pull request as draft March 5, 2026 09:24
@HeloiseJoffe HeloiseJoffe force-pushed the feat/authdb-tables-cleanup branch from db5091d to f143436 Compare March 10, 2026 09:14
@HeloiseJoffe HeloiseJoffe marked this pull request as ready for review March 10, 2026 10:13
@HeloiseJoffe HeloiseJoffe requested a review from aldbr March 10, 2026 10:13
@DIRACGridBot DIRACGridBot marked this pull request as draft March 13, 2026 14:48
@HeloiseJoffe HeloiseJoffe force-pushed the feat/authdb-tables-cleanup branch from f143436 to 0d150eb Compare March 18, 2026 13:55
@aldbr aldbr marked this pull request as ready for review March 18, 2026 14:51
@aldbr aldbr merged commit 3e495e1 into DIRACGrid:main Mar 18, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cleanup of the AuthDB tables

4 participants