Skip to content

Commit ae5cad9

Browse files
committed
DX-96480: resolve logging bug
This is a port from https://dremio.atlassian.net/browse/DX-96405 Change-Id: If0df04b715d85d22af9811838347a6175525df5d
1 parent 24a12d7 commit ae5cad9

10 files changed

Lines changed: 186 additions & 19 deletions

charts/dremio_v2/docs/setup/Writing-Logs-To-A-File.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Writing Logs to a File
22

3-
By default, logs are written to `stdout`. Logs can also be written to `/opt/dremio/log` by enabling `writeLogsToFile`.
4-
For more configuration information, see the [Values Reference](./Writing-Logs-To-A-File.md) documentation.
3+
By default, logs are written to `stdout`. Logs can also be written to `/opt/dremio/log` by enabling `writeLogsToFile`. For more configuration information, see the [Values Reference](./Writing-Logs-To-A-File.md) documentation.
54

65
***Important Note:*** Upgrading an existing Dremio deployment can potentially be a destructive change since enabling this feature
76
requires an uninstall/install instead of a typical `helm upgrade`. Prior to enabling this feature, switch the cluster into

charts/dremio_v2/templates/_helpers_coordinator.tpl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Coordinator - Dremio Heap Memory allocation
1919
{{- sub $coordinatorMemory 2048}}
2020
{{- end -}}
2121
{{- end -}}
22+
2223
{{/*
2324
Coordiantor - Dremio Direct Memory Allocation
2425
*/}}
@@ -90,18 +91,23 @@ Coordinator - Container Extra Environment Variables
9091
Coordinator - Log Path
9192
*/}}
9293
{{- define "dremio.coordinator.log.path" -}}
93-
{{- $writeLogsToFile := coalesce $.Values.coordinator.writeLogsToFile $.Values.writeLogsToFile -}}
94+
{{- $writeLogsToFile := include "dremio.booleanCoalesce" (list $.Values.coordinator.writeLogsToFile $.Values.writeLogsToFile nil) -}}
9495
{{- if $writeLogsToFile -}}
96+
- name: DREMIO_LOG_TO_CONSOLE
97+
value: "0"
9598
- name: DREMIO_LOG_DIR
9699
value: /opt/dremio/log
100+
{{- else -}}
101+
- name: DREMIO_LOG_TO_CONSOLE
102+
value: "1"
97103
{{- end -}}
98104
{{- end -}}
99105

100106
{{/*
101107
Coordinator - Log Volume Mount
102108
*/}}
103109
{{- define "dremio.coordinator.log.volumeMount" -}}
104-
{{- $writeLogsToFile := coalesce $.Values.coordinator.writeLogsToFile $.Values.writeLogsToFile -}}
110+
{{- $writeLogsToFile := include "dremio.booleanCoalesce" (list $.Values.coordinator.writeLogsToFile $.Values.writeLogsToFile nil) -}}
105111
{{- if $writeLogsToFile -}}
106112
- name: dremio-log-volume
107113
mountPath: /opt/dremio/log
@@ -113,7 +119,7 @@ Coordinator - Logs Volume Claim Template
113119
*/}}
114120
{{- define "dremio.coordinator.log.volumeClaimTemplate" -}}
115121
{{- $coordinatorLogStorageClass := coalesce $.Values.coordinator.logStorageClass $.Values.logStorageClass -}}
116-
{{- $writeLogsToFile := coalesce $.Values.coordinator.writeLogsToFile $.Values.writeLogsToFile -}}
122+
{{- $writeLogsToFile := include "dremio.booleanCoalesce" (list $.Values.coordinator.writeLogsToFile $.Values.writeLogsToFile nil) -}}
117123
{{- if $writeLogsToFile -}}
118124
- metadata:
119125
name: dremio-log-volume
@@ -228,4 +234,4 @@ Coordinator - Pod Tolerations
228234
tolerations:
229235
{{- toYaml $coordinatorTolerations | nindent 2 }}
230236
{{- end -}}
231-
{{- end -}}
237+
{{- end -}}

charts/dremio_v2/templates/_helpers_executor.tpl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,15 @@ Executor - Log Path
186186
{{- $context := index . 0 -}}
187187
{{- $engineName := index . 1 -}}
188188
{{- $engineConfiguration := default (dict) (get (default (dict) $context.Values.executor.engineOverride) $engineName) -}}
189-
{{- $writeLogsToFile := coalesce $engineConfiguration.writeLogsToFile $context.Values.executor.writeLogsToFile $context.Values.writeLogsToFile -}}
189+
{{- $writeLogsToFile := include "dremio.booleanCoalesce" (list $engineConfiguration.writeLogsToFile $context.Values.executor.writeLogsToFile $context.Values.writeLogsToFile nil) -}}
190190
{{- if $writeLogsToFile -}}
191+
- name: DREMIO_LOG_TO_CONSOLE
192+
value: "0"
191193
- name: DREMIO_LOG_DIR
192194
value: /opt/dremio/log
195+
{{- else -}}
196+
- name: DREMIO_LOG_TO_CONSOLE
197+
value: "1"
193198
{{- end -}}
194199
{{- end -}}
195200

@@ -200,7 +205,7 @@ Executor - Log Volume Mount
200205
{{- $context := index . 0 -}}
201206
{{- $engineName := index . 1 -}}
202207
{{- $engineConfiguration := default (dict) (get (default (dict) $context.Values.executor.engineOverride) $engineName) -}}
203-
{{- $writeLogsToFile := coalesce $engineConfiguration.writeLogsToFile $context.Values.executor.writeLogsToFile $context.Values.writeLogsToFile -}}
208+
{{- $writeLogsToFile := include "dremio.booleanCoalesce" (list $engineConfiguration.writeLogsToFile $context.Values.executor.writeLogsToFile $context.Values.writeLogsToFile nil) -}}
204209
{{- if $writeLogsToFile -}}
205210
- name: dremio-log-volume
206211
mountPath: /opt/dremio/log
@@ -214,7 +219,7 @@ Executor - Logs Volume Claim Template
214219
{{- $context := index . 0 -}}
215220
{{- $engineName := index . 1 -}}
216221
{{- $engineConfiguration := default (dict) (get (default (dict) $context.Values.executor.engineOverride) $engineName) -}}
217-
{{- $writeLogsToFile := coalesce $engineConfiguration.writeLogsToFile $context.Values.executor.writeLogsToFile $context.Values.writeLogsToFile -}}
222+
{{- $writeLogsToFile := include "dremio.booleanCoalesce" (list $engineConfiguration.writeLogsToFile $context.Values.executor.writeLogsToFile $context.Values.writeLogsToFile nil) -}}
218223
{{- $volumeSize := coalesce $engineConfiguration.volumeSize $context.Values.executor.volumeSize $context.Values.volumeSize -}}
219224
{{- if $writeLogsToFile -}}
220225
- metadata:

charts/dremio_v2/templates/_helpers_general.tpl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,20 @@ Admin - Service Account
121121
serviceAccount: {{ $adminServiceAccount }}
122122
{{- end -}}
123123
{{- end -}}
124+
125+
{{/*
126+
This helper function is used to coalesce a list of boolean values using "trilean" logic,
127+
i.e., returning the first non-nil value found, even if it is false.
128+
If a non-nil value is found and it is true, the function returns "1"; otherwise the function returns an empty string.
129+
This function is suitable for use in lieu of the coalesce function, which has surprising effects
130+
when used with boolean values. This function should not be used with non-boolean values.
131+
*/}}
132+
{{- define "dremio.booleanCoalesce" -}}
133+
{{- $found := false -}}
134+
{{- range $value := . -}}
135+
{{- if and (not $found) (ne $value nil) -}}
136+
{{- $found = true -}}
137+
{{- if $value -}}1{{- end -}}
138+
{{- end -}}
139+
{{- end -}}
140+
{{- end -}}

charts/dremio_v2/templates/dremio-coordinator.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ spec:
7373
value: "/opt/dremio/aws/credentials"
7474
- name: AWS_SHARED_CREDENTIALS_FILE
7575
value: "/opt/dremio/aws/credentials"
76-
- name: DREMIO_LOG_TO_CONSOLE
77-
value: "true"
7876
{{- include "dremio.coordinator.log.path" $ | nindent 8 }}
7977
{{- include "dremio.coordinator.extraEnvs" $ | nindent 8 }}
8078
command: ["/opt/dremio/bin/dremio"]

charts/dremio_v2/templates/dremio-executor.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@ spec:
7878
value: "/opt/dremio/aws/credentials"
7979
- name: AWS_SHARED_CREDENTIALS_FILE
8080
value: "/opt/dremio/aws/credentials"
81-
- name: DREMIO_LOG_TO_CONSOLE
82-
value: "true"
8381
{{- include "dremio.executor.log.path" (list $ $engineName) | nindent 8 }}
8482
{{- include "dremio.executor.extraEnvs" (list $ $engineName) | nindent 8 }}
8583
command: ["/opt/dremio/bin/dremio"]

charts/dremio_v2/templates/dremio-master.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ spec:
8484
value: "/opt/dremio/aws/credentials"
8585
- name: AWS_SHARED_CREDENTIALS_FILE
8686
value: "/opt/dremio/aws/credentials"
87-
- name: DREMIO_LOG_TO_CONSOLE
88-
value: "true"
8987
{{- include "dremio.coordinator.log.path" $ | nindent 8 }}
9088
{{- include "dremio.coordinator.extraEnvs" $ | nindent 8 }}
9189
command: ["/opt/dremio/bin/dremio"]

charts/dremio_v2/tests/dremio-coordinator_test.yaml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,73 @@ tests:
8282
content:
8383
name: TEST_DREMIO
8484
value: test_value
85+
- it: should write logs to console by default
86+
asserts:
87+
- notContains:
88+
path: spec.template.spec.containers[0].env
89+
content:
90+
name: DREMIO_LOG_TO_CONSOLE
91+
value: "0"
92+
- notContains:
93+
path: spec.template.spec.containers[0].env
94+
content:
95+
name: DREMIO_LOG_DIR
96+
value: /opt/dremio/log
97+
- it: should write logs to file when global writeLogsToFile is true
98+
set:
99+
writeLogsToFile: true
100+
asserts:
101+
- contains:
102+
path: spec.template.spec.containers[0].env
103+
content:
104+
name: DREMIO_LOG_TO_CONSOLE
105+
value: "0"
106+
- contains:
107+
path: spec.template.spec.containers[0].env
108+
content:
109+
name: DREMIO_LOG_DIR
110+
value: /opt/dremio/log
111+
- it: should not write logs to file when global writeLogsToFile is false
112+
set:
113+
writeLogsToFile: false
114+
asserts:
115+
- contains:
116+
path: spec.template.spec.containers[0].env
117+
content:
118+
name: DREMIO_LOG_TO_CONSOLE
119+
value: "1"
120+
- notContains:
121+
path: spec.template.spec.containers[0].env
122+
content:
123+
name: DREMIO_LOG_DIR
124+
- it: should not write logs to file when coordinator writeLogsToFile is false
125+
set:
126+
writeLogsToFile: true
127+
coordinator:
128+
writeLogsToFile: false
129+
asserts:
130+
- contains:
131+
path: spec.template.spec.containers[0].env
132+
content:
133+
name: DREMIO_LOG_TO_CONSOLE
134+
value: "1"
135+
- notContains:
136+
path: spec.template.spec.containers[0].env
137+
content:
138+
name: DREMIO_LOG_DIR
139+
- it: should write logs to file when coordinator writeLogsToFile is true
140+
set:
141+
writeLogsToFile: false
142+
coordinator:
143+
writeLogsToFile: true
144+
asserts:
145+
- contains:
146+
path: spec.template.spec.containers[0].env
147+
content:
148+
name: DREMIO_LOG_DIR
149+
value: /opt/dremio/log
150+
- contains:
151+
path: spec.template.spec.containers[0].env
152+
content:
153+
name: DREMIO_LOG_TO_CONSOLE
154+
value: "0"

charts/dremio_v2/tests/dremio-executor_test.yaml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,73 @@ tests:
157157
content:
158158
name: TEST_DREMIO
159159
value: test_value
160+
- it: should write logs to console by default
161+
asserts:
162+
- notContains:
163+
path: spec.template.spec.containers[0].env
164+
content:
165+
name: DREMIO_LOG_TO_CONSOLE
166+
value: "0"
167+
- notContains:
168+
path: spec.template.spec.containers[0].env
169+
content:
170+
name: DREMIO_LOG_DIR
171+
value: /opt/dremio/log
172+
- it: should write logs to file when global writeLogsToFile is true
173+
set:
174+
writeLogsToFile: true
175+
asserts:
176+
- contains:
177+
path: spec.template.spec.containers[0].env
178+
content:
179+
name: DREMIO_LOG_TO_CONSOLE
180+
value: "0"
181+
- contains:
182+
path: spec.template.spec.containers[0].env
183+
content:
184+
name: DREMIO_LOG_DIR
185+
value: /opt/dremio/log
186+
- it: should not write logs to file when global writeLogsToFile is false
187+
set:
188+
writeLogsToFile: false
189+
asserts:
190+
- contains:
191+
path: spec.template.spec.containers[0].env
192+
content:
193+
name: DREMIO_LOG_TO_CONSOLE
194+
value: "1"
195+
- notContains:
196+
path: spec.template.spec.containers[0].env
197+
content:
198+
name: DREMIO_LOG_DIR
199+
- it: should not write logs to file when executor writeLogsToFile is false
200+
set:
201+
writeLogsToFile: true
202+
executor:
203+
writeLogsToFile: false
204+
asserts:
205+
- contains:
206+
path: spec.template.spec.containers[0].env
207+
content:
208+
name: DREMIO_LOG_TO_CONSOLE
209+
value: "1"
210+
- notContains:
211+
path: spec.template.spec.containers[0].env
212+
content:
213+
name: DREMIO_LOG_DIR
214+
- it: should write logs to file when executor writeLogsToFile is true
215+
set:
216+
writeLogsToFile: false
217+
executor:
218+
writeLogsToFile: true
219+
asserts:
220+
- contains:
221+
path: spec.template.spec.containers[0].env
222+
content:
223+
name: DREMIO_LOG_DIR
224+
value: /opt/dremio/log
225+
- contains:
226+
path: spec.template.spec.containers[0].env
227+
content:
228+
name: DREMIO_LOG_TO_CONSOLE
229+
value: "0"

charts/dremio_v2/values.yaml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ coordinator:
8585
# Uncomment this value to use a different storage class for the coordinator logs.
8686
#logStorageClass:
8787

88-
# Uncomment this value to write logs to a file on disk.
88+
# Whether to write coordinator logs to a file on disk. Disabled by default.
89+
# When enabled, log messages are logged to the console and written to a persistent volume mounted at /opt/dremio/log.
90+
# When disabled, log messages are logged to the console only.
8991
#writeLogsToFile: true
9092

9193
# These values, when defined, override the provided shared annotations, labels, node selectors, or tolerations.
@@ -198,10 +200,12 @@ executor:
198200
# Uncomment this value to use a different storage class for executors.
199201
#storageClass:
200202

201-
# Uncomment this value to use a different storage class for the coordinator logs.
203+
# Uncomment this value to use a different storage class for the executor logs.
202204
#logStorageClass:
203205

204-
# Uncomment this value to write logs to a file on disk.
206+
# Whether to write executor logs to a file on disk. Disabled by default.
207+
# When enabled, log messages are logged to the console and written to a persistent volume mounted at /opt/dremio/log.
208+
# When disabled, log messages are logged to the console only.
205209
#writeLogsToFile: true
206210

207211
# Dremio C3
@@ -513,7 +517,9 @@ extraVolumeMounts: []
513517
# Array to add extra environment variables to Dremio's pods
514518
extraEnvs: []
515519

516-
# Uncomment this value to write logs to a file on disk for all Dremio resources.
520+
# Whether to write logs to a file on disk for all Dremio resources. Disabled by default.
521+
# When enabled, log messages are logged to the console and written to a persistent volume mounted at /opt/dremio/log.
522+
# When disabled, log messages are logged to the console only.
517523
#writeLogsToFile: true
518524

519525
# Dremio Service

0 commit comments

Comments
 (0)