Skip to content

Commit

Permalink
fix: log template rendreing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
luisdavim committed Jan 15, 2024
1 parent 4e2b683 commit 0e89823
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion charts/log-router/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
apiVersion: v1
description: Distribution of Fluentd as K8S daemonset
name: log-router
version: 0.4.0
version: 0.4.1
home: https://github.com/vmware/kube-fluentd-operator
sources:
- https://github.com/vmware/kube-fluentd-operator
3 changes: 3 additions & 0 deletions charts/log-router/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ metadata:
{{- end }}
name: {{ template "fluentd-router.fullname" . }}
rules:
{{- with .Values.extraRBAC }}
{{- toYaml . | nindent 2 }}
{{- end }}
- apiGroups: [""]
resources:
- configmaps
Expand Down
5 changes: 5 additions & 0 deletions charts/log-router/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ rbac:

serviceAccountName: "default"

extraRBAC: {}
# - apiGroups: [""]
# resources: ["secrets"]
# verbs: ["get", "list", "watch"]

# Possible values: default|fake|fs|multimap|crd
datasource: default

Expand Down
8 changes: 5 additions & 3 deletions config-reloader/datasource/kube_informer.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,10 @@ func (d *kubeInformerConnection) GetNamespaces(ctx context.Context) ([]*Namespac
buf := new(strings.Builder)
if err := template.Render(buf, configdata, map[string]string{
"Namespace": ns,
}); err == nil {
configdata = buf.String()
}); err != nil {
logrus.Errorf("failed to render config in namespace: %v", ns)
}
configdata = buf.String()
if configdata == "" {
logrus.Infof("Skipping namespace: %v because is empty", ns)
continue
Expand Down Expand Up @@ -375,8 +376,9 @@ func (d *kubeInformerConnection) handlePodChange(ctx context.Context, obj interf
if err := template.Render(buf, configdata, map[string]string{
"Namespace": mObj.GetNamespace(),
}); err == nil {
configdata = buf.String()
logrus.Errorf("failed to render config in namespace: %v", mObj.GetNamespace())
}
configdata = buf.String()
nsConfigStr := fmt.Sprintf("%#v", configdata)

if err == nil {
Expand Down

0 comments on commit 0e89823

Please sign in to comment.