Skip to content

Commit

Permalink
Dbp 000 moodle hotfixes (#71)
Browse files Browse the repository at this point in the history
* make secret name hardcoded to moodle
* disable update preperation job if update migration is disabled
* refactor values to make more clear which settings affect the config.php, fix some whitespace issues in config.php as well
* Add value to include arbitrary options into config.php
* change if condition to respect update_migration value
* set default for redis.enabled to false
* add comment for phpConfig.additional and set its default to be empty string
  • Loading branch information
JannikBadenhop authored Nov 11, 2024
1 parent 2339f05 commit be3d94e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 19 deletions.
7 changes: 4 additions & 3 deletions charts/dbp-moodle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ The Chart can be deployed without any modification but it is advised to set own
| dbpMoodle.backup.retention_time | string | `"6M"` | Defines the maximum age of a backup before it is deleted |
| dbpMoodle.backup.secrets | object | `{"existingSecret":"","s3_access_key":"","s3_access_secret":"","s3_endpoint_url":""}` | Either provide an existing secret, or set each secret value here. If both are set the existingSecret is used |
| dbpMoodle.backup.secrets.existingSecret | string | `""` | Existing secret for s3 endpoint |
| dbpMoodle.debug | bool | `false` | Moodle debugging is not safe for production |
| dbpMoodle.external_pvc.accessModes[0] | string | `"ReadWriteMany"` | |
| dbpMoodle.external_pvc.annotations."helm.sh/resource-policy" | string | `"keep"` | |
| dbpMoodle.external_pvc.enabled | bool | `true` | |
Expand All @@ -101,7 +100,6 @@ The Chart can be deployed without any modification but it is advised to set own
| dbpMoodle.hpa.scaledown_value | int | `25` | The max amount in percent to scale down in one step per cooldown period |
| dbpMoodle.hpa.scaleup_cooldown | int | `15` | How many seconds to wait between upscaling adjustments |
| dbpMoodle.hpa.scaleup_value | int | `50` | The max amount in percent to scale up in one step per cooldown period |
| dbpMoodle.logging | bool | `false` | Extended php logging |
| dbpMoodle.moodleUpdatePreparationHook.rules[0].apiGroups[0] | string | `"apps"` | |
| dbpMoodle.moodleUpdatePreparationHook.rules[0].resources[0] | string | `"deployments"` | |
| dbpMoodle.moodleUpdatePreparationHook.rules[0].verbs[0] | string | `"get"` | |
Expand All @@ -118,6 +116,9 @@ The Chart can be deployed without any modification but it is advised to set own
| dbpMoodle.moodleUpdatePreparationJob.kubectlImage | string | `"bitnami/kubectl:1.30.4-debian-12-r3"` | Which kubectl image to use |
| dbpMoodle.moodlecronjob | object | `{"rules":[{"apiGroups":[""],"resources":["pods","pods/exec"],"verbs":["get","list","create","watch"]}],"wait_timeout":"15m"}` | Configuration for the moodle-cronjob which runs moodles cron.php. This is required since moodle does not run as root |
| dbpMoodle.name | string | `"infra"` | |
| dbpMoodle.phpConfig.additional | string | `""` | Any additional text to be included into the config.php |
| dbpMoodle.phpConfig.debug | bool | `false` | Moodle debugging is not safe for production |
| dbpMoodle.phpConfig.extendedLogging | bool | `false` | Extended php logging |
| dbpMoodle.redis | object | `{"host":"moodle-redis-master","password":"","port":6379}` | Configurations for the optional redis |
| dbpMoodle.restore | object | `{"affinity":{},"enabled":false,"existingSecretDatabase":"moodle","existingSecretGPG":"","existingSecretKeyDatabase":"","existingSecretKeyS3Access":"","existingSecretKeyS3Secret":"","existingSecretS3":"","image":"ghcr.io/dbildungsplattform/moodle-tools:1.0.7","resources":{"limits":{"cpu":"2000m","memory":"16Gi"},"requests":{"cpu":"1000m","memory":"8Gi"}},"rules":[{"apiGroups":["apps"],"resources":["deployments/scale","deployments"],"verbs":["get","list","scale","patch"]}],"tolerations":[]}` | This restores moodle to the latest snapshot. Requires an existing s3 backup. ONLY USE FOR ROLLBACK |
| dbpMoodle.secrets | object | `{"etherpad_api_key":"","etherpad_postgresql_password":"","mariadb_password":"","mariadb_root_password":"","moodle_password":"","pgsql_admin_password":"","useChartSecret":true}` | Creates a secret with all relevant credentials for moodle -- Set useChartSecret: false to provide your own secret -- If you create your own secret, also set moodle.existingSecret (and moodle.externalDatabase.existingSecret if you bring your own DB) |
Expand Down Expand Up @@ -315,7 +316,7 @@ The Chart can be deployed without any modification but it is advised to set own
| redis.auth.existingSecret | string | `"moodle"` | |
| redis.auth.existingSecretPasswordKey | string | `"redis-password"` | |
| redis.auth.usePasswordFileFromSecret | bool | `true` | |
| redis.enabled | bool | `true` | |
| redis.enabled | bool | `false` | |
| redis.master.affinity | object | `{}` | |
| redis.master.resources | object | `{}` | |
| redis.master.tolerations | list | `[]` | |
Expand Down
20 changes: 11 additions & 9 deletions charts/dbp-moodle/scripts/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,29 @@

require_once(__DIR__ . '/lib/setup.php');

{{ if .Values.dbpMoodle.logging }}
define('MDL_PERF' , true);
define('MDL_PERFDB' , true);
define('MDL_PERFTOLOG' , true); //OK for production
{{ end }}

{{- if .Values.dbpMoodle.phpConfig.extendedLogging }}
define('MDL_PERF' , true);
define('MDL_PERFDB' , true);
define('MDL_PERFTOLOG' , true); //OK for production
{{- end }}

{{ if .Values.dbpMoodle.debug }}
{{ if .Values.dbpMoodle.phpConfig.debug -}}
@error_reporting(E_ALL | E_STRICT); // NOT FOR PRODUCTION SERVERS!
@ini_set('display_errors', '1'); // NOT FOR PRODUCTION SERVERS!
$CFG->debug = 32767; // === DEBUG_DEVELOPER - NOT FOR PRODUCTION SERVERS!
$CFG->debugdisplay = 1; // NOT FOR PRODUCTION SERVERS!
$CFG->debugpageinfo = 1;
$CFG->perfdebug = 7;
{{ else }}
{{- else -}}
$CFG->debug = 0;
$CFG->debugdisplay = 0;
$CFG->debugpageinfo = 0;
$CFG->perfdebug = 7;
$CFG->debugsqltrace = 0;
{{ end }}
{{- end }}

{{ with .Values.dbpMoodle.phpConfig.additional -}}
{{- . }}
{{- end }}
// There is no php closing tag in this file,
// it is intentional because it prevents trailing whitespace problems!
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{ if not .Values.dbpMoodle.restore.enabled }}
{{ if and .Values.dbpMoodle.update_migration.enabled (not .Values.dbpMoodle.restore.enabled) }}
apiVersion: batch/v1
kind: Job
metadata:
Expand Down
2 changes: 1 addition & 1 deletion charts/dbp-moodle/templates/secrets/moodle-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: v1
kind: Secret
type: Opaque
metadata:
name: "{{ .Release.Name }}"
name: "moodle"
namespace: "{{ .Release.Namespace }}"
stringData:
moodle-password: {{ include "dbpMoodle.secrets.moodle_password" . }}
Expand Down
14 changes: 9 additions & 5 deletions charts/dbp-moodle/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,19 @@ global:
dbpMoodle:
name: infra
stage: infra
# -- Extended php logging
logging: false
# -- Moodle debugging is not safe for production
debug: false

# -- The dbp update process to migrate moodle data when moodle versions are increased
update_migration:
enabled: false

phpConfig:
# -- Extended php logging
extendedLogging: false
# -- Moodle debugging is not safe for production
debug: false
# -- Any additional text to be included into the config.php
additional: ""

# -- Configurations for the optional redis
redis:
host: "moodle-redis-master"
Expand Down Expand Up @@ -384,7 +388,7 @@ postgresql:

# redis helm chart values
redis:
enabled: true
enabled: false
architecture: "standalone"
auth:
enabled: true
Expand Down

0 comments on commit be3d94e

Please sign in to comment.