diff --git a/api/management/commands/oauth_cleartokens.py b/api/management/commands/oauth_cleartokens.py new file mode 100644 index 000000000..2498330e4 --- /dev/null +++ b/api/management/commands/oauth_cleartokens.py @@ -0,0 +1,13 @@ +from django.core import management +from django.core.management.base import BaseCommand +from sentry_sdk.crons import monitor + +from main.sentry import SentryMonitor + + +class Command(BaseCommand): + help = "A wrapper for cleartokens command to track using sentry cron monitor. Feel free to use cleartokens" + + @monitor(monitor_slug=SentryMonitor.OAUTH_CLEARTOKENS) + def handle(self, *args, **kwargs): + management.call_command("cleartokens") diff --git a/deploy/helm/ifrcgo-helm/values.yaml b/deploy/helm/ifrcgo-helm/values.yaml index c93b673c5..6ef4a199c 100644 --- a/deploy/helm/ifrcgo-helm/values.yaml +++ b/deploy/helm/ifrcgo-helm/values.yaml @@ -169,6 +169,9 @@ cronjobs: schedule: '0 3 * * 0' - command: 'notify_validators' schedule: '0 0 * * *' + # https://github.com/jazzband/django-oauth-toolkit/blob/master/docs/management_commands.rst#cleartokens + - command: 'oauth_cleartokens' + schedule: '0 1 * * *' elasticsearch: diff --git a/main/sentry.py b/main/sentry.py index 97890ce2f..82b0b9c96 100644 --- a/main/sentry.py +++ b/main/sentry.py @@ -129,6 +129,7 @@ class SentryMonitor(models.TextChoices): INGEST_NS_INITIATIVES = "ingest_ns_initiatives", "0 0 * * 0" INGEST_ICRC = "ingest_icrc", "0 3 * * 0" NOTIFY_VALIDATORS = "notify_validators", "0 0 * * *" + OAUTH_CLEARTOKENS = "oauth_cleartokens", "0 1 * * *" @staticmethod def load_cron_data() -> typing.List[typing.Tuple[str, str]]: