Skip to content

Commit 3550700

Browse files
committed
code review fixes and bugs
1 parent 823d89c commit 3550700

File tree

12 files changed

+45
-11
lines changed

12 files changed

+45
-11
lines changed

build/logcollector/entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ else
1717
fluentbit_opt+='-c /opt/percona/logcollector/fluentbit/fluentbit.conf'
1818
fi
1919

20-
exec "$@" "$fluentbit_opt"
20+
exec "$@" $fluentbit_opt
2121
fi

build/logcollector/fluentbit/fluentbit_mongo.conf

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,14 @@
1-
[PARSER]
2-
Name json
3-
Format json
4-
Time_Key t.$date
5-
Time_Format %Y-%m-%dT%H:%M:%S.%L%z
6-
71
[SERVICE]
82
Flush 1
9-
Log_Level debug
3+
Log_Level error
104
Daemon off
11-
Parser json
125

136
[INPUT]
147
Name tail
158
Path ${LOG_DATA_DIR}/mongod.log
169
Tag ${POD_NAMESPACE}.${POD_NAME}.mongod.log
1710
Refresh_Interval 5
1811
DB /tmp/flb_kube.db
19-
Parser json
2012
read_from_head true
2113
Path_Key file
2214

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[MULTILINE_PARSER]
2+
name multiline-regex-test
3+
type regex
4+
flush_timeout 1000
5+
#
6+
# Regex rules for multiline parsing
7+
# ---------------------------------
8+
#
9+
# configuration hints:
10+
#
11+
# - first state always has the name: start_state
12+
# - every field in the rule must be inside double quotes
13+
#
14+
# rules | state name | regex pattern | next state
15+
# ------|---------------|--------------------------------------------
16+
rule "start_state" "/\d{2,4}\-\d{2,4}\-\d{2,4}T\d{2,4}\:\d{2,4}\:\d{2,4}\.\d{1,6}Z(.*)|\d{2,6} \d{2,4}\:\d{2,4}\:\d{2,4}(.*)/" "cont"
17+
rule "cont" "/^\D/" "cont"

build/ps-entry.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ if [[ $originalArgOne == mongo* ]]; then
480480
_mongod_hack_rename_arg_save_val --sslDisabledProtocols --tlsDisabledProtocols "${mongodHackedArgs[@]}"
481481
fi
482482

483-
if [[ $originalArgOne == "mongod" ]]; then
483+
if [[ $originalArgOne == "mongod" && "${LOGCOLLECTOR_ENABLED:-}" == "true" ]]; then
484484
_mongod_hack_ensure_arg_val --logpath "/data/logs/mongod.log" "${mongodHackedArgs[@]}"
485485
_mongod_hack_ensure_arg --logappend "${mongodHackedArgs[@]}"
486486
fi

pkg/apis/psmdb/v1/psmdb_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,3 +1368,7 @@ type LogCollectorSpec struct {
13681368
ContainerSecurityContext *corev1.SecurityContext `json:"containerSecurityContext,omitempty"`
13691369
ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"`
13701370
}
1371+
1372+
func (cr *PerconaServerMongoDB) IsLogCollectorEnabled() bool {
1373+
return cr.Spec.LogCollector != nil && cr.Spec.LogCollector.Enabled
1374+
}

pkg/controller/perconaservermongodb/testdata/reconcile-statefulset/cfg-arbiter.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ spec:
7979
value: "27017"
8080
- name: MONGODB_REPLSET
8181
value: cfg
82+
- name: LOGCOLLECTOR_ENABLED
83+
value: "true"
8284
envFrom:
8385
- secretRef:
8486
name: internal-reconcile-statefulset-cr-users

pkg/controller/perconaservermongodb/testdata/reconcile-statefulset/cfg-mongod.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ spec:
7979
value: "27017"
8080
- name: MONGODB_REPLSET
8181
value: cfg
82+
- name: LOGCOLLECTOR_ENABLED
83+
value: "true"
8284
envFrom:
8385
- secretRef:
8486
name: internal-reconcile-statefulset-cr-users

pkg/controller/perconaservermongodb/testdata/reconcile-statefulset/cfg-nv.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ spec:
7979
value: "27017"
8080
- name: MONGODB_REPLSET
8181
value: cfg
82+
- name: LOGCOLLECTOR_ENABLED
83+
value: "true"
8284
envFrom:
8385
- secretRef:
8486
name: internal-reconcile-statefulset-cr-users

pkg/controller/perconaservermongodb/testdata/reconcile-statefulset/rs0-arbiter.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ spec:
7979
value: "27017"
8080
- name: MONGODB_REPLSET
8181
value: rs0
82+
- name: LOGCOLLECTOR_ENABLED
83+
value: "true"
8284
envFrom:
8385
- secretRef:
8486
name: internal-reconcile-statefulset-cr-users

pkg/controller/perconaservermongodb/testdata/reconcile-statefulset/rs0-mongod.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ spec:
7979
value: "27017"
8080
- name: MONGODB_REPLSET
8181
value: rs0
82+
- name: LOGCOLLECTOR_ENABLED
83+
value: "true"
8284
envFrom:
8385
- secretRef:
8486
name: internal-reconcile-statefulset-cr-users

pkg/controller/perconaservermongodb/testdata/reconcile-statefulset/rs0-nv.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ spec:
7979
value: "27017"
8080
- name: MONGODB_REPLSET
8181
value: rs0
82+
- name: LOGCOLLECTOR_ENABLED
83+
value: "true"
8284
envFrom:
8385
- secretRef:
8486
name: internal-reconcile-statefulset-cr-users

pkg/psmdb/container.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,15 @@ func container(ctx context.Context, cr *api.PerconaServerMongoDB, replset *api.R
175175
container.Command = []string{config.BinMountPath + "/ps-entry.sh"}
176176
}
177177

178+
if cr.CompareVersion("1.20.0") >= 0 {
179+
if cr.IsLogCollectorEnabled() {
180+
container.Env = append(container.Env, corev1.EnvVar{
181+
Name: "LOGCOLLECTOR_ENABLED",
182+
Value: "true",
183+
})
184+
}
185+
}
186+
178187
return container, nil
179188
}
180189

0 commit comments

Comments
 (0)