fix: provide error instead of nil panic when cache_zone is missing#10138
Merged
Conversation
Signed-off-by: Ashish Tiwari <[email protected]>
Signed-off-by: Ashish Tiwari <[email protected]>
Signed-off-by: Ashish Tiwari <[email protected]>
Signed-off-by: Ashish Tiwari <[email protected]>
Signed-off-by: Ashish Tiwari <[email protected]>
kayx23
previously approved these changes
Sep 5, 2023
shreemaan-abhishek
requested changes
Sep 6, 2023
enhance test description Co-authored-by: Abhishek Choudhary <[email protected]>
shreemaan-abhishek
previously approved these changes
Sep 6, 2023
kayx23
previously approved these changes
Sep 6, 2023
Sn0rt
approved these changes
Sep 7, 2023
|
|
||
| -- 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 |
Contributor
There was a problem hiding this comment.
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 <[email protected]>
Signed-off-by: Ashish Tiwari <[email protected]>
Revolyssup
dismissed stale reviews from kayx23 and shreemaan-abhishek
via
September 13, 2023 04:39
c76dfe5
Contributor
Author
|
@monkeyDluffy6017 I added a slightly modified version of your suggestion with comments. Please review. |
juststillthinking
approved these changes
Sep 13, 2023
leslie-tsang
approved these changes
Sep 13, 2023
This file contains hidden or 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
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