trento-project / agent

Trento Agent is a little process running in your OS, collecting metadata about SAP hosts.
Other
4 stars 10 forks source link

Print fact gathering error in facts gather cmd call #304

Closed arbulu89 closed 10 months ago

arbulu89 commented 10 months ago

While playing a bit with some gatherers, I have noticed that we don't print properly the error message if we have a fact gathering error.

So we move from:

INFO[2023-11-28 14:25:43] Starting password verifying facts gathering process 
ERRO[2023-11-28 14:25:43] fact gathering error: verify-password-password-not-set - password authentication not set for user: redis 
INFO[2023-11-28 14:25:43] Requested password verifying facts gathered  
INFO[2023-11-28 14:25:43] Gathered fact for "verify_password" with argument "redis": 
INFO[2023-11-28 14:25:43] Name: redis
Check ID: 

Value:

()  

To

INFO[2023-11-28 14:37:27] loading plugins                              
INFO[2023-11-28 14:37:27] Starting password verifying facts gathering process 
ERRO[2023-11-28 14:37:27] fact gathering error: verify-password-invalid-username - requested user is not whitelisted for password check: redis 
INFO[2023-11-28 14:37:27] Requested password verifying facts gathered  
ERRO[2023-11-28 14:37:27] Error gathering fact "verify_password" with argument "redis": 
ERRO[2023-11-28 14:37:27] fact gathering error: verify-password-invalid-username - requested user is not whitelisted for password check: redis

PD: In this case it logs twice because we have an explicit log.Error in the gatherer code, but this doesn't happen always

arbulu89 commented 10 months ago

LGTM @arbulu89, just a side question: in which cases should we do an explicit Log.error() in the gatherer code (and when not)?

My suggestion is to do it always when there is a fact gathering error. This way, we can see it in the logs. But this would be a general guideline, and it must be decided for each individual case