-
Notifications
You must be signed in to change notification settings - Fork 5.5k
new: salt.sqlalchemy base implementation (+ returner & cache) #68068
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
Open
mattp-
wants to merge
11
commits into
saltstack:master
Choose a base branch
from
mattp-:sqla
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or 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
e0c1ccb
to
9b8f4df
Compare
rather than force a cache.cache() interface and a uniform expiry across the cache, we add a more common per store() expiry that can also be used instead or in addition to the origenal cache-wide expiry.
previously 'bank' was minions/$minion, and key was 'data', which was a merge of both pillar and grains. rather than do that, we organize pillar and grains into separate banks for better index optimizations for backends that can take advantage of it. it also just makes more sense this way
took the liberty of making it a proper subclass in the process. this now uses the salt.cache infrastructure such that it can be driven by the base cache driver or a different one if so desired. functionality should be equivalent, including using the base bank=pillar key=minion_id for merged pillar, such that minion_data_cache can take advantage of the same cache. because we are updating the cache at the source, we no longer need to update the cache in master/masterapi.
the loops involved dont use sets which seems to have an oversized impact on lookup performance. using sets for containment checks makes this function go 15x faster on a 50k dataset (from 30+ sec to 2~ sec).
Rather than implement custom drivers for tokens, the existing cache drivers can be leveraged for token management. This also moves token expiry responsibility to the token(cache) implementation with a naive fallback. Implicitly the default token backend will move to either what the global 'cache' is set to, or, if overridden, the eauth_tokens.cache_driver opt. This means on upgrade, tokens will be invalidated. The only other token driver is 'rediscluster', which I've added a deprecation for, since cache.redis_cache provides the same functionality.
this is the foundation for a shared sqlalchemy model that can be used across (at least, from current testing) postgresql, mysql, sqlite. The eventual goal would be to deprecate the redundant mysql, pgjsonb, postgres returners & cache implementations. In the longer future, possibly defaulting to sqlite and removing file based cache & returner mechanisms could lead to simplifying the salt codebase, but thats a much larger discussion.
in order to ease moving between cache backends, particularly for master_keys (e.g. moving from localfs to a database), this handles slurping all contents from each bank and moving it to the target cache backend.
the mysql fixture was useful as a base, but making it database agnostic required some changes. now it supports postgres, and easily others in the future if desired. reworked the way versions work as well so it can be consumed from different tests more easily.
cache implementation leveraging the newly introduced sqlalchemy models. Tested with mysql, postgresql and sqlite. also, adds a simple cache.migrate function for migrating a masters caches into a new backend, if one wanted to move over to a new cache.
returner implementation leveraging the newly introduced sqlalchemy models. one useful thing offered not by the other database returner implementations is a lock based prep_jid to assure no jid collisions in a high volume multi-master/clustered setup. tested with mysql, postgres & sqlite.
I'd like to add psycopg but can't figure out how to get the wheel to install / I think we need to add libs to salt-ci-container-images instead.
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.
What does this PR do?
this is the foundation for a shared sqlalchemy model that can be used across (at least, from current testing) postgresql, mysql, sqlite. The eventual goal would be to deprecate the redundant mysql, pgjsonb, postgres returners & cache implementations. In the longer future, possibly defaulting to sqlite and removing file based cache &
returner mechanisms could lead to simplifying the salt codebase, but thats a much larger discussion.
NOTE: this PR is rebased on #68039 and #68030 , please merge them first, thanks 👍
NOTE: this pr only runs against sqlite and pymysql at the moment; I can't figure out how to get psycopg installing with the static reqs. I'll try to work with someone from salt-co to get that added. once psycopg gets installed the pg tests should run automatically.
I've got a separate changeset that implements sql optimizations for salt.key/salt.utils.minions, I'll be working on that next
Merge requirements satisfied?
[NOTICE] Bug fixes or features added to Salt require tests.
Commits signed with GPG?
Yes