From 56e6c13903314b5813880e111a7b8f9a3ef3b9f2 Mon Sep 17 00:00:00 2001 From: gadisn Date: Mon, 4 Mar 2024 09:10:11 +0200 Subject: [PATCH 1/3] feat: support customization for logger dev mode When the log from btp operator is sent to a log system, e.g. OpenSearch, it make sense to turn off the dev mode, so the format will be json - which is simpler to process as structured fields --- main.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 922c3e45..2141db55 100644 --- a/main.go +++ b/main.go @@ -64,15 +64,19 @@ func init() { func main() { var metricsAddr string var enableLeaderElection bool + var loggerUseDevMode bool var probeAddr string flag.StringVar(&metricsAddr, "metrics-addr", ":8080", "The address the metric endpoint binds to.") flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoints bind to.") flag.BoolVar(&enableLeaderElection, "enable-leader-election", false, "Enable leader election for controller manager. "+ "Enabling this will ensure there is only one active controller manager.") + flag.BoolVar(&loggerUseDevMode, "logger_use_dev_mode", true, + "Sets the logger to use dev mode, e.g. more friendly printing format") + flag.Parse() - ctrl.SetLogger(zap.New(zap.UseDevMode(true))) + ctrl.SetLogger(zap.New(zap.UseDevMode(loggerUseDevMode))) mgrOptions := ctrl.Options{ Scheme: scheme, From 31ba0d7177eaacf5b6c0d8b203e37b89a42d3587 Mon Sep 17 00:00:00 2001 From: gadisn Date: Mon, 4 Mar 2024 09:13:13 +0200 Subject: [PATCH 2/3] Update values.yaml --- sapbtp-operator-charts/values.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/sapbtp-operator-charts/values.yaml b/sapbtp-operator-charts/values.yaml index 4ac9e3f8..84c0467e 100644 --- a/sapbtp-operator-charts/values.yaml +++ b/sapbtp-operator-charts/values.yaml @@ -11,6 +11,7 @@ manager: allowed_namespaces: [] replica_count: 2 enable_leader_election: true + logger_use_dev_mode: true management_namespace: image: repository: ghcr.io/sap/sap-btp-service-operator/controller From fb4017df87d743da094035da7272d68c4eaae8a3 Mon Sep 17 00:00:00 2001 From: gadisn Date: Mon, 4 Mar 2024 09:13:37 +0200 Subject: [PATCH 3/3] Update deployment.yml --- sapbtp-operator-charts/templates/deployment.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/sapbtp-operator-charts/templates/deployment.yml b/sapbtp-operator-charts/templates/deployment.yml index 34759e00..5069eb7b 100644 --- a/sapbtp-operator-charts/templates/deployment.yml +++ b/sapbtp-operator-charts/templates/deployment.yml @@ -74,6 +74,7 @@ spec: {{- if .Values.manager.enable_leader_election }} - --enable-leader-election {{- end}} + - --logger_use_dev_mode={{.Values.manager.logger_use_dev_mode}} command: - /manager envFrom: