Skip to content

Commit

Permalink
Allow configuring to emit error logs only
Browse files Browse the repository at this point in the history
The controllers themselves already supported `--log-level=error`, but
there was no way in the chart or via the annotation to use that setting.
Now, a user can specify "error" or "-1" in the annotation to configure
the controller to only emit error logs.

Refs:
 - https://issues.redhat.com/browse/ACM-7778

Signed-off-by: Justin Kulikauskas <[email protected]>
  • Loading branch information
JustinKuli authored and openshift-ci[bot] committed Oct 17, 2023
1 parent e521f70 commit 70d3d20
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion pkg/addon/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,12 @@ func (pa *PolicyAgentAddon) Manifests(
func GetLogLevel(component string, level string) int8 {
logDefault := int8(0)

if level == "error" {
return int8(-1)
}

logLevel, err := strconv.ParseInt(level, 10, 8)
if err != nil || logLevel < 0 {
if err != nil || logLevel < -1 {
log.Error(err, fmt.Sprintf(
"Failed to verify '%s' annotation value '%s' for component %s (falling back to default value %d)",
PolicyLogLevelAnnotation, level, component, logDefault),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ spec:
- '--leader-elect=false'
{{- end }}
- --log-encoder={{ .Values.args.logEncoder }}
- --log-level={{ .Values.args.logLevel }}
- --log-level={{ if eq (toString .Values.args.logLevel) "-1" }}error{{ else }}{{ .Values.args.logLevel }}{{end}}
- --v={{ .Values.args.pkgLogLevel }}
- --evaluation-concurrency={{ .Values.args.evaluationConcurrency }}
- --client-max-qps={{ .Values.args.clientQPS }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ spec:
- '--leader-elect=false'
{{- end }}
- --log-encoder={{ .Values.args.logEncoder }}
- --log-level={{ .Values.args.logLevel }}
- --log-level={{ if eq (toString .Values.args.logLevel) "-1" }}error{{ else }}{{ .Values.args.logLevel }}{{end}}
- --v={{ .Values.args.pkgLogLevel }}
- --evaluation-concurrency={{ .Values.args.evaluationConcurrency }}
- --client-max-qps={{ .Values.args.clientQPS }}
Expand Down

0 comments on commit 70d3d20

Please sign in to comment.