aquasecurity / starboard

Moved to https://github.com/aquasecurity/trivy-operator

Home Page:https://aquasecurity.github.io/starboard/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Missing Error Message for wrong value in OPERATOR_VULNERABILITY_SCANNER_REPORT_TTL

shaardie opened this issue · comments

What steps did you take and what happened:

I ran starboard operator with the new TTL feature with OPERATOR_VULNERABILITY_SCANNER_REPORT_TTL="7d". This makes the operator stop immediately without any message and with return code 0. So I had no clue what actually went wrong.
I was only able to fix this by try and error and fixed it with OPERATOR_VULNERABILITY_SCANNER_REPORT_TTL="168h"

I can recreate this simply with docker:

❯ docker run -it -e OPERATOR_VULNERABILITY_SCANNER_REPORT_TTL=7d  aquasec/starboard-operator:0.14.0
❯ echo $?
0
❯ docker run -it -e OPERATOR_VULNERABILITY_SCANNER_REPORT_TTL=1h aquasec/starboard-operator:0.14.0  
{"level":"info","ts":1643112968.92483,"logger":"main","msg":"Starting operator","buildInfo":{"Version":"0.14.0","Commit":"4aa2a11c0c5e6362c1ce04d736ec2fd1997bdaf8","Date":"2022-01-20T11:03:24Z","Executable":""}}
{"level":"error","ts":1643112968.9249914,"logger":"main","msg":"Unable to run starboard operator","error":"resolving install mode: OPERATOR_NAMESPACE must be set"}

What did you expect to happen:

I would expect a proper error message, just like the one above for the missing OPERATOR_NAMESPACE.

Anything else you would like to add:

Environment:

  • Starboard version (use starboard version): 0.14.0 (as seen above)
  • Kubernetes version (use kubectl version): 1.22.

Thank you for reporting this issue @shaardie I think the root cause is that we are trying to use setupLog in case of configuration parser failure:

if err := run(); err != nil {
	setupLog.Error(err, "Unable to run starboard operator")
}

However, the setupLog hasn't been initialised yet, because we initialise it only after the configuration is parsed:

log.SetLogger(zap.New(zap.UseDevMode(operatorConfig.LogDevMode)))

Thanks to fix this so fast 👍