Skip to content
New issue

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

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

Already on GitHub? # to your account

argocd-dex not using logformat/loglevel from cli #19884

Closed
hermanbanken opened this issue Sep 11, 2024 · 1 comment
Closed

argocd-dex not using logformat/loglevel from cli #19884

hermanbanken opened this issue Sep 11, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@hermanbanken
Copy link

What is the problem

ArgoCD (argocd-dex) starts dex with a YAML configuration from argocd_dex.go#L100. Before starting dex, it parses cli arguments logformat and loglevel :

command.Flags().StringVar(&cmdutil.LogFormat, "logformat", env.StringFromEnv("ARGOCD_DEX_SERVER_LOGFORMAT", "text"), "Set the logging format. One of: text|json")
command.Flags().StringVar(&cmdutil.LogLevel, "loglevel", env.StringFromEnv("ARGOCD_DEX_SERVER_LOGLEVEL", "info"), "Set the logging level. One of: debug|info|warn|error")

into cmd/util
var (
LogFormat string
LogLevel string
)

However, the dex YAML configuration parses environment variables defined in common anew (ARGOCD_LOG_LEVEL, ARGOCD_LOG_FORMAT):

dexCfg["logger"] = map[string]interface{}{
"level": slogLevelFromLogrus(os.Getenv(common.EnvLogLevel)),
"format": os.Getenv(common.EnvLogFormat),
}

These sets of arguments/variables are misaligned.

What we observe

Our deployment YAML contains:

      - args:
        - rundex
        command:
        - /shared/argocd-dex
        - --logformat=json
        - --loglevel=info

We expected this would log everything as json, and at info level. However, the logs contain the following:

{"level":"info","msg":"dex config unmodified","time":"2024-09-10T09:22:42Z"}                                                                                                                        
{"level":"info","msg":"Notifying 1 settings subscribers: [0xc00123cea0]","time":"2024-09-10T09:22:47Z"}                                                                                                                                                                                                           
time="2024-09-10T12:30:15Z" level=info msg="keys expired, rotating"                                                                                                                                 
time="2024-09-10T12:30:15Z" level=info msg="keys rotated, next rotation: 2024-09-10 18:30:15.78678407 +0000 UTC"                                                                                    
time="2024-09-10T18:30:17Z" level=info msg="keys expired, rotating"                                                                                                                                 
time="2024-09-11T06:30:19Z" level=info msg="keys rotated, next rotation: 2024-09-11 12:30:19.81644692 +0000 UTC"                                                                                    
{"level":"info","msg":"Notifying 1 settings subscribers: [0xc00123cea0]","time":"2024-09-11T08:00:23Z"}                                                                                             
{"level":"info","msg":"dex config unmodified","time":"2024-09-11T08:00:23Z"}                                                                                                                        
{"level":"info","msg":"Notifying 1 settings subscribers: [0xc00123cea0]","time":"2024-09-11T08:00:27Z"}                                                                                             
{"level":"info","msg":"dex config unmodified","time":"2024-09-11T08:00:27Z"}                                                                                                                        
time="2024-09-11T08:00:43Z" level=info msg="login successful: connector \"github\", username=\"Herman\", preferred_username=\"hermanbanken\", email=\"redacted\", groups=[\"redacted
time="2024-09-11T08:00:47Z" level=info msg="login successful: connector \"github\", username=\"Herman\", preferred_username=\"hermanbanken\", email=\"redacted\", groups=[\"redacted
{"level":"info","msg":"Notifying 1 settings subscribers: [0xc00123cea0]","time":"2024-09-11T08:12:15Z"}                                                                                             

This contains non-json logs on the stderr stream, resulting in non-errors reported as errors.

@hermanbanken hermanbanken added the bug Something isn't working label Sep 11, 2024
@hermanbanken
Copy link
Author

Sorry! Duplicate of #13191. We hadn't updated yet.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant