Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Define cron jobs running mgmt commands in Helm chart #440

Merged
merged 4 commits into from
May 15, 2024

Conversation

microamp
Copy link
Contributor

Fixes #431.

  • Two cron jobs:

    The PR defines two cron jobs, one hourly the other weekly.

    https://docs.wagtail.org/en/stable/reference/management_commands.html

    • publish_scheduled:

      We recommend running this command once an hour.

    • update_index:

      It is recommended to run this command once a week

    With the current spec, the daily job runs every hour at minute 0, and the weekly job runs on Sunday at 00:30 UTC. Note that the weekly database maintenance window currently occurs on Saturdays UTC, and will no overlap with the weekly cron job.

  • Verifying helm install output:

    With tag set to the latest image tag, v2.1.10, helm install www helm --dry-run outputs as below.

    ...
    ---
    # Source: www/templates/cronjob.yaml
    apiVersion: batch/v1
    kind: CronJob
    metadata:
      name: "mgmt-hourly"
    spec:
      schedule: "0 * * * *"
      timeZone: "Etc/UTC"
      concurrencyPolicy: Forbid
      jobTemplate:
        spec:
          backoffLimit: 0 # No retries
          template:
            spec:
              restartPolicy: Never
              volumes:
                - name: settings-local-volume
                  configMap:
                    name: django-configmap
              containers:
              - name: "mgmt-hourly"
                image: "ghcr.io/ietf-tools/www:v2.1.10"
                imagePullPolicy: IfNotPresent
                ...
                command: ["python","/app/manage.py","publish_scheduled"]
    ---
    # Source: www/templates/cronjob.yaml
    apiVersion: batch/v1
    kind: CronJob
    metadata:
      name: "mgmt-weekly"
    spec:
      schedule: "30 0 * * 0"
      timeZone: "Etc/UTC"
      concurrencyPolicy: Forbid
      jobTemplate:
        spec:
          backoffLimit: 0 # No retries
          template:
            spec:
              restartPolicy: Never
              volumes:
                - name: settings-local-volume
                  configMap:
                    name: django-configmap
              containers:
              - name: "mgmt-weekly"
                image: "ghcr.io/ietf-tools/www:v2.1.10"
                imagePullPolicy: IfNotPresent
                ...
                command: ["python","/app/manage.py","update_index"]

@microamp microamp requested review from kesara and rjsparks May 12, 2024 23:10
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.81%. Comparing base (271b518) to head (adff04c).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #440   +/-   ##
=======================================
  Coverage   82.81%   82.81%           
=======================================
  Files         126      126           
  Lines        2612     2612           
=======================================
  Hits         2163     2163           
  Misses        449      449           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@microamp microamp merged commit 35525ce into ietf-tools:main May 15, 2024
6 checks passed
@microamp microamp deleted the feat/crons branch May 15, 2024 11:37
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.

Define K8s CronJob to run management commands periodically
4 participants