APIcast icon indicating copy to clipboard operation
APIcast copied to clipboard

1316: support resilient redis mode for cache util

Open abarrak opened this issue 3 years ago • 4 comments

This resolves #1316 and make it useful to use the cache without fail in case of network disconnect, etc.

Tests passing: (results included in commit message) Screen Shot 2022-02-10 at 12 07 17 PM

abarrak avatar Feb 10 '22 09:02 abarrak

Thanks @eloycoto and @unleashed .. Just covered both scenarios and made sure to keep backward compatibility as the default.

Tests run is passing:

$ make busted-util
EXTRA_CFLAGS="-DHAVE_EVP_KDF_CTX=1" /usr/local/openresty/luajit/bin/rover install --roverfile=gateway/Roverfile > /dev/null
/usr/local/openresty/luajit/bin/rover exec bin/busted "spec/threescale_utils_spec.lua" 
●●●
3 successes / 0 failures / 0 errors / 0 pending : 0.022514 seconds

abarrak avatar Feb 10 '22 23:02 abarrak

Guys I thought again about current implementation and think it's better to keep _M.error() signature intact and introduce a new function (e.g. _M.silent_error()) using same signature ... and without nginx exit call.

This way will make the redis connect use either based on the resilient flag and without impacting original function usage. Shared chunk in the function will be reused without duplication.

What do you think @unleashed @eloycoto @kevprice83 ?

Update: New implementation is done and re-based all commits.

bash-4.4$ make busted-util
EXTRA_CFLAGS="-DHAVE_EVP_KDF_CTX=1" /usr/local/openresty/luajit/bin/rover install --roverfile=gateway/Roverfile > /dev/null
/usr/local/openresty/luajit/bin/rover exec bin/busted "spec/threescale_utils_spec.lua" 
●●●
3 successes / 0 failures / 0 errors / 0 pending : 0.02537 seconds

abarrak avatar Feb 11 '22 11:02 abarrak

In general I think this is fine and adds a useful option. We could probably look at extending error_handler in the future to map the same auth caching modes we support in the auth caching policy: allow, none, strict & resilient. That might also be of interest to you @abarrak in case you wanted more granular control over the auth caching decisions when using redis as a shared cache.

kevprice83 avatar Feb 16 '22 16:02 kevprice83

@kevprice83 please review this PR and we decide to merge or close it

eguzki avatar May 12 '22 20:05 eguzki

Hi @eguzki @kevprice83, could you decide on this PR clousre? It was originally approved but got new changes after review.

abarrak avatar Apr 28 '23 17:04 abarrak