Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

config: not properly loaded error #140

Merged
merged 3 commits into from
Apr 18, 2016
Merged

Conversation

jgsqware
Copy link
Contributor

When a wrong config file was used, it result in a panic.
Adding some check condition to validate the Unmarshaled configuration
before using it

fixes #134

When a wrong config file was used, it result in a panic.
Adding some check condition to validate the Unmarshaled configuration
before using it

fixes quay#134
@@ -111,7 +112,10 @@ func Load(path string) (config *Config, err error) {
return
}
config = &cfgFile.Clair

if config.API == nil || config.Database == nil || config.Notifier == nil || config.Updater == nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't going to work because the default configuration is loaded first and these fields will never be nil. Instead, we might simply add a check in the database code that tries to open the database.

Copy link
Contributor

@Quentin-M Quentin-M Apr 15, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or find a way to verify that there's a clair key somehow.

@jgsqware
Copy link
Contributor Author

it's what I'm thinking of but that mean unmarshaling yaml than merge

I can check for the db connection is the only critical value in the config?

You had a health check previously for the db connection isn't it?

@jgsqware
Copy link
Contributor Author

From the configuration Load method, it could be overhead to check for the database connection.

@jzelinskie jzelinskie added area/usability related to improving user experience reviewed/needs rework will be closed if review not addressed component/config labels Apr 15, 2016
@jgsqware
Copy link
Contributor Author

Could I supposed that only the database source shouldn't be empty?

//ErrConfigNotLoaded is returned when the configuration file is not loaded properly
ErrConfigNotLoaded = errors.New("could not load configuration properly")
// ErrDatasourceNotLoaded is returned when the datasource variable in the configuration file is not loaded properly
ErrDatasourceNotLoaded = errors.New("could not load datasource configuration properly")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We try to declare the errors are locally as possible - it should be in config/config.go as this error is very specific and not meant to be re-used.

Also, I am not sure that everybody will understand that error message. Maybe something like could not load configuration: no database source specified would be more appropriate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK don't know for the locality of errors. I will move it.
Better message indeed. Thanks for the feedback

@Quentin-M
Copy link
Contributor

Quentin-M commented Apr 18, 2016

LGTM.

Thank you so much for your contribution!

@Quentin-M Quentin-M merged commit af2c688 into quay:master Apr 18, 2016
@jgsqware jgsqware deleted the load-config-error branch April 22, 2016 04:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/usability related to improving user experience reviewed/needs rework will be closed if review not addressed
Development

Successfully merging this pull request may close these issues.

Connection refused between docker container of clair and pgsql
3 participants