owncloud-docker / helm-charts

ownCloud Server Helm charts
https://owncloud-docker.github.io/helm-charts/
Apache License 2.0
4 stars 11 forks source link

Missing cronjob call for /usr/lib/php/sessionclean #66

Closed astromechza closed 10 months ago

astromechza commented 11 months ago

I found that my /mnt/data/sessions directory was filling up with old session files. up to 80k of them without any cleanup.

There's a crontab entry for it in cron.d, but that doesn't get called by anything, and not by the occ system:cron background jobs either.

I solved this myself by adding a manual cronjob like below, but ideally we'd include this in the helm chart or make sure the existing helm chart calls it after running the owncloud /usr/bin/cronjob file.

---
apiVersion: batch/v1
kind: CronJob
metadata:
  name: owncloud-phpsessionclean
  namespace: production
spec:
  schedule: "@hourly"
  concurrencyPolicy: Forbid
  jobTemplate:
    spec:
      parallelism: 1
      backoffLimit: 0
      template:
        spec:
          restartPolicy: Never
          containers:
          - name: cronjob
            image: docker.io/owncloud/server:10.13.3
            imagePullPolicy: IfNotPresent
            command: ["/bin/sh", "/usr/lib/php/sessionclean"]
            envFrom:
              - configMapRef:
                  name: owncloud-env-config
            volumeMounts:
              - name: owncloud-data
                mountPath: /mnt/data
              - name: config-volume
                mountPath: /mnt/data/config/configmap.config.php
                subPath: configmap.config.php
          volumes:
            - name: owncloud-data
              persistentVolumeClaim:
                claimName: owncloud
            - name: config-volume
              secret:
                secretName: owncloud-config
xoxys commented 11 months ago

Thanks for your report. The [/usr/bin/cronjob](https://github.com/owncloud-docker/base/blob/master/v20.04/overlay/usr/bin/cronjob) script has the ability to hook-in custom scripts by mounting scripts into the directory defined in OWNCLOUD_PRE_CRONJOB_PATH and OWNCLOUD_POST_CRONJOB_PATH.

To make this behavior useable with the helm chart, we could add extraVolume and extraVolumeMounts options to allow users to set custom volumes/mounts. This way, a simple script that executes /usr/lib/php/sessionclean can be mounted from a configmap to the cronjob pre/post path. Would you like to contribute this?

astromechza commented 11 months ago

@xoxys, sure that sounds like a good starting point. extraVolumeMounts is pretty standardized these days among helm charts. PR coming soon.

xoxys commented 11 months ago

Cool, thanks!