Skip to content

Commit d30366c

Browse files
committed
crd: add clickhouse.logLevel (#22)
1 parent 8667797 commit d30366c

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

api/v1/coroot_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ type ClickhouseSpec struct {
144144
// Annotations for clickhouse pods.
145145
PodAnnotations map[string]string `json:"podAnnotations,omitempty"`
146146
Image ImageSpec `json:"image,omitempty"`
147+
// Log level (fatal, critical, error, warning, notice, information, debug, trace, test, or none; default: warning).
148+
// +kubebuilder:validation:Enum="none";"fatal";"critical";"error";"warning";"notice";"information";"debug";"trace";"test"
149+
LogLevel string `json:"logLevel,omitempty"`
147150

148151
Keeper ClickhouseKeeperSpec `json:"keeper,omitempty"`
149152
}

config/crd/coroot.com_coroots.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3224,6 +3224,21 @@ spec:
32243224
type: object
32253225
type: array
32263226
type: object
3227+
logLevel:
3228+
description: 'Log level (fatal, critical, error, warning, notice,
3229+
information, debug, trace, test, or none; default: warning).'
3230+
enum:
3231+
- none
3232+
- fatal
3233+
- critical
3234+
- error
3235+
- warning
3236+
- notice
3237+
- information
3238+
- debug
3239+
- trace
3240+
- test
3241+
type: string
32273242
nodeSelector:
32283243
additionalProperties:
32293244
type: string

controller/clickhouse.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,11 @@ func clickhouseConfigCmd(filename string, cr *corootv1.Coroot, shards, replicas,
250250
Shards []int
251251
Replicas []int
252252
Keepers []int
253+
LogLevel string
253254
}{
254255
Namespace: cr.Namespace,
255256
Name: cr.Name,
257+
LogLevel: cr.Spec.Clickhouse.LogLevel,
256258
}
257259
for i := 0; i < shards; i++ {
258260
params.Shards = append(params.Shards, i)
@@ -263,6 +265,9 @@ func clickhouseConfigCmd(filename string, cr *corootv1.Coroot, shards, replicas,
263265
for i := 0; i < keepers; i++ {
264266
params.Keepers = append(params.Keepers, i)
265267
}
268+
if params.LogLevel == "" {
269+
params.LogLevel = "warning"
270+
}
266271
var out bytes.Buffer
267272
_ = clickhouseConfigTemplate.Execute(&out, params)
268273
return "cat <<EOF > " + filename + out.String() + "EOF"
@@ -286,7 +291,7 @@ var clickhouseConfigTemplate = template.Must(template.New("").Parse(`
286291
287292
<logger>
288293
<console>1</console>
289-
<level>information</level>
294+
<level>{{ .LogLevel }}</level>
290295
</logger>
291296
292297
<listen_host>::</listen_host>

0 commit comments

Comments
 (0)