-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
Better error handling, use better practices. #140
Conversation
i haven't looked at all your changes but this behavior is intentional. it should be possible to run the application with no database configured, and still get the welcome page w/ no page view count displayed. once a DB is added, the pageview count should appear when the page is reloaded. |
That seems kind of... odd? You'd have to restart the app in order for the env vars to be populated, so why let the app even start up with no indication of why the database isn't working? Even if you wanted the app to be able to start up in an erroneous state, I would think you'd still want to let the dev know what is wrong. |
the page does report that no db connection is configured under those conditions. logging something would be nice, sure. |
And the reason it's designed this way is this sample app is intended to be deployed both with, and without, a database. For many users trying to get a hello world app running on openshift, they aren't even going to have the DB, so it's important that it "just work" even if you haven't configured a DB. The DB is an optional feature, not a requirement (which is always why no errors are reported if the DB is not available). |
Looks to me like @MikeyBurkman has made a very solid contribution. Seems like we should at the very least log that the db was not found, not just put an error on a page served by the app. If we want to show people best practices on using mongodb, this PR does just that. |
sure, I am just trying to provide some context for why the app behaves as it does.
Not really the intent of the repo, but sure, i'm not against improving it, again I just want the context and goals understood. We have a significant test infrastructure that in part dependent on the behavior of this repo, so changing it needs to be considered carefully. |
Alright, will change it to make mongo optional for the homepage to display, and will log warnings to the console and fill in the dynamic fields in the homepage appropriately. (I'll see if I can go one further, and if mongo env vars ARE provided, I won't display the page until it's been initialized.) What about the |
Yeah i think returning a 500 on that should be ok. |
@MikeyBurkman: PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Closing this issue. The database were switched from MOngoDB -> Postgresql. Feel free to update it against postgresql. |
This node app is currently doing a lot of weird/bad practices for being an example app, which you almost certainly would never want in any real app:
dependencies
rather thandevDependencies
inpackage.json
object-assign
polyfill was still being used. (Though it wasn't actually being used in the code?)var
was being used all over the place, though it's usage has been largely replaced byconst
andscope
in ES6 codeI did NOT fix the tests yet, and they currently fail, so DO NOT MERGE until they have been resolved. Had the tests done anything more substantial than just expect a 200 response from the server, they would have previously failed anyways, as the database would just silently never initialize. (The code branches where
db != null
were never being reached.)I didn't fix the tests because I'm not certain which way things should go:
proxyquire
? (This will look a bit convoluted, as Mongo is not pleasant to correctly mock.)