From ba674e9b30b777c4c7481244ab0167a68edb8e68 Mon Sep 17 00:00:00 2001 From: Luis Davim Date: Mon, 15 Jan 2024 11:24:39 +0000 Subject: [PATCH] fix: log template rendreing errors Signed-off-by: Luis Davim --- charts/log-router/Chart.yaml | 2 +- charts/log-router/templates/clusterrole.yaml | 3 +++ charts/log-router/values.yaml | 5 +++++ config-reloader/datasource/kube_informer.go | 8 +++++--- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/charts/log-router/Chart.yaml b/charts/log-router/Chart.yaml index 07ca6ad0..e2871669 100755 --- a/charts/log-router/Chart.yaml +++ b/charts/log-router/Chart.yaml @@ -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 diff --git a/charts/log-router/templates/clusterrole.yaml b/charts/log-router/templates/clusterrole.yaml index da69bdf9..db5a1c91 100755 --- a/charts/log-router/templates/clusterrole.yaml +++ b/charts/log-router/templates/clusterrole.yaml @@ -17,6 +17,9 @@ metadata: {{- end }} name: {{ template "fluentd-router.fullname" . }} rules: +{{- with .Values.extraRBAC }} + {{- toYaml . | nindent 2 }} +{{- end }} - apiGroups: [""] resources: - configmaps diff --git a/charts/log-router/values.yaml b/charts/log-router/values.yaml index 03f6e122..712e89a5 100755 --- a/charts/log-router/values.yaml +++ b/charts/log-router/values.yaml @@ -14,6 +14,11 @@ rbac: serviceAccountName: "default" +extraRBAC: {} + # - apiGroups: [""] + # resources: ["secrets"] + # verbs: ["get", "list", "watch"] + # Possible values: default|fake|fs|multimap|crd datasource: default diff --git a/config-reloader/datasource/kube_informer.go b/config-reloader/datasource/kube_informer.go index afe1f062..4ea5d05a 100644 --- a/config-reloader/datasource/kube_informer.go +++ b/config-reloader/datasource/kube_informer.go @@ -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 @@ -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 {