Repository navigation
Provide token storage using the salt.cache interface - #68039
Conversation
|
Looks like the rest of the failures are failing on master. Once those are fixed, we can rebase. |
| elif len(record) == 3: | ||
| (created_at, expires, data) = record | ||
|
|
||
| if (created_at + (expires or self.expire)) >= now: |
There was a problem hiding this comment.
If len(record) is 1, 2 or > 3 then created_at will not be defined and the same problem with data below on line 385.
There was a problem hiding this comment.
mmm practically speaking i dont think that's possible to happen, but ill update to be more defensive
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.
|
Is there a possibility that this update, gets tokens expired too early? I upgraded from 3007, since then tokens seems to be valid for around <10 seconds. The log shows: I am running stock configuration 3008.0 with only rest_cherrypy enabled. The the token expiry timestamp when the token was created looks fine (10-12h). |
it's possible.. but many things have changed in 3008. are you able to provide debug level logs, and/or a simple repro case? |
|
Thank you for the fast response, I have narrowed down the problem.
Could it be this line:
Or is it just that the general localfs cache gets dropped? With maintenance_interval: 9999 and loop_interval: 60 the tokens still get expired, so the problem seems to be tied to the loop_interval. |
|
By the way, the expires inside the {{token}}.p file looks fine:
|
|
@haijerc can you create a new issue tagged on 3008 and feel free to link this PR ? I don't think anyone is seeing your comments but me |
|
also delete that token on your infra if its valid :) |
|
if you don't mind sticking a log.debug below line 340 in salt/auth/init.py on your master and sharing it here (or in new issue) , it should show whats happening / why it's not being handled as expected |
|
@mattp I have tracked down the issue, yay! I will open a pull request with a code fix and see if it gets merged. I will mention this aswell. |
|
My suggested fix is at LoadAuth::clean_expired_tokens Instead of Use for cleaning the tokens, this respects the expiry value inside the cachefile. Or would you prefer implementing localfs.clean_expired? This is eventually the better fix, but leads to duplicate expiry data locations or more changes to get it nicely done. |
What does this PR do?
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.
NOTE: this PR depends on #68030 being merged; once done I can rebase. 1e505cb is the only relevant commit for this PR.
What issues does this PR fix or reference?
Fixes
Previous Behavior
Remove this section if not relevant
New Behavior
Remove this section if not relevant
Merge requirements satisfied?
[NOTICE] Bug fixes or features added to Salt require tests.
Commits signed with GPG?
Yes