Configuration not initialized correctly in Nextcloud Helm Chart version 3.5.21 with specific Redis configuration.
Description:
While deploying Nextcloud using the Helm Chart version 3.5.21 on a Kubernetes cluster, I encountered a repeated error in nextcloud.log indicating that the configuration was not read or initialized correctly, which prevented the Nextcloud instance from operating as expected.
Log Output:
{
"reqId":"jcxSm6ZxTA4kerDn7m00",
"level":3,
"time":"2023-08-10T23:32:31+00:00",
"remoteAddr":"10.244.6.155",
"user":"--",
"app":"remote",
"method":"GET",
"url":"/status.php",
"message":"Configuration was not read or initialized correctly, not overwriting /var/www/html/config/config.php",
"userAgent":"kube-probe/1.27",
"version":"",
"exception":{
"Exception":"OCP\\HintException",
"Message":"Configuration was not read or initialized correctly, not overwriting /var/www/html/config/config.php",
"Code":0,
"Trace":[
{"file":"/var/www/html/lib/private/Config.php","line":143,"function":"writeData","class":"OC\\Config","type":"->","args":[]},
{"file":"/var/www/html/lib/private/SystemConfig.php","line":145,"function":"setValue","class":"OC\\Config","type":"->","args":["instanceid","ocqei17lpobq"]},
{"file":"/var/www/html/lib/private/legacy/OC_Util.php","line":889,"function":"setValue","class":"OC\\SystemConfig","type":"->","args":["instanceid","ocqei17lpobq"]},
{"file":"/var/www/html/lib/base.php","line":444,"function":"getInstanceId","class":"OC_Util","type":"::","args":[]},
{"file":"/var/www/html/lib/base.php","line":708,"function":"initSession","class":"OC","type":"::","args":[]},
{"file":"/var/www/html/lib/base.php","line":1180,"function":"init","class":"OC","type":"::","args":[]},
{"file":"/var/www/html/status.php","line":37,"args":["/var/www/html/lib/base.php"],"function":"require_once"}
],
"File":"/var/www/html/lib/private/Config.php",
"Line":266,
"Hint":"Configuration was not read or initialized correctly, not overwriting /var/www/html/config/config.php",
"CustomMessage":"--"
}
}
Steps to Reproduce:
Deploy Nextcloud using Helm Chart version 3.5.21 with specific Redis configuration. Observe the above error in nextcloud.log. Expected Behavior:
Nextcloud should correctly initialize and apply the configuration without any issues.
Actual Behavior:
Nextcloud fails to initialize the configuration and throws the error
Additional Configuration Details:
Below is the values.yaml file I used during the deployment:
## Official nextcloud image versionsto
## ref: https://hub.docker.com/r/library/nextcloud/tags/
##
image:
repository: nextcloud
tag: 27.0.1-fpm
pullPolicy: IfNotPresent
# pullSecrets:
# - myRegistrKeySecretName
nameOverride: ""
fullnameOverride: ""
podAnnotations: {}
deploymentAnnotations: {}
# Number of replicas to be deployed
replicaCount: 1
## Allowing use of ingress controllers
## ref: https://kubernetes.io/docs/concepts/services-networking/ingress/
##
ingress:
enabled: true
className: nginx
annotations:
nginx.ingress.kubernetes.io/enable-cors: "true"
nginx.ingress.kubernetes.io/cors-allow-headers: "X-Forwarded-For"
# nginx.ingress.kubernetes.io/proxy-body-size: 4G
# kubernetes.io/tls-acme: "true"
# cert-manager.io/cluster-issuer: letsencrypt-prod
# nginx.ingress.kubernetes.io/server-snippet: |-
# server_tokens off;
# proxy_hide_header X-Powered-By;
# rewrite ^/.well-known/webfinger /public.php?service=webfinger last;
# rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
# rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json;
# location = /.well-known/carddav {
# return 301 $scheme://$host/remote.php/dav;
# }
# location = /.well-known/caldav {
# return 301 $scheme://$host/remote.php/dav;
# }
# location = /robots.txt {
# allow all;
# log_not_found off;
# access_log off;
# }
# location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ {
# deny all;
# }
# location ~ ^/(?:autotest|occ|issue|indie|db_|console) {
# deny all;
# }
# tls:
# - secretName: nextcloud-tls
# hosts:
# - nextcloud.kube.home
labels: {}
path: /
pathType: Prefix
# Allow configuration of lifecycle hooks
# ref: https://kubernetes.io/docs/tasks/configure-pod-container/attach-handler-lifecycle-event/
lifecycle: {}
# postStartCommand: []
# preStopCommand: []
phpClientHttpsFix:
enabled: false
protocol: https
nextcloud:
host: nextcloud.turelk.com
username: admin
password: "password"
## Use an existing secret
existingSecret:
enabled: false
# secretName: nameofsecret
# usernameKey: username
# passwordKey: password
# tokenKey: serverinfo_token
# smtpUsernameKey: smtp_username
# smtpPasswordKey: smtp_password
update: 0
# If web server is not binding default port, you can define it
# containerPort: 8080
datadir: /var/www/html/data
persistence:
subPath:
mail:
enabled: false
fromAddress: user
domain: domain.com
smtp:
host: domain.com
secure: ssl
port: 465
authtype: LOGIN
name: user
password: pass
# PHP Configuration files
# Will be injected in /usr/local/etc/php/conf.d for apache image and in /usr/local/etc/php-fpm.d when nginx.enabled: true
phpConfigs:
# Default config files
# IMPORTANT: Will be used only if you put extra configs, otherwise default will come from nextcloud itself
# Default confgurations can be found here: https://github.com/nextcloud/docker/tree/master/16.0/apache/config
defaultConfigs:
# To protect /var/www/html/config
.htaccess: true
# Redis default configuration
redis.config.php: false
# Apache configuration for rewrite urls
apache-pretty-urls.config.php: true
# Define APCu as local cache
apcu.config.php: true
# Apps directory configs
apps.config.php: true
# Used for auto configure database
autoconfig.php: true
# SMTP default configuration
smtp.config.php: true
# Extra config files created in /var/www/html/config/
# ref: https://docs.nextcloud.com/server/15/admin_manual/configuration_server/config_sample_php_parameters.html#multiple-config-php-file
configs:
redis.config-sentinel.php: |-
<?php
$CONFIG = [
'memcache.local' => '\\OC\\Memcache\\Redis',
'memcache.distributed' => '\\OC\\Memcache\\Redis',
'memcache.locking' => '\\OC\\Memcache\\Redis',
'redis' => [
'host' => 'nextcloud-redis',
'port' => 6379,
'timeout' => 0,
],
];
# For example, to use S3 as primary storage
# ref: https://docs.nextcloud.com/server/13/admin_manual/configuration_files/primary_storage.html#simple-storage-service-s3
#
# configs:
# s3.config.php: |-
# <?php
# $CONFIG = array (
# 'objectstore' => array(
# 'class' => '\\OC\\Files\\ObjectStore\\S3',
# 'arguments' => array(
# 'bucket' => 'my-bucket',
# 'autocreate' => true,
# 'key' => 'xxx',
# 'secret' => 'xxx',
# 'region' => 'us-east-1',
# 'use_ssl' => true
# )
# )
# );
## Strategy used to replace old pods
## IMPORTANT: use with care, it is suggested to leave as that for upgrade purposes
## ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy
strategy:
type: Recreate
# type: RollingUpdate
# rollingUpdate:
# maxSurge: 1
# maxUnavailable: 0
##
## Extra environment variables
extraEnv:
# - name: SOME_SECRET_ENV
# valueFrom:
# secretKeyRef:
# name: nextcloud
# key: secret_key
# Extra init containers that runs before pods start.
extraInitContainers: []
# - name: do-something
# image: busybox
# command: ['do', 'something']
# Extra sidecar containers.
extraSidecarContainers: []
# - name: nextcloud-logger
# image: busybox
# command: [/bin/sh, -c, 'while ! test -f "/run/nextcloud/data/nextcloud.log"; do sleep 1; done; tail -n+1 -f /run/nextcloud/data/nextcloud.log']
# volumeMounts:
# - name: nextcloud-data
# mountPath: /run/nextcloud/data
# Extra mounts for the pods. Example shown is for connecting a legacy NFS volume
# to NextCloud pods in Kubernetes. This can then be configured in External Storage
extraVolumes:
# - name: nfs
# nfs:
# server: "10.0.0.1"
# path: "/nextcloud_data"
# readOnly: false
extraVolumeMounts:
# - name: nfs
# mountPath: "/legacy_data"
# Extra secuurityContext parameters. For example you may need to define runAsNonRoot directive
# extraSecurityContext:
# runAsUser: "33"
# runAsGroup: "33"
# runAsNonRoot: true
# readOnlyRootFilesystem: true
nginx:
## You need to set an fpm version of the image for nextcloud if you want to use nginx!
enabled: true
image:
repository: nginx
tag: alpine
pullPolicy: IfNotPresent
config:
# This generates the default nginx config as per the nextcloud documentation
default: true
# custom: |-
# worker_processes 1;..
resources: {}
internalDatabase:
enabled: false
name: nextcloud
##
## External database configuration
##
externalDatabase:
enabled: true
## Supported database engines: mysql or postgresql
type: mysql
## Database host
host: my-mariadb-galera
## Database user
user: nextcloud
## Database password
password: nextcloud
## Database name
database: nextcloud
## Use a existing secret
existingSecret:
enabled: false
# secretName: nameofsecret
# usernameKey: username
# passwordKey: password
##
## MariaDB chart configuration
##
mariadb:
## Whether to deploy a mariadb server to satisfy the applications database requirements. To use an external database set this to false and configure the externalDatabase parameters
enabled: false
auth:
database: nextcloud
username: nextcloud
password: changeme
architecture: standalone
## Enable persistence using Persistent Volume Claims
## ref: http://kubernetes.io/docs/user-guide/persistent-volumes/
##
primary:
persistence:
enabled: true
storageClass: "rook-cephfs"
accessMode: ReadWriteMany
size: 10Gi
##
## PostgreSQL chart configuration
## for more options see https://github.com/bitnami/charts/tree/master/bitnami/postgresql
##
postgresql:
enabled: false
global:
postgresql:
auth:
username: nextcloud
password: changeme
database: nextcloud
primary:
persistence:
enabled: true
storageClass: "rook-cephfs"
##
## Redis chart configuration
## for more options see https://github.com/bitnami/charts/tree/master/bitnami/redis
##
redis:
enabled: true
sentinel:
enabled: true
auth:
enabled: true
password: 'changeme'
master:
persistence:
enabled: true
storageClass: rook-cephfs
accessModes:
- ReadWriteOnce
size: 8Gi
replica:
persistence:
enabled: true
storageClass: rook-cephfs
accessModes:
- ReadWriteOnce
size: 8Gi
## Cronjob to execute Nextcloud background tasks
## ref: https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/background_jobs_configuration.html#cron
##
cronjob:
enabled: false
# Allow configuration of lifecycle hooks
# ref: https://kubernetes.io/docs/tasks/configure-pod-container/attach-handler-lifecycle-event/
lifecycle: {}
# postStartCommand: []
# preStopCommand: []
service:
type: ClusterIP
port: 8080
loadBalancerIP: nil
nodePort: nil
## Enable persistence using Persistent Volume Claims
## ref: http://kubernetes.io/docs/user-guide/persistent-volumes/
##
persistence:
# Nextcloud Data (/var/www/html)
enabled: true
annotations: {}
## nextcloud data Persistent Volume Storage Class
## If defined, storageClassName: <storageClass>
## If set to "-", storageClassName: "", which disables dynamic provisioning
## If undefined (the default) or set to null, no storageClassName spec is
## set, choosing the default provisioner. (gp2 on AWS, standard on
## GKE, AWS & OpenStack)
##
storageClass: "rook-cephfs"
## A manually managed Persistent Volume and Claim
## Requires persistence.enabled: true
## If defined, PVC must be created manually before volume will be bound
# existingClaim:
accessMode: ReadWriteMany
size: 8Gi
## Use an additional pvc for the data directory rather than a subpath of the default PVC
## Useful to store data on a different storageClass (e.g. on slower disks)
nextcloudData:
enabled: false
subPath:
annotations: {}
storageClass: "rook-cephfs"
# existingClaim:
accessMode: ReadWriteMany
size: 8Gi
resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
## Liveness and readiness probe values
## Ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#container-probes
##
livenessProbe:
enabled: true
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
successThreshold: 1
readinessProbe:
enabled: true
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
successThreshold: 1
startupProbe:
enabled: false
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 30
successThreshold: 1
## Enable pod autoscaling using HorizontalPodAutoscaler
## ref: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/
##
hpa:
enabled: false
cputhreshold: 60
minPods: 1
maxPods: 10
nodeSelector: {}
tolerations: []
affinity: {}
## Prometheus Exporter / Metrics
##
metrics:
enabled: false
replicaCount: 1
# The metrics exporter needs to know how you serve Nextcloud either http or https
https: false
# Use API token if set, otherwise fall back to password authentication
# https://github.com/xperimental/nextcloud-exporter#token-authentication
# Currently you still need to set the token manually in your nextcloud install
token: ""
timeout: 5s
image:
repository: xperimental/nextcloud-exporter
tag: 0.5.1
pullPolicy: IfNotPresent
## Metrics exporter resource requests and limits
## ref: http://kubernetes.io/docs/user-guide/compute-resources/
##
# resources: {}
## Metrics exporter pod Annotation and Labels
# podAnnotations: {}
# podLabels: {}
service:
type: ClusterIP
## Use serviceLoadBalancerIP to request a specific static IP,
## otherwise leave blank
# loadBalancerIP:
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "9205"
labels: {}
## Prometheus Operator ServiceMonitor configuration
##
serviceMonitor:
## @param metrics.serviceMonitor.enabled Create ServiceMonitor Resource for scraping metrics using PrometheusOperator
##
enabled: false
## @param metrics.serviceMonitor.namespace Namespace in which Prometheus is running
##
namespace: ""
## @param metrics.serviceMonitor.jobLabel The name of the label on the target service to use as the job name in prometheus.
##
jobLabel: ""
## @param metrics.serviceMonitor.interval Interval at which metrics should be scraped
## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#endpoint
##
interval: 30s
## @param metrics.serviceMonitor.scrapeTimeout Specify the timeout after which the scrape is ended
## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#endpoint
##
scrapeTimeout: ""
## @param metrics.serviceMonitor.labels Extra labels for the ServiceMonitor
##
labels: {}
rbac:
enabled: true
serviceaccount:
create: true
name: nextcloud-serviceaccount
annotations: {}
Hi @melbruki, could you please update your values.yaml code block to use three backticks and the word yaml like this:
```yaml myyamlhere: myvalue ```
This makes it render with syntax highlighting, which makes it a little easier to read:
myyamlhere: myvalue
ok done, let me know if you need anything else
Thank you! It looks like you still have an extra backtick before and after your yaml code, so it renders the entire thing as blue, instead of blue and green. Sorry for the extra hassle on this btw. I have a reading disability and syntax highlighting just helps break up the code so I can view it better. Otherwise I end up copying and pasting the code block into an editor where I can see the colors better, which just lengthens the time it takes for me to evaluate an issue quickly.
- update I modified the post to just fix the syntax highlighting and nothing else, so you can use it as a reference for future code blocks.
On your actual configuration, it looks ok from what I can tell though. Can you try again on helm chart version 4.0.0 and also try enabling debug logging? You can do that with the following in your values.yaml:
nextcloud:
configs:
# log levels: 0=debug, 1=info, 2=warn, 3=error, 4=fatal
logging.config.php: |-
<?php
$CONFIG = array (
'log_type' => 'file',
'logfile' => 'nextcloud.log',
'loglevel' => 0,
'logdateformat' => 'F d, Y H:i:s'
);
After adding syntax highlighting to your values.yaml code block, I noticed your externalDatabase.host is set to my-mariadb-galera. Can you try setting it to hostname + :$PORT. I don't use mariadb galera, but according to the docs, I think you'd want either mariadb-galera:3306, or mariadb-galera:4567.
I am suggesting this, because when using postgresql I pass in localhost:5432 for my externalDatabase.host.
It also looks like you have persistence enabled, so another thing to try would be to see if disabling persistence produces the same error (after fixing the externalDatabase.host).
Thanks I actually donβt have any issue using Mariadb galera the problem only comes in when I try to use the distributed sentinel redis . If I donβt modify the config.php everything works as expected. Anytime I try to modify the config.php I get that error . I think in order to get redis sentinel working I have to modify config.php
Sorry, I misread your issue! π
I'm now up to speed and looking at your redis config. I did want to note that your nextcloud.phpconfigs value did seem to be null instead of {} or being removed entirely, but I don't think that matters. Also want to note that I haven't worked with redis and nextcloud a ton, so others in the community might have a better idea of how to proceed, but I'll rubberduck on this regardless.
Here's the important parts we're working with from your full values.yaml for easy reference:
nextcloud:
# Default config files
defaultConfigs:
# Redis default configuration
redis.config.php: false
# Extra config files created in /var/www/html/config/
configs:
redis.config-sentinel.php: |-
<?php
$CONFIG = [
'memcache.local' => '\\OC\\Memcache\\Redis',
'memcache.distributed' => '\\OC\\Memcache\\Redis',
'memcache.locking' => '\\OC\\Memcache\\Redis',
'redis' => [
'host' => 'nextcloud-redis',
'port' => 6379,
'timeout' => 0,
],
];
## Redis chart configuration
## for more options see https://github.com/bitnami/charts/tree/master/bitnami/redis
redis:
enabled: true
sentinel:
enabled: true
auth:
enabled: true
password: 'changeme'
master:
persistence:
enabled: true
storageClass: rook-cephfs
accessModes:
- ReadWriteOnce
size: 8Gi
replica:
persistence:
enabled: true
storageClass: rook-cephfs
accessModes:
- ReadWriteOnce
size: 8Gi
From your logs:
Configuration was not read or initialized correctly, not overwriting /var/www/html/config/config.php
So, I think that means something wasn't initialized correctly with the file you passed in. Perhaps you need your nextcloud.configs.redis.config-sentinel.php to more closely match the one we create for you if nextcloud.defaultConfigs.redis.config.php is true:
https://github.com/nextcloud/helm/blob/fff00ffbfa7ca005ac62817d30c547c9e8001c75/charts/nextcloud/templates/config.yaml#L32-L46
It looks like the main difference is you're passing in 'timeout' => 0, but not password, and we're specifying 'password' => getenv('REDIS_HOST_PASSWORD'), but no timeout. We're also grabbing the host/port from env vars.
Can you try changing your redis host, port, and password values in nextcloud.configs.redis.config-sentinel.php?
Thank you Iβll give that a try
@jessebot I'm bumping this up.
The issue arise with the chart latest version everytime a configs: array is added to the values.yaml.
That results in additionnal foo.config.php files created in the config directory in the nextcloud pod, but the config.php itself is existing but empty !
Removing the extra configs: array from values actually populates the config.php file.
I'm having the same issue regarding the code snippet to declare trusted_proxies.
EDIT:
Adding the nextcloud.configs array, does add this to the deployment template :
129 β > - name: nextcloud-config
130 β > mountPath: /var/www/html/config/proxy.config.php
131 β > subPath: proxy.config.php
132 β > - name: nextcloud-config
133 β > mountPath: /var/www/html/config/.htaccess
134 β > subPath: .htaccess
135 β > - name: nextcloud-config
136 β > mountPath: /var/www/html/config/apache-pretty-urls.config.php
137 β > subPath: apache-pretty-urls.config.php
138 β > - name: nextcloud-config
139 β > mountPath: /var/www/html/config/apcu.config.php
140 β > subPath: apcu.config.php
141 β > - name: nextcloud-config
142 β > mountPath: /var/www/html/config/apps.config.php
143 β > subPath: apps.config.php
144 β > - name: nextcloud-config
145 β > mountPath: /var/www/html/config/autoconfig.php
146 β > subPath: autoconfig.php
147 β > - name: nextcloud-config
148 β > mountPath: /var/www/html/config/redis.config.php
149 β > subPath: redis.config.php
150 β > - name: nextcloud-config
151 β > mountPath: /var/www/html/config/smtp.config.php
152 β > subPath: smtp.config.php
No config.php is created.
@jessebot I'm bumping this up.
The issue arise with the chart latest version everytime a configs: array is added to the values.yaml.
That results in additionnal foo.config.php files created in the config directory in the nextcloud pod, but the config.php itself is existing but empty !
Removing the extra configs: array from values actually populates the config.php file.
I'm having the same issue regarding the code snippet to declare trusted_proxies.
EDIT:
Adding the nextcloud.configs array, does add this to the deployment template :
129 β > - name: nextcloud-config 130 β > mountPath: /var/www/html/config/proxy.config.php 131 β > subPath: proxy.config.php 132 β > - name: nextcloud-config 133 β > mountPath: /var/www/html/config/.htaccess 134 β > subPath: .htaccess 135 β > - name: nextcloud-config 136 β > mountPath: /var/www/html/config/apache-pretty-urls.config.php 137 β > subPath: apache-pretty-urls.config.php 138 β > - name: nextcloud-config 139 β > mountPath: /var/www/html/config/apcu.config.php 140 β > subPath: apcu.config.php 141 β > - name: nextcloud-config 142 β > mountPath: /var/www/html/config/apps.config.php 143 β > subPath: apps.config.php 144 β > - name: nextcloud-config 145 β > mountPath: /var/www/html/config/autoconfig.php 146 β > subPath: autoconfig.php 147 β > - name: nextcloud-config 148 β > mountPath: /var/www/html/config/redis.config.php 149 β > subPath: redis.config.php 150 β > - name: nextcloud-config 151 β > mountPath: /var/www/html/config/smtp.config.php 152 β > subPath: smtp.config.phpNo config.php is created.
i think you described the problem exactly , did you get this resolved?
just noticed this issue again after @melbruki pointed it out in #449. From that issue, can you let me know what's in the config.php that you need? I explained a bit more here: https://github.com/nextcloud/helm/issues/449#issuecomment-1794759246