From 724c0d3eb02737146272b6ba64d5be7815648241 Mon Sep 17 00:00:00 2001 From: Andrew Keesler Date: Wed, 11 Nov 2020 07:49:46 -0500 Subject: [PATCH 1/2] Add YTT template value for setting log level This is helpful for us, amongst other users, because we want to enable "debug" logging whenever we deploy components for testing. See a5643e3 for addition of log level. Signed-off-by: Andrew Keesler --- deploy/concierge/deployment.yaml | 5 ++++- deploy/concierge/helpers.lib.yaml | 8 ++++++++ deploy/concierge/values.yaml | 4 ++++ deploy/supervisor/deployment.yaml | 5 ++++- deploy/supervisor/helpers.lib.yaml | 8 ++++++++ deploy/supervisor/values.yaml | 4 ++++ 6 files changed, 32 insertions(+), 2 deletions(-) diff --git a/deploy/concierge/deployment.yaml b/deploy/concierge/deployment.yaml index 52f9cf29..b4d6351f 100644 --- a/deploy/concierge/deployment.yaml +++ b/deploy/concierge/deployment.yaml @@ -3,7 +3,7 @@ #@ load("@ytt:data", "data") #@ load("@ytt:json", "json") -#@ load("helpers.lib.yaml", "defaultLabel", "labels", "namespace", "defaultResourceName", "defaultResourceNameWithSuffix") +#@ load("helpers.lib.yaml", "defaultLabel", "labels", "namespace", "defaultResourceName", "defaultResourceNameWithSuffix", "getAndValidateLogLevel") #@ if not data.values.into_namespace: --- @@ -57,6 +57,9 @@ data: imagePullSecrets: - image-pull-secret (@ end @) + (@ if data.values.log_level: @) + logLevel: (@= getAndValidateLogLevel() @) + (@ end @) --- #@ if data.values.image_pull_dockerconfigjson and data.values.image_pull_dockerconfigjson != "": apiVersion: v1 diff --git a/deploy/concierge/helpers.lib.yaml b/deploy/concierge/helpers.lib.yaml index f893152e..452faa75 100644 --- a/deploy/concierge/helpers.lib.yaml +++ b/deploy/concierge/helpers.lib.yaml @@ -28,3 +28,11 @@ app: #@ data.values.app_name _: #@ template.replace(defaultLabel()) _: #@ template.replace(data.values.custom_labels) #@ end + +#@ def getAndValidateLogLevel(): +#@ log_level = data.values.log_level +#@ if log_level != "info" and log_level != "debug" and log_level != "trace" and log_level != "all": +#@ fail("log_level '" + log_level + "' is invalid") +#@ end +#@ return log_level +#@ end diff --git a/deploy/concierge/values.yaml b/deploy/concierge/values.yaml index 00eddbdb..d7e0069e 100644 --- a/deploy/concierge/values.yaml +++ b/deploy/concierge/values.yaml @@ -50,3 +50,7 @@ discovery_url: #! e.g., https://example.com #! about every 25 days. api_serving_certificate_duration_seconds: 2592000 api_serving_certificate_renew_before_seconds: 2160000 + +#! Specify the verbosity of logging: info ("nice to know" information), debug (developer +#! information), trace (timing information), all (kitchen sink). +log_level: #! By default, when this value is left unset, only warnings and errors are printed. There is no way to suppress warning and error logs. diff --git a/deploy/supervisor/deployment.yaml b/deploy/supervisor/deployment.yaml index 9bd74483..28b8d93f 100644 --- a/deploy/supervisor/deployment.yaml +++ b/deploy/supervisor/deployment.yaml @@ -3,7 +3,7 @@ #@ load("@ytt:data", "data") #@ load("@ytt:json", "json") -#@ load("helpers.lib.yaml", "defaultLabel", "labels", "namespace", "defaultResourceName", "defaultResourceNameWithSuffix") +#@ load("helpers.lib.yaml", "defaultLabel", "labels", "namespace", "defaultResourceName", "defaultResourceNameWithSuffix", "getAndValidateLogLevel") #@ if not data.values.into_namespace: --- @@ -33,6 +33,9 @@ data: names: defaultTLSCertificateSecret: (@= defaultResourceNameWithSuffix("default-tls-certificate") @) labels: (@= json.encode(labels()).rstrip() @) + (@ if data.values.log_level: @) + logLevel: (@= getAndValidateLogLevel() @) + (@ end @) --- #@ if data.values.image_pull_dockerconfigjson and data.values.image_pull_dockerconfigjson != "": apiVersion: v1 diff --git a/deploy/supervisor/helpers.lib.yaml b/deploy/supervisor/helpers.lib.yaml index f893152e..452faa75 100644 --- a/deploy/supervisor/helpers.lib.yaml +++ b/deploy/supervisor/helpers.lib.yaml @@ -28,3 +28,11 @@ app: #@ data.values.app_name _: #@ template.replace(defaultLabel()) _: #@ template.replace(data.values.custom_labels) #@ end + +#@ def getAndValidateLogLevel(): +#@ log_level = data.values.log_level +#@ if log_level != "info" and log_level != "debug" and log_level != "trace" and log_level != "all": +#@ fail("log_level '" + log_level + "' is invalid") +#@ end +#@ return log_level +#@ end diff --git a/deploy/supervisor/values.yaml b/deploy/supervisor/values.yaml index 480d1cc1..5456ebe3 100644 --- a/deploy/supervisor/values.yaml +++ b/deploy/supervisor/values.yaml @@ -52,3 +52,7 @@ service_https_clusterip_port: #! when specified, creates a ClusterIP Service wit #! Ignored unless service_http_loadbalancer_port and/or service_https_loadbalancer_port are provided. #! Optional. service_loadbalancer_ip: #! e.g. 1.2.3.4 + +#! Specify the verbosity of logging: info ("nice to know" information), debug (developer +#! information), trace (timing information), all (kitchen sink). +log_level: #! By default, when this value is left unset, only warnings and errors are printed. There is no way to suppress warning and error logs. From 83a156d72b6d5dbb98b89a9e3155831741d2c032 Mon Sep 17 00:00:00 2001 From: Andrew Keesler Date: Wed, 11 Nov 2020 07:51:51 -0500 Subject: [PATCH 2/2] Enable debug logging in all testing scenarios It is really helpful to have verbose logs during test debugging. Signed-off-by: Andrew Keesler --- cmd/local-user-authenticator/main.go | 5 +++++ hack/lib/tilt/Tiltfile | 2 ++ hack/prepare-for-integration-tests.sh | 2 ++ 3 files changed, 9 insertions(+) diff --git a/cmd/local-user-authenticator/main.go b/cmd/local-user-authenticator/main.go index c4dd9db8..bd00bf36 100644 --- a/cmd/local-user-authenticator/main.go +++ b/cmd/local-user-authenticator/main.go @@ -395,6 +395,11 @@ func run() error { } func main() { + // Hardcode the logging level to debug, since this is a test app and it is very helpful to have + // verbose logs to debug test failures. + if err := plog.ValidateAndSetLogLevelGlobally(plog.LevelDebug); err != nil { + klog.Fatal(err) + } if err := run(); err != nil { klog.Fatal(err) } diff --git a/hack/lib/tilt/Tiltfile b/hack/lib/tilt/Tiltfile index 767582c8..9358451d 100644 --- a/hack/lib/tilt/Tiltfile +++ b/hack/lib/tilt/Tiltfile @@ -95,6 +95,7 @@ k8s_yaml(local([ '--data-value', 'namespace=supervisor', '--data-value', 'image_repo=image/supervisor', '--data-value', 'image_tag=tilt-dev', + '--data-value', 'log_level=debug', '--data-value-yaml', 'replicas=1', '--data-value-yaml', 'service_http_nodeport_port=80', '--data-value-yaml', 'service_http_nodeport_nodeport=31234', @@ -142,6 +143,7 @@ k8s_yaml(local([ '--data-value image_tag=tilt-dev ' + '--data-value kube_cert_agent_image=debian:10.6-slim ' + '--data-value discovery_url=$(TERM=dumb kubectl cluster-info | awk \'/Kubernetes master/ {print $NF}\') ' + + '--data-value log_level=debug ' + '--data-value-yaml replicas=1 ' + '--data-value-yaml "custom_labels={myConciergeCustomLabelName: myConciergeCustomLabelValue}"' ])) diff --git a/hack/prepare-for-integration-tests.sh b/hack/prepare-for-integration-tests.sh index e8512827..d3d7cb24 100755 --- a/hack/prepare-for-integration-tests.sh +++ b/hack/prepare-for-integration-tests.sh @@ -224,6 +224,7 @@ if ! tilt_mode; then --data-value "namespace=$supervisor_namespace" \ --data-value "image_repo=$registry_repo" \ --data-value "image_tag=$tag" \ + --data-value "log_level=debug" \ --data-value-yaml "custom_labels=$supervisor_custom_labels" \ --data-value-yaml 'service_http_nodeport_port=80' \ --data-value-yaml 'service_http_nodeport_nodeport=31234' \ @@ -253,6 +254,7 @@ if ! tilt_mode; then ytt --file . \ --data-value "app_name=$concierge_app_name" \ --data-value "namespace=$concierge_namespace" \ + --data-value "log_level=debug" \ --data-value-yaml "custom_labels=$concierge_custom_labels" \ --data-value "image_repo=$registry_repo" \ --data-value "image_tag=$tag" \