Skip to content

Commit

Permalink
[CORE-824] Disallow configuring logs in text format
Browse files Browse the repository at this point in the history
  • Loading branch information
FahadBSyed committed Aug 23, 2022
1 parent 6b423ae commit db292f4
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 13 deletions.
4 changes: 4 additions & 0 deletions etc/helm/pachyderm/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ pachctl config set active-context local
pachctl port-forward
{{- end -}}

{{- if eq .Values.pachd.logFormat "text" }}
WARNING: setting log format to text is not supported. Defaulting to json
{{- end -}}

{{ if and (.Values.oidc.mockIDP) (.Values.pachd.enterpriseLicenseKey) (.Values.pachd.activateAuth) }}
WARNING: Your cluster is configured with a default login of admin:password
{{- end -}}
Expand Down
8 changes: 1 addition & 7 deletions src/internal/middleware/logging/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ type Option func(*config)

func WithLogFormat(fmt string) func(*config) {
return func(cfg *config) {
if fmt != "text" {
cfg.format = "json"
}
cfg.format = fmt
cfg.format = "json"
}
}

Expand Down Expand Up @@ -67,9 +64,6 @@ func NewLoggingInterceptor(logger *logrus.Logger, opts ...Option) *LoggingInterc
opt(cfg)
}
logger.Formatter = log.FormatterFunc(log.JSONPretty)
if cfg.format == "text" {
logger.Formatter = log.FormatterFunc(log.Pretty)
}

interceptor := &LoggingInterceptor{
logger,
Expand Down
3 changes: 0 additions & 3 deletions src/server/cmd/pachd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,6 @@ func setup(config interface{}, service string) (env *serviceenv.NonblockingServi
log.Printf("no Jaeger collector found (JAEGER_COLLECTOR_SERVICE_HOST not set)")
}
env = serviceenv.InitWithKube(serviceenv.NewConfiguration(config))
if env.Config().LogFormat == "text" {
log.SetFormatter(logutil.FormatterFunc(logutil.Pretty))
}
profileutil.StartCloudProfiler(service, env.Config())
debug.SetGCPercent(env.Config().GCPercent)
if env.Config().EtcdPrefix == "" {
Expand Down
3 changes: 0 additions & 3 deletions src/server/cmd/worker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ func do(ctx context.Context, config interface{}) error {
env := serviceenv.InitWithKube(serviceenv.NewConfiguration(config))

log.SetFormatter(logutil.FormatterFunc(logutil.JSONPretty))
if env.Config().LogFormat == "text" {
log.SetFormatter(logutil.FormatterFunc(logutil.Pretty))
}

// Enable cloud profilers if the configuration allows.
profileutil.StartCloudProfiler("pachyderm-worker", env.Config())
Expand Down

0 comments on commit db292f4

Please sign in to comment.