Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chart] Fix default log level #5796

Merged
merged 3 commits into from
Sep 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,13 @@ env:
- name: GITPOD_INSTALLATION_SHORTNAME
value: {{ template "gitpod.installation.shortname" . }}
- name: LOG_LEVEL
value: {{ template "gitpod.loglevel" }}
value: {{ template "gitpod.loglevel" . }}
{{- end -}}

{{- define "gitpod.loglevel" -}}
{{- $ := .root -}}
{{- $gp := .gp -}}
{{ $gp.log.level | default "debug" | lower | quote }}
{{ $gp.log.level | default "info" | lower | quote }}
{{- end -}}

{{- define "gitpod.container.analyticsEnv" -}}
Expand Down
2 changes: 1 addition & 1 deletion chart/templates/agent-smith-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ spec:
{{- if $comp.volumeMounts }}
{{ toYaml $comp.volumeMounts | indent 8 }}
{{- end }}
args: ["run", "-v", "--config", "/config/config.json"]
args: ["run", "--config", "/config/config.json"]
image: {{ template "gitpod.comp.imageFull" $this }}
{{ include "gitpod.container.imagePullPolicy" $this | indent 8 }}
{{ include "gitpod.container.resources" $this | indent 8 }}
Expand Down
2 changes: 1 addition & 1 deletion chart/templates/blobserve-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ spec:
containers:
- name: blobserve
image: {{ template "gitpod.comp.imageFull" $this }}
args: ["run", "-v", "/mnt/config/config.json"]
args: ["run", "/mnt/config/config.json"]
{{ include "gitpod.container.imagePullPolicy" $this | indent 8 }}
{{ include "gitpod.container.resources" $this | indent 8 }}
securityContext:
Expand Down
2 changes: 1 addition & 1 deletion chart/templates/content-service-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ spec:
containers:
- name: content-service
image: {{ template "gitpod.comp.imageFull" $this }}
args: ["run", "-v", "--config", "/config/config.json"]
args: ["run", "--config", "/config/config.json"]
{{ include "gitpod.container.imagePullPolicy" $this | indent 8 }}
{{ include "gitpod.container.resources" $this | indent 8 }}
ports:
Expand Down
1 change: 0 additions & 1 deletion chart/templates/image-builder-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ spec:
image: {{ template "gitpod.comp.imageFull" $this }}
args:
- "run"
- "-v"
- "--config"
- "/config/image-builder.json"
{{ include "gitpod.container.imagePullPolicy" $this | indent 8 }}
Expand Down
1 change: 0 additions & 1 deletion chart/templates/image-builder-mk3-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ spec:
image: {{ template "gitpod.comp.imageFull" $this }}
args:
- "run"
- "-v"
- "--config"
- "/config/image-builder.json"
{{ include "gitpod.container.imagePullPolicy" $this | indent 8 }}
Expand Down
1 change: 0 additions & 1 deletion chart/templates/kedge-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ spec:
image: {{ template "gitpod.comp.imageFull" $this }}
{{ include "gitpod.container.imagePullPolicy" $this | indent 8 }}
args:
- "-v"
- "--config"
- "/config/config.json"
- "run"
Expand Down
2 changes: 1 addition & 1 deletion chart/templates/registry-facade-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ spec:
containers:
- name: registry-facade
image: {{ template "gitpod.comp.imageFull" $this }}
args: ["run", "-v", "/mnt/config/config.json"]
args: ["run", "/mnt/config/config.json"]
{{ include "gitpod.container.imagePullPolicy" $this | indent 8 }}
{{ include "gitpod.container.resources" $this | indent 8 }}
ports:
Expand Down
2 changes: 1 addition & 1 deletion chart/templates/ws-daemon-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ spec:
{{- if $comp.volumeMounts }}
{{ toYaml $comp.volumeMounts | indent 8 }}
{{- end }}
args: ["run", "-v", "--config", "/config/config.json"]
args: ["run", "--config", "/config/config.json"]
image: {{ template "gitpod.comp.imageFull" $this }}
{{ include "gitpod.container.imagePullPolicy" $this | indent 8 }}
{{ include "gitpod.container.resources" $this | indent 8 }}
Expand Down
2 changes: 1 addition & 1 deletion chart/templates/ws-manager-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ spec:
containers:
{{ include "gitpod.kube-rbac-proxy" $this | indent 6 }}
- name: ws-manager
args: ["run", "-v", "--config", "/config/config.json"]
args: ["run", "--config", "/config/config.json"]
image: {{ template "gitpod.comp.imageFull" $this }}
{{ include "gitpod.container.imagePullPolicy" $this | indent 8 }}
{{ include "gitpod.container.resources" $this | indent 8 }}
Expand Down
2 changes: 1 addition & 1 deletion chart/templates/ws-proxy-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ spec:
{{ include "gitpod.kube-rbac-proxy" $this | indent 6 }}
- name: ws-proxy
image: {{ template "gitpod.comp.imageFull" $this }}
args: ["run", "-v", "/config/config.json"]
args: ["run", "/config/config.json"]
{{ include "gitpod.container.imagePullPolicy" $this | indent 8 }}
{{ include "gitpod.container.resources" $this | indent 8 }}
{{ include "gitpod.container.ports" $this | indent 8 }}
Expand Down
2 changes: 1 addition & 1 deletion chart/templates/ws-scheduler-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ spec:
enableServiceLinks: false
containers:
- name: scheduler
args: ["run", "-v", "--config", "/config/config.json"]
args: ["run", "--config", "/config/config.json"]
image: {{ template "gitpod.comp.imageFull" $this }}
{{ include "gitpod.container.imagePullPolicy" $this | indent 8 }}
{{ include "gitpod.container.resources" $this | indent 8 }}
Expand Down
5 changes: 3 additions & 2 deletions components/blobserve/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var rootCmd = &cobra.Command{
Short: "This service provides static assets from OCI images",
Args: cobra.MinimumNArgs(1),
PersistentPreRun: func(cmd *cobra.Command, args []string) {
log.Init(ServiceName, Version, jsonLog, jsonLog)
log.Init(ServiceName, Version, jsonLog, verbose)

// configure containerd log with gitpod-io configuration
containerd_log.WithLogger(context.Background(), log.Log)
Expand All @@ -52,7 +52,8 @@ func Execute() {
}

func init() {
rootCmd.PersistentFlags().BoolVarP(&jsonLog, "json-log", "v", false, "produce JSON log output on verbose level")
rootCmd.PersistentFlags().BoolVarP(&jsonLog, "json-log", "j", true, "produce JSON log output on verbose level")
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Enable verbose JSON logging")
}

// Config configures this servuce
Expand Down
1 change: 1 addition & 0 deletions components/blobserve/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
)

var jsonLog bool
var verbose bool

// runCmd represents the run command
var runCmd = &cobra.Command{
Expand Down
11 changes: 7 additions & 4 deletions components/common-go/log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,17 @@ func init() {

func logLevelFromEnv() {
level := os.Getenv("LOG_LEVEL")
if level == "" {
return
if len(level) == 0 {
level = "info"
}

newLevel, err := logrus.ParseLevel(level)
if err == nil {
Log.Logger.SetLevel(newLevel)
if err != nil {
Log.WithError(err).Errorf("cannot change log level to '%v'", level)
return
}

Log.Logger.SetLevel(newLevel)
}

// Init initializes/configures the application-wide logger
Expand Down
5 changes: 4 additions & 1 deletion components/content-service/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ var (
Version = ""
)

var jsonLog bool
var verbose bool
var configFile string

var rootCmd = &cobra.Command{
Use: "content-service",
Short: "Content service",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
log.Init(ServiceName, Version, verbose, verbose)
log.Init(ServiceName, Version, jsonLog, verbose)
},
}

Expand Down Expand Up @@ -69,6 +71,7 @@ func getConfig() *serviceConfig {
}

func init() {
rootCmd.PersistentFlags().BoolVarP(&jsonLog, "json-log", "j", true, "produce JSON log output on verbose level")
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Enable verbose JSON logging")
rootCmd.PersistentFlags().StringVar(&configFile, "config", "", "config file")
}
Expand Down
6 changes: 4 additions & 2 deletions components/ee/agent-smith/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ var (

var cfgFile string
var jsonLog bool
var verbose bool

// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "agent-smith",
Short: "Moves through workspace pods and finds bad players",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
os.Args = []string{""}
log.Init(ServiceName, Version, jsonLog, jsonLog)
log.Init(ServiceName, Version, jsonLog, verbose)

// Disable golog, Googles logging framwork for misanthropic
err := goflag.Set("stderrthreshold", "5")
Expand All @@ -56,7 +57,8 @@ func Execute() {

func init() {
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file")
rootCmd.PersistentFlags().BoolVarP(&jsonLog, "json-log", "v", false, "produce JSON log output on verbose level")
rootCmd.PersistentFlags().BoolVarP(&jsonLog, "json-log", "j", true, "produce JSON log output on verbose level")
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Enable verbose JSON logging")
}

func getConfig() (*config, error) {
Expand Down
6 changes: 4 additions & 2 deletions components/ee/kedge/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ var (

var cfgFile string
var jsonLog bool
var verbose bool

// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "kedge",
Short: "Remote kubernetes service discovery and replication",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
log.Init(ServiceName, Version, jsonLog, jsonLog)
log.Init(ServiceName, Version, jsonLog, verbose)
},
}

Expand All @@ -47,8 +48,9 @@ func Execute() {

func init() {
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "confg.json", "config file")
rootCmd.PersistentFlags().BoolVarP(&jsonLog, "json-log", "v", false, "produce JSON log output on verbose level")
rootCmd.PersistentFlags().BoolVarP(&jsonLog, "json-log", "j", true, "produce JSON log output on verbose level")
rootCmd.PersistentFlags().String("kubeconfig", "", "kubernetes client config file")
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Enable verbose JSON logging")
}

func getConfig() (*config, error) {
Expand Down
6 changes: 4 additions & 2 deletions components/ee/ws-scheduler/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ var (
var cfgFile string
var kubeconfig string
var jsonLog bool
var verbose bool

// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "ws-scheduler",
Short: "ws-scheduler schedules workspace pods to nodes",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
log.Init(ServiceName, Version, jsonLog, jsonLog)
log.Init(ServiceName, Version, jsonLog, verbose)
},
}

Expand All @@ -57,7 +58,8 @@ func Execute() {

func init() {
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.kedgei.yaml)")
rootCmd.PersistentFlags().BoolVarP(&jsonLog, "json-log", "v", false, "produce JSON log output on verbose level")
rootCmd.PersistentFlags().BoolVarP(&jsonLog, "json-log", "j", true, "produce JSON log output on verbose level")
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Enable verbose JSON logging")

rootCmd.PersistentFlags().StringVar(&kubeconfig, "kubeconfig", "", "path to the kubeconfig file to use (defaults to in-cluster config)")
}
Expand Down
2 changes: 1 addition & 1 deletion components/image-builder-bob/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var rootCmd = &cobra.Command{

// Execute runs the root command
func Execute() {
log.Init("bob", "", false, false)
log.Init("bob", "", true, false)
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
Expand Down
4 changes: 3 additions & 1 deletion components/image-builder-mk3/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ var (
Version = ""
)

var jsonLog bool
var verbose bool
var configFile string
var rootCmd = &cobra.Command{
Use: "image-builder-mk3",
Short: "Workspace image-builder service",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
log.Init(ServiceName, Version, verbose && !isatty.IsTerminal(os.Stdout.Fd()), verbose)
log.Init(ServiceName, Version, jsonLog && !isatty.IsTerminal(os.Stdout.Fd()), verbose)
},
}

Expand Down Expand Up @@ -71,6 +72,7 @@ func getConfig() *config {
}

func init() {
rootCmd.PersistentFlags().BoolVarP(&jsonLog, "json-log", "j", true, "produce JSON log output on verbose level")
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Enable verbose JSON logging")
rootCmd.PersistentFlags().StringVar(&configFile, "config", "", "config file")
}
Expand Down
5 changes: 4 additions & 1 deletion components/image-builder/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ var (
Version = ""
)

var jsonLog bool
var verbose bool
var configFile string

var rootCmd = &cobra.Command{
Use: "image-builder",
Short: "Workspace image-builder service",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
log.Init(ServiceName, Version, verbose && !isatty.IsTerminal(os.Stdout.Fd()), verbose)
log.Init(ServiceName, Version, jsonLog && !isatty.IsTerminal(os.Stdout.Fd()), verbose)
},
}

Expand Down Expand Up @@ -70,6 +72,7 @@ func getConfig() *config {
}

func init() {
rootCmd.PersistentFlags().BoolVarP(&jsonLog, "json-log", "j", true, "produce JSON log output on verbose level")
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Enable verbose JSON logging")
rootCmd.PersistentFlags().StringVar(&configFile, "config", "", "config file")
}
Expand Down
5 changes: 3 additions & 2 deletions components/registry-facade/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var rootCmd = &cobra.Command{
Short: "This service acts as image registry augmenting images with workspace content and Theia",
Args: cobra.MinimumNArgs(1),
PersistentPreRun: func(cmd *cobra.Command, args []string) {
log.Init(ServiceName, Version, jsonLog, jsonLog)
log.Init(ServiceName, Version, jsonLog, verbose)
},
}

Expand All @@ -47,7 +47,8 @@ func Execute() {
}

func init() {
rootCmd.PersistentFlags().BoolVarP(&jsonLog, "json-log", "v", false, "produce JSON log output on verbose level")
rootCmd.PersistentFlags().BoolVarP(&jsonLog, "json-log", "j", true, "produce JSON log output on verbose level")
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Enable verbose JSON logging")
}

// Config configures this servuce
Expand Down
1 change: 1 addition & 0 deletions components/registry-facade/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
)

var jsonLog bool
var verbose bool

// runCmd represents the run command
var runCmd = &cobra.Command{
Expand Down
6 changes: 4 additions & 2 deletions components/service-waiter/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ var (

var cfgFile string
var jsonLog bool
var verbose bool

// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "service-waiter",
Short: "service-waiter waits until a service becomes available",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
log.Init(ServiceName, Version, jsonLog, jsonLog)
log.Init(ServiceName, Version, jsonLog, verbose)
},
}

Expand All @@ -48,7 +49,8 @@ func init() {
cobra.OnInitialize(initConfig)

rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.service-waiter.yaml)")
rootCmd.PersistentFlags().BoolVarP(&jsonLog, "json-log", "v", false, "produce JSON log output on verbose level")
rootCmd.PersistentFlags().BoolVarP(&jsonLog, "json-log", "j", true, "produce JSON log output on verbose level")
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Enable verbose JSON logging")

defaultTimeout := os.Getenv("SERVICE_WAITER_TIMEOUT")
if defaultTimeout == "" {
Expand Down
2 changes: 1 addition & 1 deletion components/supervisor/cmd/ghost.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var ghostCmd = &cobra.Command{
Short: "starts the supervisor",

Run: func(cmd *cobra.Command, args []string) {
log.Init(ServiceName, Version, true, true)
log.Init(ServiceName, Version, true, false)
log.Info("running as ghost - waiting for SIGTERM")

sigChan := make(chan os.Signal, 1)
Expand Down
2 changes: 1 addition & 1 deletion components/supervisor/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var (
// Execute adds all child commands to the root command and sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() {
log.Init(ServiceName, Version, false, true)
log.Init(ServiceName, Version, true, false)
log.Log.Logger.AddHook(fatalTerminationLogHook{})

if err := rootCmd.Execute(); err != nil {
Expand Down
Loading