From 2e3b3e5361065308cfc2b21fe54fe56abb30582c Mon Sep 17 00:00:00 2001 From: Pubudu Gunatilaka Date: Sun, 31 Mar 2024 17:12:47 +0530 Subject: [PATCH 1/2] Fix logging issue in cc --- adapter/pkg/config/parser.go | 3 +-- .../data-plane/gateway-components/common-log-conf.yaml | 8 ++++++-- helm-charts/values.yaml.template | 7 +++++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/adapter/pkg/config/parser.go b/adapter/pkg/config/parser.go index 583ae17f0..76a0dbe94 100644 --- a/adapter/pkg/config/parser.go +++ b/adapter/pkg/config/parser.go @@ -22,7 +22,6 @@ package config import ( "fmt" - "io/ioutil" "os" "path/filepath" "reflect" @@ -107,7 +106,7 @@ func ReadLogConfigs() *LogConfig { adapterLogConfig = getDefaultLogConfig() path, err := GetLogConfigPath() if err == nil { - content, readErr := ioutil.ReadFile(filepath.Clean(path)) + content, readErr := os.ReadFile(filepath.Clean(path)) if readErr != nil { logger.Error("Proceeding with default log configuration as error occured while reading log configurations ", readErr) } else { diff --git a/helm-charts/templates/data-plane/gateway-components/common-log-conf.yaml b/helm-charts/templates/data-plane/gateway-components/common-log-conf.yaml index 909c48c01..cbaf50a9f 100644 --- a/helm-charts/templates/data-plane/gateway-components/common-log-conf.yaml +++ b/helm-charts/templates/data-plane/gateway-components/common-log-conf.yaml @@ -94,11 +94,15 @@ data: log_config.toml: | # The logging configuration for Adapter - ## Adapter root Level configurations + ## Common Controller root Level configurations - logfile = "adapter.log" # This file will be created inside adapter container. + {{- if .Values.wso2.apk.dp.commonController.logging }} + logLevel = "{{ .Values.wso2.apk.dp.commonController.logging.level | default "INFO" }}" # LogLevels can be "DEBG", "FATL", "ERRO", "WARN", "INFO", "PANC" + LogFormat = "{{ .Values.wso2.apk.dp.commonController.logging.logFormat | default "TEXT" }}" # Values can be "JSON", "TEXT" + {{- else }} logLevel = "INFO" # LogLevels can be "DEBG", "FATL", "ERRO", "WARN", "INFO", "PANC" LogFormat = "TEXT" # Values can be "JSON", "TEXT" + {{- end }} [rotation] MaxSize = 10 # In MegaBytes (MB) diff --git a/helm-charts/values.yaml.template b/helm-charts/values.yaml.template index f9fb9ebe7..f4e122a11 100644 --- a/helm-charts/values.yaml.template +++ b/helm-charts/values.yaml.template @@ -347,6 +347,13 @@ wso2: poolMaxConnIdleTime: "1h" poolHealthCheckPeriod: "1m" poolMaxConnLifetimeJitter: "1s" + logging: + # -- Optionally configure logging for common controller. + # LogLevels can be "DEBG", "FATL", "ERRO", "WARN", "INFO", "PANC" + level: "INFO" + # -- Log format can be "JSON", "TEXT" + logFormat: "TEXT" + type ratelimiter: # -- Enable the deployment of the Rate Limiter From 9678fcb7e933802f1465375c10638d00714b8187 Mon Sep 17 00:00:00 2001 From: Pubudu Gunatilaka Date: Sun, 31 Mar 2024 17:38:02 +0530 Subject: [PATCH 2/2] Fix Gin mode in cc --- common-controller/internal/server/server.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common-controller/internal/server/server.go b/common-controller/internal/server/server.go index c9fbed9d5..192aa645b 100644 --- a/common-controller/internal/server/server.go +++ b/common-controller/internal/server/server.go @@ -16,6 +16,8 @@ var applicationKeyMappingMap = make(map[string]ApplicationKeyMapping) // StartInternalServer starts the internal server func StartInternalServer() { + + gin.SetMode(gin.ReleaseMode) r := gin.Default() r.GET("/applications", func(c *gin.Context) { @@ -46,7 +48,6 @@ func StartInternalServer() { } c.JSON(http.StatusOK, ApplicationKeyMappingList{List: applicationKeyMappingList}) }) - gin.SetMode(gin.ReleaseMode) conf := config.ReadConfigs() certPath := conf.CommonController.Keystore.CertPath keyPath := conf.CommonController.Keystore.KeyPath