Skip to content

Commit 4f20a79

Browse files
authored
fix: log template rendreing errors (#433)
Signed-off-by: Luis Davim <[email protected]>
1 parent 4e2b683 commit 4f20a79

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

charts/log-router/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
apiVersion: v1
55
description: Distribution of Fluentd as K8S daemonset
66
name: log-router
7-
version: 0.4.0
7+
version: 0.4.1
88
home: https://github.com/vmware/kube-fluentd-operator
99
sources:
1010
- https://github.com/vmware/kube-fluentd-operator

charts/log-router/templates/clusterrole.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ metadata:
1717
{{- end }}
1818
name: {{ template "fluentd-router.fullname" . }}
1919
rules:
20+
{{- with .Values.extraRBAC }}
21+
{{- toYaml . | nindent 2 }}
22+
{{- end }}
2023
- apiGroups: [""]
2124
resources:
2225
- configmaps

charts/log-router/values.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ rbac:
1414

1515
serviceAccountName: "default"
1616

17+
extraRBAC: {}
18+
# - apiGroups: [""]
19+
# resources: ["secrets"]
20+
# verbs: ["get", "list", "watch"]
21+
1722
# Possible values: default|fake|fs|multimap|crd
1823
datasource: default
1924

config-reloader/datasource/kube_informer.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,10 @@ func (d *kubeInformerConnection) GetNamespaces(ctx context.Context) ([]*Namespac
173173
buf := new(strings.Builder)
174174
if err := template.Render(buf, configdata, map[string]string{
175175
"Namespace": ns,
176-
}); err == nil {
177-
configdata = buf.String()
176+
}); err != nil {
177+
logrus.Errorf("failed to render config in namespace: %v", ns)
178178
}
179+
configdata = buf.String()
179180
if configdata == "" {
180181
logrus.Infof("Skipping namespace: %v because is empty", ns)
181182
continue
@@ -375,8 +376,9 @@ func (d *kubeInformerConnection) handlePodChange(ctx context.Context, obj interf
375376
if err := template.Render(buf, configdata, map[string]string{
376377
"Namespace": mObj.GetNamespace(),
377378
}); err == nil {
378-
configdata = buf.String()
379+
logrus.Errorf("failed to render config in namespace: %v", mObj.GetNamespace())
379380
}
381+
configdata = buf.String()
380382
nsConfigStr := fmt.Sprintf("%#v", configdata)
381383

382384
if err == nil {

0 commit comments

Comments
 (0)