# HG changeset patch
# User Hordur Freyr Yngvason <hfyngvason@gitlab.com>
# Date 1646257727 0
#      Wed Mar 02 21:48:47 2022 +0000
# Node ID 9e6fc1e06869aa6d3954267a12faaf16a4e02cd6
# Parent  10b0ed22000aa570e07f708bc7f3d62434d1320d
Add gitlab_kas['log_level'] customization

The default KAS log level is 'info', but when troubleshooting we usually
want it to be 'debug'. So this option needs to be exposed to users.

Changelog: added

diff --git a/files/gitlab-config-template/gitlab.rb.template b/files/gitlab-config-template/gitlab.rb.template
--- a/files/gitlab-config-template/gitlab.rb.template
+++ b/files/gitlab-config-template/gitlab.rb.template
@@ -1821,6 +1821,9 @@
 ##! Metrics configuration for GitLab KAS
 # gitlab_kas['metrics_usage_reporting_period'] = 60
 
+##! Log configuration for GitLab KAS
+# gitlab_kas['log_level'] = 'info'
+
 ##! Environment variables for GitLab KAS
 # gitlab_kas['env'] = {
 #   'SSL_CERT_DIR' => "/opt/gitlab/embedded/ssl/certs/",
diff --git a/files/gitlab-cookbooks/gitlab-kas/attributes/default.rb b/files/gitlab-cookbooks/gitlab-kas/attributes/default.rb
--- a/files/gitlab-cookbooks/gitlab-kas/attributes/default.rb
+++ b/files/gitlab-cookbooks/gitlab-kas/attributes/default.rb
@@ -30,6 +30,7 @@
 default['gitlab-kas']['metrics_usage_reporting_period'] = 60
 default['gitlab-kas']['sentry_dsn'] = nil
 default['gitlab-kas']['sentry_environment'] = nil
+default['gitlab-kas']['log_level'] = 'info'
 default['gitlab-kas']['dir'] = '/var/opt/gitlab/gitlab-kas'
 default['gitlab-kas']['log_directory'] = '/var/log/gitlab/gitlab-kas'
 default['gitlab-kas']['env_directory'] = '/opt/gitlab/etc/gitlab-kas/env'
diff --git a/files/gitlab-cookbooks/gitlab-kas/templates/default/gitlab-kas-config.yml.erb b/files/gitlab-cookbooks/gitlab-kas/templates/default/gitlab-kas-config.yml.erb
--- a/files/gitlab-cookbooks/gitlab-kas/templates/default/gitlab-kas-config.yml.erb
+++ b/files/gitlab-cookbooks/gitlab-kas/templates/default/gitlab-kas-config.yml.erb
@@ -35,6 +35,8 @@
     environment: <%= @sentry_environment %>
     <%- end %>
   <%- end %>
+  logging:
+    level: <%= @log_level %>
 redis:
   network: <%= @redis_network %>
   tls:
diff --git a/spec/chef/recipes/gitlab-kas_spec.rb b/spec/chef/recipes/gitlab-kas_spec.rb
--- a/spec/chef/recipes/gitlab-kas_spec.rb
+++ b/spec/chef/recipes/gitlab-kas_spec.rb
@@ -57,6 +57,9 @@
             }
           ),
           observability: {
+            logging: {
+              level: 'info',
+            },
             usage_reporting_period: '60s'
           },
           private_api: {
@@ -95,7 +98,8 @@
           listen_websocket: false,
           metrics_usage_reporting_period: '120',
           sentry_dsn: 'https://my_key:my_secret@sentry.io/test_project',
-          sentry_environment: 'production'
+          sentry_environment: 'production',
+          log_level: 'debug',
         }
       )
     end
@@ -119,6 +123,9 @@
             }
           ),
           observability: {
+            logging: {
+              level: 'debug'
+            },
             usage_reporting_period: '120s',
             sentry: {
               dsn: 'https://my_key:my_secret@sentry.io/test_project',