-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
python bridge: rewrite packages serving code
Rework the packages loading code. The main changes: - we don't attempt to do checksums anymore. This was taking a large amount of time when loading the bridge and we never implemented it properly anyway (since we weren't sending the `.checksum` fields in the manifests) - instead, we do scan the list of files in the package one time (at first use, not load) and build our map of URL paths to filenames at this point. This allows us to retain our efficient lookup code, but requires us to do the actual file loading at the time of the request. Because we're no longer storing the contents of the files in memory, this is a substantial runtime memory usage reduction. - drop all of the extra code we had for walking the paths in a particular order. We just do (r)globs now. - move all of the code for deciding which packages to load to a separate class. We now load all of the manifests and evaluate them (requirements, conditionals, priorities) and only the packages that we actually intend to serve are then scanned. The new structure also makes it easier for cockpit-beiboot to do its thing. - the packages loading code now uses the actual cockpit version number for requires comparisons instead of the previously hardcoded '300'. Add a somewhat arbitrary number to our `_versions.py` file instead of the current value of `0`. This gets automatically filled in for release versions, but if we want to run things in tree, we need something valid here. - clean up the relationship between `cockpit.packages` and `cockpit.channels.packages`. Previously, `cockpit.packages` would access properties on the channel object and call methods on it to serve the content back. Now the channel requests the data from `cockpit.packages` (which merely returns the result). - enabled by the above: full typing throughout, and mypy is happy. We have one tiny little thorn in that the packages channel is not strictly capable of knowing that the router to which it's connected has a `packages` attribute, but that's nothing that we weren't doing already. Add a comment to draw attention to it. - to the extent possible, we try to keep the state of the packages channel away from the packages code proper. This led to an overhaul of our `Content-Security-Policy` not to include the origin URLs in the policy output. This is redundant anyway, since that's what "'self'" is for. We do need to do one hack for websockets though, until we can convince ourselves about browser support for the standard. This hack is lifted to the channel level. Adjust tests accordingly. - with some small changes to our pyproject.toml, the two rewritten files (`packages.py` and `channels/packages.py`) are now also passing pylint, but we don't enable that yet, since everything else is broken.
- Loading branch information
1 parent
a48f24f
commit e8a81cf
Showing
9 changed files
with
498 additions
and
443 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# This file is only in git. It gets replaced by `make dist`. | ||
__version__ = '0' | ||
__version__ = '295' |
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
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
Oops, something went wrong.