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
Cache fixes #209
Cache fixes #209
Conversation
lib/fog/core/cache.rb
Outdated
model_klass.new(load_cache(path)[:attrs]) | ||
else | ||
Fog::Logger.warning("Found corrupt items in the cache: #{path}. Expire all & refresh cache soon.\n\nData:#{File.read(path)}") | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder where this check should be done here or in the load_cache
method instead.
This one is big enough already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds reasonable.
Just as an FYI...we've had to revert to fog-core 1.44.1 gem version. 1.44.2 breaks with the following error:
Credit to @PashaLVWD for finding this for us. He led me to this PR, which may be a fix? |
@BigGillyStyle Thanks for the heads up. I think this contains the fix (but also some other stuff which is still in progress). I'll see if I can't extract the relevant bit so we can cut that into a release. |
@BigGillyStyle I think it should be fixed and released in v1.44.3, sorry for the breakage! |
@geemus No worries...I mostly wanted to just let you know about this. I just tested out 1.44.3 and we're all good. Awesome turnaround! 👍 |
Been running this fork for a while and seems to work w/out an issue.
For example:
FWIW, locally the tests pass:
|
@shaiguitar there were some weird breaks on master, which I think are fixed now. Could you rebase? Hopefully that will get us back to a passing test suite here. Thanks! |
@geemus rebased. looks like travis is failing on https://stackoverflow.com/questions/3163641/get-a-class-by-name-in-ruby for 1.9.3 and 1.8.7 ... Are those deprecated or should I try to patch those? |
So fixed the const_get compat and running into a different 1.8.7 compat issue with |
I think if you rebase off master it should help. I fixed the const_get issue there, as well as other dependency issues (and got master passing for everything). I think those fixes are pretty good/clean (and are apt to conflict with these changes). Does that help/make sense? |
I thought I had rebased earlier but now I'm wondering if I screwed up the rebase - can you take a quick look at the branch's current state? |
I see my changes in the |
Yeah at this point |
@geemus Latest compat error was 1.8.7 does not take |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having all those changes dropped is kind of frustrating, makes me feel like I wasted some effort. Anyway, some small other feedback here. Thanks!
lib/fog/core/cache.rb
Outdated
load_cache(path)[:attrs] | ||
loaded = cache_files.map do |path| | ||
if valid_for_load?(path) | ||
model_klass = const_get_compat(load_cache(path)[:model_klass]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be repeated? Shouldn't it be the same as the passed-in model_klass value that is already set in the method scope?
lib/fog/core/cache.rb
Outdated
end | ||
end.compact | ||
|
||
path = pick_random(cache_files) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't clear on this, why does this use a random file?
spec/core/cache_spec.rb
Outdated
@@ -35,9 +35,63 @@ def initialize(opts = {}) | |||
example_cache = File.expand_path(Fog::Cache.namespace(Fog::SubFogTestModel, @service)).downcase | |||
expected_namespace = File.expand_path("~/.fog-cache/for-service-user-region-foo").downcase | |||
|
|||
puts example_cache |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you remove these puts
? I think I pulled them on master, as I presume they were just accidentally left behind?
spec/core/cache_spec.rb
Outdated
@@ -101,7 +173,7 @@ def initialize(opts = {}) | |||
|
|||
id = SecureRandom.hex | |||
|
|||
# security groups on aws for eg can have the same identity group name 'default'. | |||
# security gruops on aws for eg can have the same identity group name 'default'. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I fixed this typo in my master also, looks like that change also was dropped.
Metadata can be used to implement cahce expiry policies. For example, you have a cache expirey policy per-day. Fog::Cache.metadata = {:last_dumped => "Tuesday"} then next day, you re-run, check and expire the cache based on the data that exists for that specific cache store.
@geemus Understood. Rebase went off due to many commits I hadn't squashed so I opt'ed to skip some and just fill in the differences manually, it was my mistake. I fixed the recent comments - removed random sampling by simply finding the first cache entry that is valid and the puts/comment typo. I also moved model/collection detection out of the loop. Let me know if there's anything left outstanding. |
Thanks for working through that with me, looks good. |
Not important to merge/release at this point, as there might be some more iterations to go through. But logging this here so I don't forget.
There might be some more fixes of these sorts of things over time as usage increases.