-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Demo webserver for managed instances tutorial #2077
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
Conversation
The linter fails on a few lines over the line limit that are part of a multi-line HTML template string: '''IN-LINE Let me know if this is, in fact, an ugly way to define an index.html page for a python HTTP server, and I'll find a way to refactor. |
I've updated the server to use Flask. |
if r.status_code == 200: | ||
return sub(r'.+zones/(.+)', r'\1', r.text) | ||
else: | ||
return '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there any failure cases here that we should be throwing errors on instead of returning the empty string? This seems like unexpected behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsuccessfully getting the zone is not a critical failure. The zone (and the template) are fetched simply for informational purposes on the UI. The demo still works perfectly fine if both fetches fail. If I were to put something in the failure case, it would be an error message along the lines of 'zone not found'/'template not found'.
|
||
PORT_NUMBER = 80 | ||
HTML_TEMPLATES_PATH = path.dirname(path.realpath(__file__)) + '/templates' | ||
HEALTHY = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this sample ever have multiple instances behind a load balancer, or is it intended to run on one machine at a time only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future, I intend to run this sample with a load balancer.
The global 'healthy' is meant to simply hold state for each individual server. It is expected that a user might be redirected to different servers by the load balancer. Please let me know if there is a more idiomatic way of hosting a simple boolean state variable on a flask server (all I can find are examples using databases which seems too overcomplicated for this task).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Please take a look at adding comments but otherwise LGTM
Looks like there's a linting error with the new comments... sorry it's so nitpicky. If that's resolved I can merge right away. Thanks for your work on this.
|
Comments fixed, all checks passed! |
Thanks, I'll merge now. |
A simple demo web server used in a new interactive tutorial: Highly Available Deployments with Autohealing