Skip to content

Commit

Permalink
Merge pull request #24 from Ontotext-AD/logback-override-improvement
Browse files Browse the repository at this point in the history
Fixed logback override when GraphDB helm chart is used as a subchart
  • Loading branch information
nikolaykolev authored Oct 8, 2021
2 parents 82850bb + 99b7b49 commit ec4f2ae
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ apiVersion: v2
name: graphdb
description: Helm chart for GraphDB Free/SE/EE
type: application
version: 9.9.1-R2
version: 9.9.1-R3
appVersion: 9.9.1
home: https://graphdb.ontotext.com/
icon: https://graphdb.ontotext.com/home/images/visual_Logo_GraphDB_02_12_2015.png
Expand Down
28 changes: 28 additions & 0 deletions files/config/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,20 @@
<property name="defaultPattern" value="[%-5p] %d{ISO8601} [%t | %c{5}]%X{headers} %m%n%ex" />
<property name="encoding" value="UTF-8" />

<!-- Properties for log keeping based on age and size. By default logs will be kept for 30 days with no size limit-->
<!-- Sets the maximum age of kept logs in days. Set to 0 for no limit -->
<property name="keepLogDays" value="30" />
<!-- Sets the maximum size of every log kept. Accepts values like 500KB, 200MB, 1GB etc. Set to 0 for no limit
NOTE: This sets the size limit per each different log type. If you want more control change the totalSizeCap of each log separately-->
<property name="logMaxSize" value="0" />

<!-- Audit log. Contains security related things -->
<appender name="AuditLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${logDestinationDirectory}/audit-log-%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>${keepLogDays}</maxHistory>
<totalSizeCap>${logMaxSize}</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
<encoder>
<pattern>${defaultPattern}</pattern>
Expand All @@ -44,6 +54,9 @@
<appender name="MainLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${logDestinationDirectory}/main-%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>${keepLogDays}</maxHistory>
<totalSizeCap>${logMaxSize}</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
<encoder>
<pattern>${defaultPattern}</pattern>
Expand All @@ -54,6 +67,9 @@
<appender name="ErrorLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${logDestinationDirectory}/error-%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>${keepLogDays}</maxHistory>
<totalSizeCap>${logMaxSize}</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
<encoder>
<pattern>${defaultPattern}</pattern>
Expand All @@ -68,6 +84,9 @@
<appender name="EnterpriseLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${logDestinationDirectory}/enterprise-log-%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>${keepLogDays}</maxHistory>
<totalSizeCap>${logMaxSize}</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
<encoder>
<pattern>${defaultPattern}</pattern>
Expand All @@ -78,6 +97,9 @@
<appender name="HttpLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${logDestinationDirectory}/http-log-%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>${keepLogDays}</maxHistory>
<totalSizeCap>${logMaxSize}</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
<encoder>
<pattern>${defaultPattern}</pattern>
Expand All @@ -88,6 +110,9 @@
<appender name="QueryLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${logDestinationDirectory}/query-log-%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>${keepLogDays}</maxHistory>
<totalSizeCap>${logMaxSize}</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
<encoder>
<pattern>${defaultPattern}</pattern>
Expand All @@ -98,6 +123,9 @@
<appender name="SlowQueryLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${logDestinationDirectory}/slow-query-log-%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>${keepLogDays}</maxHistory>
<totalSizeCap>${logMaxSize}</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
<encoder>
<pattern>${defaultPattern}</pattern>
Expand Down
13 changes: 13 additions & 0 deletions templates/configuration/graphdb-logback-configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Default configuration map for provisioning GraphDB repository.
# To change it, prepare another configuration map and update "graphdb.repositoryConfigmap"
{{- if .Values.deployment.logbackConfigMap }}
apiVersion: {{ .Values.versions.configmap }}
kind: ConfigMap
metadata:
name: graphdb-logback-configmap
labels:
name: graphdb-logback-configmap
data:
logback.xml: |-
{{ tpl (.Files.Get "files/config/logback.xml" | indent 4) . }}
{{- end }}
13 changes: 11 additions & 2 deletions templates/graphdb-master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ spec:
- name: graphdb-master-settings-config
configMap:
name: {{ required "Config map with settings.js (and graphdb.properties(optional) ) for security/settings provisioning is required!" $.Values.graphdb.masters.settingsConfigmap }}
{{- if $.Values.deployment.logbackConfigMap }}
- name: graphdb-logback-config
configMap:
name: {{ $.Values.deployment.logbackConfigMap }}
{{- end }}
imagePullSecrets:
{{- include "combinedImagePullSecrets" $ | nindent 8 }}
nodeSelector:
Expand Down Expand Up @@ -191,6 +196,10 @@ spec:
mountPath: /opt/graphdb/home
- name: graphdb-master-settings-config
mountPath: /tmp/graphdb
{{- if $.Values.deployment.logbackConfigMap }}
- name: graphdb-logback-config
mountPath: /tmp/graphdb-configmap
{{- end }}
command: ['sh', '-c']
args:
- |
Expand All @@ -205,10 +214,10 @@ spec:
mkdir -p /opt/graphdb/home/conf ;
cp /tmp/graphdb/graphdb.properties /opt/graphdb/home/conf/graphdb.properties
fi
if [[ ! -f /opt/graphdb/home/conf/logback.xml && -f /tmp/graphdb/logback.xml ]]; then
if [[ ! -f /opt/graphdb/home/conf/logback.xml && -f /tmp/graphdb-configmap/logback.xml ]]; then
echo "Provisioning logging config file..."
mkdir -p /opt/graphdb/home/conf ;
cp /tmp/graphdb/logback.xml /opt/graphdb/home/conf/logback.xml
cp /tmp/graphdb-configmap/logback.xml /opt/graphdb/home/conf/logback.xml
fi
mkdir -p /opt/graphdb/home/jdbc-driver
echo 'Done'
Expand Down
13 changes: 11 additions & 2 deletions templates/graphdb-worker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ spec:
- name: graphdb-utils
configMap:
name: graphdb-utils-configmap
{{- if $.Values.deployment.logbackConfigMap }}
- name: graphdb-logback-config
configMap:
name: {{ $.Values.deployment.logbackConfigMap }}
{{- end }}
{{- if and (eq $worker_index 1) (or $.Values.graphdb.tools.preload.trigger $.Values.graphdb.tools.loadrdf.trigger) }}
- name: graphdb-worker-preload-data
persistentVolumeClaim:
Expand Down Expand Up @@ -175,6 +180,10 @@ spec:
mountPath: /opt/graphdb/home
- name: graphdb-master-settings-config
mountPath: /tmp/graphdb
{{- if $.Values.deployment.logbackConfigMap }}
- name: graphdb-logback-config
mountPath: /tmp/graphdb-configmap
{{- end }}
command: ['sh', '-c']
args:
- |
Expand All @@ -189,10 +198,10 @@ spec:
mkdir -p /opt/graphdb/home/conf ;
cp /tmp/graphdb/graphdb.properties /opt/graphdb/home/conf/graphdb.properties
fi
if [[ ! -f /opt/graphdb/home/conf/logback.xml && -f /tmp/graphdb/logback.xml ]]; then
if [[ ! -f /opt/graphdb/home/conf/logback.xml && -f /tmp/graphdb-configmap/logback.xml ]]; then
echo "Provisioning logging config file..."
mkdir -p /opt/graphdb/home/conf ;
cp /tmp/graphdb/logback.xml /opt/graphdb/home/conf/logback.xml
cp /tmp/graphdb-configmap/logback.xml /opt/graphdb/home/conf/logback.xml
fi
mkdir -p /opt/graphdb/home/jdbc-driver
echo 'Done'
Expand Down
2 changes: 1 addition & 1 deletion values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ deployment:
read: 60
send: 60
# Override default logback configuration
# logbackConfigFile: files/config/logback.xml
# logbackConfigMap: graphdb-logback-configmap

# KONG API gateway configurations.
# This gateway sits behind the ingress and exposes the rest of the components.
Expand Down

0 comments on commit ec4f2ae

Please sign in to comment.