-
Notifications
You must be signed in to change notification settings - Fork 62
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
Improve code style #86
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signed-off-by: Marek Pikuła <marek.pikula@embevity.com>
- black - isort - ruff - pre-comit - mypy - pydocstyle Signed-off-by: Marek Pikuła <marek.pikula@embevity.com>
Signed-off-by: Marek Pikuła <marek.pikula@embevity.com>
Signed-off-by: Marek Pikuła <marek.pikula@embevity.com>
Signed-off-by: Marek Pikuła <marek.pikula@embevity.com>
Signed-off-by: Marek Pikuła <marek.pikula@embevity.com>
Signed-off-by: Marek Pikuła <marek.pikula@embevity.com>
Signed-off-by: Marek Pikuła <marek.pikula@embevity.com>
Major part of iFargle#73 Unfortunately, it wasn't possible to split it to multiple smaller commits, since the changes touched the entire application substantially. Here is a short list of major changes: 1. Create a separate library (headscale-api), which is used as a convenient abstraction layer providing Pythonic interface with Pydantic. Headscale API is fully asynchronous library, benefitting from improved concurrency for backend requests thus increasing page load speed, e.g., on "Machines" page. 2. Create a common common, validated with flask-pydantic API passthrough layer from GUI to the backend. 3. Move authentication to a separate (auth.py), consolidating the functionality in a single place (with better place for expansion in the future). 4. Move configuration management to a separate module (config.py). Use Pydantic's BaseSettings for reading values from environment, with extensive validation and error reporting. 5. Reduce the number of health checks. - Now, most are performed during server initialization. If any test fails, the server is started in tainted mode, with only the error page exposed (thus reducing the surface of attack in invalid state). - Key checks are implicit in the requests to the backend and guarded by `@headscale.key_check_guard` decorator. - Key renewal is moved to server-side scheduler. 6. Introduce type hints to the level satisfactory for mypy static analysis. Also, enable some other linters in CI and add optional pre-commit hooks. 7. Properly handle some error states. Instead of returning success and handling different responses, if something fails, there is HTTP error code and standard response for it. 8. General formatting, small rewrites for clarity and more idiomatic Python constructs. Signed-off-by: Marek Pikuła <marek.pikula@embevity.com>
Signed-off-by: Marek Pikuła <marek.pikula@embevity.com>
Signed-off-by: Marek Pikuła <marek.pikula@embevity.com>
I'll work on this as soon as I can! 2-3 days at most. Thank you for your help on this -- This is great! |
Signed-off-by: Marek Pikuła <marek.pikula@embevity.com>
MarekPikula
force-pushed
the
improve_code_style
branch
from
April 21, 2023 06:23
3fbc5b9
to
fa86bbf
Compare
To be revisited in future. Signed-off-by: Marek Pikuła <marek.pikula@embevity.com>
iFargle
approved these changes
Apr 21, 2023
My (very) basic tests seem to all work fine! #80 still exists but that's expected. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Unfortunately, it wasn't possible to split it into multiple smaller commits since the changes touched the entire application substantially. Here is a short list of significant changes:
From my perspective, some more work still needs to be done, but at this point, most of the significant changes are complete, and I would like to (finally) push this forward to have it merged sooner than later so that other people can base on this (or the evolution of it). I think that some issues might be solved with this rewrite (#84 #74), but testing from the user's side is required for this. I did my best to go through all the parts of the application manually, but for sure, there is an option I missed something (or didn't retest after some polishing). The most important thing is for you @iFargle, to review the code and check if everything works as before (or better). From my side, I will check if the documentation needs any updates and retest everything again (tomorrow).
One issue I already found is some intermittent error with aiohttp used for async requests when running by gunicorn in a multi-worker set-up. I would say that for now, it's a low priority as, either way, the project from the start didn't support it. In the long run, it would be really nice to have support for multiple workers, especially if this frontend would be used by bigger users (e.g., companies) with more machines/users/admins to serve.
Work on #73