Fixes #1082 修复在更新token无操作有效期时的时间判断问题 #1104
Merged
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.
变更点(Changes)
相关issues (Which issues this PR fixes)
备注(Special notes)
BkToken表中inactive_expire_time字段,在更新时,是基于当前时间+ 无操作失效期,即inactive_expire_time = now_time + BK_INACTIVE_COOKIE_AGE。
在原代码中,更新inactive_expire_time前的判断(该判断是为了避免频繁更新inactive_expire_time带来的性能问题):
if now_time > inactive_expire_time + settings.BK_INACTIVE_UPDATE_INTERVEL:
存在问题,相当于是:if now_time > (now_time1 + BK_INACTIVE_COOKIE_AGE) + settings.BK_INACTIVE_UPDATE_INTERVEL:
判断结果基本不可能为true,不会进入到更新inactive_expire_time代码。
因此,需要修复为:
if now_time + BK_INACTIVE_COOKIE_AGE > inactive_expire_time + settings.BK_INACTIVE_UPDATE_INTERVEL