From c36bcb50fbc9f8c69e9097e21f0334a636526b5c Mon Sep 17 00:00:00 2001 From: Manuel Alejandro de Brito Fontes Date: Thu, 10 Jun 2021 15:08:56 -0400 Subject: [PATCH] Use gitpod-io log package --- components/blobserve/cmd/root.go | 5 +++++ components/common-go/log/redact_test.go | 6 ++---- components/ee/ws-scheduler/cmd/run.go | 2 +- components/ee/ws-scheduler/pkg/scheduler/strategy.go | 2 +- components/ws-daemon/cmd/client-init.go | 2 +- components/ws-manager/cmd/root.go | 9 +++++---- dev/poolkeeper/cmd/root.go | 3 +-- dev/poolkeeper/cmd/run.go | 2 +- install/installer/cmd/bash.go | 3 ++- install/installer/pkg/gcp/gcp.go | 3 ++- 10 files changed, 21 insertions(+), 16 deletions(-) diff --git a/components/blobserve/cmd/root.go b/components/blobserve/cmd/root.go index effe7a61fb6b0b..718f91f633d748 100644 --- a/components/blobserve/cmd/root.go +++ b/components/blobserve/cmd/root.go @@ -5,10 +5,12 @@ package cmd import ( + "context" "encoding/json" "fmt" "os" + containerd_log "github.com/containerd/containerd/log" "github.com/spf13/cobra" "github.com/gitpod-io/gitpod/blobserve/pkg/blobserve" @@ -30,6 +32,9 @@ var rootCmd = &cobra.Command{ Args: cobra.MinimumNArgs(1), PersistentPreRun: func(cmd *cobra.Command, args []string) { log.Init(ServiceName, Version, jsonLog, jsonLog) + + // configure containerd log with gitpod-io configuration + containerd_log.WithLogger(context.Background(), log.Log) }, } diff --git a/components/common-go/log/redact_test.go b/components/common-go/log/redact_test.go index 8be7e7a4dbde0c..1fbce09cb47159 100644 --- a/components/common-go/log/redact_test.go +++ b/components/common-go/log/redact_test.go @@ -2,12 +2,10 @@ // Licensed under the GNU Affero General Public License (AGPL). // See License-AGPL.txt in the project root for license information. -package log_test +package log import ( "testing" - - "github.com/gitpod-io/gitpod/common-go/log" ) func TestRedactJSON(t *testing.T) { @@ -22,7 +20,7 @@ func TestRedactJSON(t *testing.T) { } for i, test := range tests { - res, err := log.RedactJSON([]byte(test.Input)) + res, err := RedactJSON([]byte(test.Input)) if err != nil { t.Errorf("test %d failed: %v", i, err) continue diff --git a/components/ee/ws-scheduler/cmd/run.go b/components/ee/ws-scheduler/cmd/run.go index 0ccc2333a28727..bac7e22d043f78 100644 --- a/components/ee/ws-scheduler/cmd/run.go +++ b/components/ee/ws-scheduler/cmd/run.go @@ -13,9 +13,9 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" + "github.com/gitpod-io/gitpod/common-go/log" "github.com/gitpod-io/gitpod/common-go/pprof" "github.com/gitpod-io/gitpod/ws-scheduler/pkg/scaler" sched "github.com/gitpod-io/gitpod/ws-scheduler/pkg/scheduler" diff --git a/components/ee/ws-scheduler/pkg/scheduler/strategy.go b/components/ee/ws-scheduler/pkg/scheduler/strategy.go index 78e4ae43aafc64..822669e89084a5 100644 --- a/components/ee/ws-scheduler/pkg/scheduler/strategy.go +++ b/components/ee/ws-scheduler/pkg/scheduler/strategy.go @@ -9,11 +9,11 @@ import ( "sort" "time" - log "github.com/sirupsen/logrus" "golang.org/x/xerrors" corev1 "k8s.io/api/core/v1" wsk8s "github.com/gitpod-io/gitpod/common-go/kubernetes" + "github.com/gitpod-io/gitpod/common-go/log" ) // StrategyName is the type that identifies strategies diff --git a/components/ws-daemon/cmd/client-init.go b/components/ws-daemon/cmd/client-init.go index 2ca1d0b5519198..123f71f6315c31 100644 --- a/components/ws-daemon/cmd/client-init.go +++ b/components/ws-daemon/cmd/client-init.go @@ -8,9 +8,9 @@ import ( "context" "github.com/alecthomas/repr" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" + "github.com/gitpod-io/gitpod/common-go/log" csapi "github.com/gitpod-io/gitpod/content-service/api" "github.com/gitpod-io/gitpod/ws-daemon/api" ) diff --git a/components/ws-manager/cmd/root.go b/components/ws-manager/cmd/root.go index b44f26153ef05f..6acf0fc0813a1b 100644 --- a/components/ws-manager/cmd/root.go +++ b/components/ws-manager/cmd/root.go @@ -11,16 +11,17 @@ import ( "github.com/prometheus/client_golang/prometheus" + "github.com/spf13/cobra" + "k8s.io/client-go/kubernetes" + "k8s.io/client-go/rest" + "k8s.io/client-go/tools/clientcmd" + "github.com/gitpod-io/gitpod/common-go/grpc" wsk8s "github.com/gitpod-io/gitpod/common-go/kubernetes" "github.com/gitpod-io/gitpod/common-go/log" "github.com/gitpod-io/gitpod/common-go/tracing" "github.com/gitpod-io/gitpod/content-service/pkg/storage" "github.com/gitpod-io/gitpod/ws-manager/pkg/manager" - "github.com/spf13/cobra" - "k8s.io/client-go/kubernetes" - "k8s.io/client-go/rest" - "k8s.io/client-go/tools/clientcmd" ) var ( diff --git a/dev/poolkeeper/cmd/root.go b/dev/poolkeeper/cmd/root.go index e1bf0a0a5e4ccf..39a9a385bfa1f6 100644 --- a/dev/poolkeeper/cmd/root.go +++ b/dev/poolkeeper/cmd/root.go @@ -9,15 +9,14 @@ import ( "fmt" "os" - wsk8s "github.com/gitpod-io/gitpod/common-go/kubernetes" "github.com/spf13/cobra" "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" "k8s.io/client-go/tools/clientcmd" + wsk8s "github.com/gitpod-io/gitpod/common-go/kubernetes" "github.com/gitpod-io/gitpod/common-go/log" "github.com/gitpod-io/gitpod/common-go/tracing" - "github.com/gitpod-io/gitpod/poolkeeper/pkg/poolkeeper" ) diff --git a/dev/poolkeeper/cmd/run.go b/dev/poolkeeper/cmd/run.go index daad7d167bca40..f10ed22b50ddbd 100644 --- a/dev/poolkeeper/cmd/run.go +++ b/dev/poolkeeper/cmd/run.go @@ -9,9 +9,9 @@ import ( "os/signal" "syscall" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" + "github.com/gitpod-io/gitpod/common-go/log" "github.com/gitpod-io/gitpod/poolkeeper/pkg/poolkeeper" ) diff --git a/install/installer/cmd/bash.go b/install/installer/cmd/bash.go index 42e25dd688f4a2..04b359423ac914 100644 --- a/install/installer/cmd/bash.go +++ b/install/installer/cmd/bash.go @@ -10,9 +10,10 @@ import ( "os" "syscall" - "github.com/gitpod-io/installer/pkg/sources" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" + + "github.com/gitpod-io/installer/pkg/sources" ) // bashCmd represents the gcp command diff --git a/install/installer/pkg/gcp/gcp.go b/install/installer/pkg/gcp/gcp.go index 993954a6ee38b7..04b0bbcdf66dac 100644 --- a/install/installer/pkg/gcp/gcp.go +++ b/install/installer/pkg/gcp/gcp.go @@ -13,9 +13,10 @@ import ( "path/filepath" "strings" + log "github.com/sirupsen/logrus" + "github.com/gitpod-io/installer/pkg/terraform" "github.com/gitpod-io/installer/pkg/ui" - log "github.com/sirupsen/logrus" ) var availableRegions = []string{