Repository navigation
feat: 🩺 allow customized health check endpoint - #442
dee-me-tree-or-love merged 35 commits into
Conversation
Get the liveness endpoint from the environment variable `HEALTH_ENDPOINT` and verify it. If the customized endpoint is invalied, it will fallback to the DEFAULT_HEALTH_ENDPOINT.
|
Hi @dee-me-tree-or-love, |
|
Hey @Mason-Lin sure! The CI's on for the PR :) Thanks for sending in the idea! I will try to leave a proper review a little later today. 👍 |
Thank you so much! |
|
Hey @Mason-Lin, I like this idea and have checked out the linked issue, thanks for adding all the motivation and related reads, this helps 👍 I do think that this can be a useful addition, so I'd be happy to add it. But I'd like to make sure that we don't create diverging ways for booting up the application code. Right now we indeed don't have any [afaik] customization possibilities of the routing of the app, and in that sense-making, a configurable endpoint for the
Thinking about this, I'd like to still try to find a way to make this configuration a part of the CLI interface in order to keep it consistent with other options. But I'm not 100% sure how to tweak the existing config to make this work on top of my head either :) Right now I can think of looking into the As an extra detail, thanks a lot for adding the tests 😊 |
|
Hi @dee-me-tree-or-love , In the beginning, I tried to copy FALLBACK_URL and add --health-endpoint to DEFAULTS and RunConfig and run_parser Then I replaced I got an error while executing the test Then I checked Because the The above is the blockage I encountered while exploring the CLI interface.😅 I would greatly appreciate it if you kindly give me some suggestions. |
|
Hey @Mason-Lin! Thanks a lot for the detailed description, this helps a lot, indeed I see the trouble 👍 I'm sorry I didn't get back to this yesterday, had some unexpected changes to my plans, but I will try to think along in the coming days and will keep you posted. What you describe is indeed a bit of a blocking issue, so I will try to see how to work around this with minimal changes. Alternatively, I have come across the explicit routing of the bottle library: (see Request Routing -> EXPLICIT ROUTING CONFIGURATION). This seems to allow defining the routes within a function, which could technically solve the import order issue. # Taken from the bottle docs:
# see https://bottlepy.org/docs/dev/routing.html#explicit-routing-configuration
def setup_routing(app):
app.route('/new', ['GET', 'POST'], form_new)
app.route('/edit', ['GET', 'POST'], form_edit)
app = Bottle()
setup_routing(app)The only thing is that I am a bit wary of coupling our code to the bottle's interface even more. And if that is to be the solution, I'd like to pick this up in a separate PR to keep the changes isolated. But feel to give it a try, maybe that makes it work with Furthermore, not to make many changes to the internals of In any case, I'll get back to this soon, thanks a lot for all your work! 👍 |
|
Hi @dee-me-tree-or-love , Thank you for the suggestions. |
|
Hi @dee-me-tree-or-love , Thanks again for the suggestion The practice of My current usage is actually to deploy I will now change the environment variable approach to using the CLI to set the health endpoint. 😊 |
|
notes: |
|
Hey, @Mason-Lin I've fixed the #439 issue with #444. The CI should be back to normal if you update from |
…com:Mason-Lin/pypiserver into mason-lin-ft-customize-healthcheck-endpoint
|
Hey @Mason-Lin, thanks a lot for all the updates on this branch! ✌️ I've had a few things that kept me busy last week, but I'll try to walk through your PR in detail this week :D |
No problem, thank you 😁 |
dee-me-tree-or-love
left a comment
There was a problem hiding this comment.
Hey @Mason-Lin, thanks a lot for your work and adjusting it to the explicit routing setup! 😊 This is already looking nicer, and I think this addition could be an interesting enabler for some extra configurations for the pypiserver in the future. I added a few comments with requests to change below. Those are some alignment details to keep this new behaviour as close as possible to other features of pypiserver, plus to make sure it's modular enough for future extensions or changes. I think it's getting there! Could you take a look at the comments? :)
Special thanks for making all the test cases, these are useful and helpful to see! Then, when you finish this up, don't forget to add a note about this in the Recipes section of the README and update the help command output in the Quickstart section, this will be nice ;) 👍 🚀
Ok no problem, thank you very much for your review. |
pypiserver#442 (comment) Co-authored-by: Dmitrii Orlov <dmtree.dev@yahoo.com>
Co-authored-by: Dmitrii Orlov <dmtree.dev@yahoo.com>
Co-authored-by: Dmitrii Orlov <dmtree.dev@yahoo.com>
Co-authored-by: Dmitrii Orlov <dmtree.dev@yahoo.com>
|
Hi @dee-me-tree-or-love , |
|
Hi @dee-me-tree-or-love , |
dee-me-tree-or-love
left a comment
There was a problem hiding this comment.
Hey @Mason-Lin, this is great work! Thanks a lot for the effort, it was a pleasure to discuss this change 👍 Sorry for my late response, last few weeks I had to manage some challenges on the personal side and was largely AFK. But now getting back to this :) I left a few final nitty comments to polish up the readme and the rest, the code looks good to go IMHO 👍
| "args, exp_txt", | ||
| CONFIG_ERROR_PARAMS, | ||
| ids=CONFIG_TEST_IDS, | ||
| ids=CONFIG_ERROR_IDS, |
There was a problem hiding this comment.
🤩 great catch! Thanks 👍
There was a problem hiding this comment.
Very obscure typo, I happened to see
|
|
||
| def test_health_endpoint_invalid_customized(main): | ||
| with pytest.raises(SystemExit): | ||
| main(["--health-endpoint", "/health!"]) |
There was a problem hiding this comment.
Awesome! Thanks a lot for setting up all these tests!
There was a problem hiding this comment.
I'm a fan of TDD 😄
Co-authored-by: Dmitrii Orlov <dmtree.dev@yahoo.com>
Co-authored-by: Dmitrii Orlov <dmtree.dev@yahoo.com>
Co-authored-by: Dmitrii Orlov <dmtree.dev@yahoo.com>
Co-authored-by: Dmitrii Orlov <dmtree.dev@yahoo.com>
|
Thanks for the correction in reStructuredText. |
3b4ed20 to
628aa81
Compare
no problem, thanks for your time 👍 |
|
Hi @dee-me-tree-or-love , Thank you. |
There was a problem hiding this comment.
Hey @Mason-Lin! Great job, I think this is ready to go, sorry for taking such a long time for this process, but I'll be happy to merge this :) There is one last tiny remark in the code, and regarding the branch update, if you could, that'd indeed be perfect 🙏
Hi @dee-me-tree-or-love ,
Do I need to update the branch or keep what it is?
If it needs to be updated, should I rebase it or merge it?Thank you.
You can do either a rebase or merge, there's no strict process on this since we're squashing PRs into the main branch in the end, it will all appear as a single commit borrowing the PR title :)
Co-authored-by: Dmitrii Orlov <dmtree.dev@yahoo.com>
|
Don't worry, I've also learned some good ideas along the way, thanks for every suggestion you give. Regarding the workflow part, because “First-time contributors need a maintainer to approve running workflows”, I have an idea but I don't know if it is suitable or not, that is to provide a dockerfile, which contains mypy, pylint, black, etc. If I want to confirm whether the PR will be pass the workflow, I can check with docker build. |
dee-me-tree-or-love
left a comment
There was a problem hiding this comment.
Great work! 👍 :) Merging
Hey @Mason-Lin, I like this idea! I totally agree that some improved flow for checking will be nice :) Maybe a tool like |
I think your suggestion is good, and after rethinking it, I guess The reason is that people who use the pypiserver project do not necessarily have experience using docker and makefile because the most basic usage of pypiserver is to use pip install directly. (from QuickStart) When developers find a requirement, they may be able to contribute to it, and the project's contribute guide can guide them to complete the PR smoothly with the lowest learning cost. Yes, maybe a combination of these options will be a nice middle ground. |
Get the liveness endpoint from the environment variableHEALTH_ENDPOINTand verify it. If the customized endpoint is invalied, it will fallback to the DEFAULT_HEALTH_ENDPOINT.UPDATE 2022-10-21
pypiserverprovides a default health endpoint at/health. It always returns200 Okif the service is up. Otherwise, it means that the service is not responsive.In addition,
pypiserverallows users to customize the health endpoint.Alphanumeric characters, hyphens, forward slashes and underscores are allowed and the endpoint should not overlap with any existing routes.
Valid examples:
/healthz,/health/live-1,/api_health,/action/health