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

Status endpoints #53

Merged
merged 3 commits into from
Apr 1, 2020
Merged

Status endpoints #53

merged 3 commits into from
Apr 1, 2020

Conversation

schottra
Copy link
Contributor

This is the first change set for implementing a global notification banner. Note: This is being opened against a feature branch, as this is not the completely implementation of the change.

  • Added ability for the console server to load custom middleware. This makes it possible to implement additional endpoints in private code that will be added to the console server at runtime.
  • Added environment variable for STATUS_URL. This will be used in an upcoming change to ping for system status and conditionally show the notification banner.
  • Updated Dockerfile excludes.

Tracking Issue

flyteorg/flyte#223

@schottra schottra requested review from BobNisco and podehnal March 27, 2020 19:44
module.exports.applyMiddleware = app => middleware.forEach(m => m(app));
} else if (middleware !== undefined) {
console.log(
`Expected middleware to be of type Array, but got ${middleware} instead`

Choose a reason for hiding this comment

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

Won't this case always be hit when there is no env.PLUGINS_MODULE set? is that desired?

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps the conditional should be else to handle all the other cases here. That would cover the case where require(env.PLUGINS_MODULE).middleware resolves to undefined. The code as it is written wouldn't export anything, nor log anything to the console.

Choose a reason for hiding this comment

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

sorry, 🤦‍♂ you are right. I misread the destructuring on that assignment... disregard

Copy link
Contributor Author

@schottra schottra Mar 30, 2020

Choose a reason for hiding this comment

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

Looking at it now, I realize I may have been a little cryptic with this code. The intended behavior is that if you specify env.PLUGINS_MODULE, and it exports an object with property middleware, that property will be an array.
If it is not an array, or it is undefined, we will ignore it altogether. Plugins/middleware are completely optional and shouldn't interrupt the startup with an error.

The else if case was meant to be informational. In the event that you set the environment variable and your module exports a value, you clearly want to add middleware. So we let you know why we can't use your value.

And in the case where require(env.PLUGINS_MODULE).middleware resolves to undefined, we aren't modifying module.exports. This will result in the module exporting an empty object. To me that seems like the desirable behavior. But it's probably not clear what conventions/behaviors are expected here.

Maybe this could use more documentation and more robust logging in all cases?

@schottra schottra merged commit 292efbb into notification-banner Apr 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants