-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
fix: provide error instead of nil panic when cache_zone is missing #10138
Merged
Conversation
This file contains 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
Signed-off-by: Ashish Tiwari <ashishjaitiwari15112000@gmail.com>
Signed-off-by: Ashish Tiwari <ashishjaitiwari15112000@gmail.com>
kayx23
previously approved these changes
Sep 5, 2023
shreemaan-abhishek
requested changes
Sep 6, 2023
enhance test description Co-authored-by: Abhishek Choudhary <shreemaan.abhishek@gmail.com>
shreemaan-abhishek
previously approved these changes
Sep 6, 2023
kayx23
previously approved these changes
Sep 6, 2023
Sn0rt
approved these changes
Sep 7, 2023
apisix/plugins/proxy-cache/init.lua
Outdated
@@ -140,6 +141,12 @@ function _M.check_schema(conf) | |||
end | |||
end | |||
|
|||
-- For memory based cache, the default cache_zone cannot be used. | |||
-- cache_zone will also be set as default value in case when passed empty. | |||
if conf.cache_strategy == STRATEGY_MEMORY and conf.cache_zone == DEFAULT_CACHE_ZONE then |
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.
It's not very reliable to judge by cache zone name, i think you could modified like this:
if local_conf.apisix.proxy_cache then
for _, cache in ipairs(local_conf.apisix.proxy_cache.zones) do
if cache.name == conf.cache_zone then
if conf.cache_strategy == STRATEGY_MEMORY and not cache.disk_path then
found = true
break
elseif conf.cache_strategy == STRATEGY_DISK and cache.disk_path then
found = true
break
end
end
end
if found == false then
return false, "cache_zone " .. conf.cache_zone .. " not found"
end
end
Signed-off-by: Ashish Tiwari <ashishjaitiwari15112000@gmail.com>
Signed-off-by: Ashish Tiwari <ashishjaitiwari15112000@gmail.com>
c76dfe5
@monkeyDluffy6017 I added a slightly modified version of your suggestion with comments. Please review. |
monkeyDluffy6017
approved these changes
Sep 13, 2023
leslie-tsang
approved these changes
Sep 13, 2023
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.
Description
Fixes #9957
Checklist