Skip to content
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

[2017.7] backport - Do not allow age to be a negative number #50252

Merged
merged 1 commit into from Oct 30, 2018

Conversation

Projects
None yet
3 participants
@dwoz
Copy link
Contributor

commented Oct 26, 2018

What does this PR do?

Backport file cache bug fix found while fixing 2018.3 tests

Tests written?

No

Commits signed with GPG?

Yes

@dwoz dwoz requested a review from rallytime Oct 26, 2018

age = time.time() - cache_stat.st_mtime
# st_time can have a greater precision than time, removing
# float precision makes sure age will never be a negative
# number.

This comment has been minimized.

Copy link
@cachedout

cachedout Oct 29, 2018

Collaborator

Could we just do an absolute value here instead?

This comment has been minimized.

Copy link
@dwoz

dwoz Oct 29, 2018

Author Contributor

Originally when we saw age was able to be a negative number I thought it was due to st_mtime having greater floating point precision (which could make age negative). Later we found that there are also cases where the system time changes enough to make age negative. I think that means with the file_mtime > current_time check we don't need to cast things to int in the first place and the comment can be updated.

Otherwise, I'd prefer not to use abs since that could result in more cache updates (rather than less). The code would be simpler but less explicit. That is just my $0.02, using abs would work as you say.

@rallytime rallytime merged commit e535b38 into saltstack:2017.7 Oct 30, 2018

8 of 9 checks passed

jenkins/pr/py2-windows-2016 The py2-windows-2016 job has failed
Details
continuous-integration/jenkins/pr-merge This commit looks good
Details
jenkins/pr/docs The docs job has passed
Details
jenkins/pr/lint The lint job has passed
Details
jenkins/pr/py2-centos-7 The py2-centos-7 job has passed
Details
jenkins/pr/py2-ubuntu-1604 The py2-ubuntu-1604 job has passed
Details
jenkins/pr/py3-centos-7 The py3-centos-7 job has passed
Details
jenkins/pr/py3-ubuntu-1604 The py3-ubuntu-1604 job has passed
Details
jenkins/pr/py3-windows-2016 The py3-windows-2016 job has passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.