diff --git a/ee/api/app_crons.py b/ee/api/app_crons.py index 081d4d4d6..f2a225c19 100644 --- a/ee/api/app_crons.py +++ b/ee/api/app_crons.py @@ -2,14 +2,15 @@ print("============= CRONS =============") import asyncio import sys -from crons import core_dynamic_crons +from crons import core_dynamic_crons, ee_crons ACTIONS = { "TELEMETRY": core_dynamic_crons.telemetry_cron, "JOB": core_dynamic_crons.run_scheduled_jobs, "REPORT": core_dynamic_crons.weekly_report, "PROJECTS_STATS": core_dynamic_crons.health_cron, - "FIX_PROJECTS_STATS": core_dynamic_crons.weekly_health_cron + "FIX_PROJECTS_STATS": core_dynamic_crons.weekly_health_cron, + "ASSISTSTATS": ee_crons.assist_events_aggregates_cron, } diff --git a/scripts/helmcharts/openreplay/charts/utilities/templates/assist-stats-cron.yaml b/scripts/helmcharts/openreplay/charts/utilities/templates/assist-stats-cron.yaml new file mode 100644 index 000000000..56a5ccbac --- /dev/null +++ b/scripts/helmcharts/openreplay/charts/utilities/templates/assist-stats-cron.yaml @@ -0,0 +1,111 @@ +{{- if .Values.global.enterpriseEditionLicense }} +{{- $kubeTargetVersion := .Capabilities.KubeVersion.GitVersion }} +{{- if semverCompare ">=1.22.0-0" $kubeTargetVersion }} +apiVersion: batch/v1 +{{- else }} +apiVersion: batch/v1beta1 +{{- end }} +kind: CronJob +metadata: + name: assiststats-cron + namespace: {{ .Release.Namespace }} +spec: + schedule: "{{ .Values.assiststats.cron }}" + failedJobsHistoryLimit: 1 + successfulJobsHistoryLimit: 1 + jobTemplate: + spec: + backoffLimit: 0 # Don't restart the failed jobs + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 12 }} + {{- end }} + spec: + restartPolicy: Never + containers: + - name: assiststats-cron + image: "{{ tpl .Values.assiststats.image.repository . }}:{{ .Values.assiststats.image.tag | default .Chart.AppVersion }}-ee" + imagePullPolicy: {{ .Values.assiststats.image.pullPolicy }} + env: + {{- range $key, $val := .Values.global.env }} + - name: {{ $key }} + value: '{{ $val }}' + {{- end }} + - name: LICENSE_KEY + value: '{{ .Values.global.enterpriseEditionLicense }}' + - name: version_number + value: '{{ .Chart.AppVersion }}' + - name: pg_host + value: '{{ .Values.global.postgresql.postgresqlHost }}' + - name: pg_port + value: "5432" + - name: pg_dbname + value: "{{ .Values.global.postgresql.postgresqlDatabase }}" + - name: pg_user + value: '{{ .Values.global.postgresql.postgresqlUser }}' + - name: pg_password + {{- if .Values.global.postgresql.existingSecret }} + valueFrom: + secretKeyRef: + name: {{ .Values.global.postgresql.existingSecret }} + key: postgresql-postgres-password + {{- else }} + value: '{{ .Values.global.postgresql.postgresqlPassword }}' + {{- end}} + - name: SITE_URL + value: '{{- include "openreplay.domainURL" . }}' + - name: S3_HOST + value: '{{- include "openreplay.s3Endpoint" . }}' + - name: S3_KEY + {{- if .Values.global.s3.existingSecret }} + valueFrom: + secretKeyRef: + name: {{ .Values.global.s3.existingSecret }} + key: access-key + {{- else }} + value: {{ .Values.global.s3.accessKey }} + {{- end }} + - name: S3_SECRET + {{- if .Values.global.s3.existingSecret }} + valueFrom: + secretKeyRef: + name: {{ .Values.global.s3.existingSecret }} + key: secret-key + {{- else }} + value: {{ .Values.global.s3.secretKey }} + {{- end }} + - name: AWS_DEFAULT_REGION + value: '{{ .Values.global.s3.region }}' + - name: sessions_region + value: '{{ .Values.global.s3.region }}' + - name: sessions_bucket + value: {{ .Values.global.s3.recordingsBucket }} + - name: sourcemaps_bucket + value: {{ .Values.global.s3.sourcemapsBucket }} + - name: js_cache_bucket + value: {{ .Values.global.s3.assetsBucket }} + - name: EMAIL_HOST + value: '{{ .Values.global.email.emailHost }}' + - name: EMAIL_PORT + value: '{{ .Values.global.email.emailPort }}' + - name: EMAIL_USER + value: '{{ .Values.global.email.emailUser }}' + - name: EMAIL_PASSWORD + value: '{{ .Values.global.email.emailPassword }}' + - name: EMAIL_USE_TLS + value: '{{ .Values.global.email.emailUseTls }}' + - name: EMAIL_USE_SSL + value: '{{ .Values.global.email.emailUseSsl }}' + - name: EMAIL_SSL_KEY + value: '{{ .Values.global.email.emailSslKey }}' + - name: EMAIL_SSL_CERT + value: '{{ .Values.global.email.emailSslCert }}' + - name: EMAIL_FROM + value: '{{ .Values.global.email.emailFrom }}' + {{- range $key, $val := .Values.assiststats.env }} + - name: {{ $key }} + value: '{{ $val }}' + {{- end}} +{{- end}} diff --git a/scripts/helmcharts/openreplay/charts/utilities/values.yaml b/scripts/helmcharts/openreplay/charts/utilities/values.yaml index 36e0f0c3d..bae821d5e 100644 --- a/scripts/helmcharts/openreplay/charts/utilities/values.yaml +++ b/scripts/helmcharts/openreplay/charts/utilities/values.yaml @@ -25,6 +25,18 @@ telemetry: tag: "" env: ACTION: "TELEMETRY" + +assiststats: + # https://crontab.guru/#5_12_*_*_* + # Midnight 12.05 + cron: "0 * * * *" + image: + repository: "{{ .Values.global.openReplayContainerRegistry }}/crons" + pullPolicy: Always + # Overrides the image tag whose default is the chart appVersion. + tag: "" + env: + ACTION: "ASSISTSTATS" report: # https://crontab.guru/#0_5_*_*_1 # Monday morning 5am