Problem/Motivation

Trying to run on Azure, I've found that the CONFIG command is not available. Trying to open the status page will throw this (at least running Predis):

Predis\Response\ServerException: ERR unknown command `CONFIG`, with args beginning with: `get`, `maxmemory*`, inPredis\Client->onErrorResponse() (line 370 of /var/www/html/vendor/predis/

Steps to reproduce

It's actually not hard to reproduce when you have a Redis with the config under your control (e.g. with Lando). Add this line to your config file:

rename-command CONFIG ""

Then, with this config applied, visit the status page.

Proposed resolution

Catch the exception and alter the value displayed for memory accordingly.

Remaining tasks

Create patch
Review

User interface changes

The value reported for memory usage may not include a maximum value or policy (as opposed to the screen not working at all, in this situation).

API changes

None.

Data model changes

None.

Issue fork redis-3173988

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

eelkeblok created an issue. See original summary.

eelkeblok’s picture

Issue summary: View changes
eelkeblok’s picture

Assigned: eelkeblok » Unassigned
Status: Active » Needs review
StatusFileSize
new3.35 KB

Here is a first stab at a patch.

eelkeblok’s picture

Title: Take into account CONFIG command may not work » Azure/AWS: Take into account CONFIG command may not work

eelkeblok’s picture

Needed a reroll, created an MR instead.

nitinsp’s picture

Assigned: Unassigned » nitinsp
StatusFileSize
new3.28 KB

#3 patch is not working if you applied it on latest redis module.
So above is reworked patch.

nitinsp’s picture

Assigned: nitinsp » Unassigned
eelkeblok’s picture

Did you try the merge request? I think it is more up to date than patch #3.

kasperg’s picture

Status: Needs review » Reviewed & tested by the community

I have also experienced this problem on Platform.sh sites using Redis 6.0.

#9: The merge request does not apply for me either when testing with the current latest release, 8.1.5.

The patch in #7 does apply, solves the problem in my case and the code looks sound to me. I will mark this as RTBTC.

somersoft’s picture

This patch from #7 has been rerolled so that if you have have the patch from https://www.drupal.org/project/redis/issues/2900947 it applies.

somersoft’s picture

StatusFileSize
new3.17 KB

Extended the patch from #11 so that if maxmemory policy is not returned, there is not PHP warning generated.

somersoft’s picture

Further experiences with AWS indicate that ->info() throws an error for certain AWS ElastiCache configurations and also there is a second ->config() that needs attention too.

eelkeblok’s picture

Status: Reviewed & tested by the community » Needs review
t-lo’s picture

Assigned: Unassigned » t-lo
Status: Needs review » Needs work

Confirmed the second ->config() throws an error on the default AWS elasticache configuration.
I'm working on this.

t-lo’s picture

Status: Needs work » Needs review
StatusFileSize
new4.38 KB

Added try, catch for the error thrown by the second ->config() on the reports page.

Still for if you have have the patch #49 from https://www.drupal.org/project/redis/issues/2900947 applied.

This is working for me now against a default config Elasticache redis cluster.

t-lo’s picture

Assigned: t-lo » Unassigned
technoveltyco’s picture

StatusFileSize
new213.65 KB

@eelkeblok @t-lo the patches provided at #16 and in the issue fork 3173988-azureaws-take-into no longer apply correctly in 1.5.0

patch fails in version 1.5

Both patches need to be re-rolled.

Moreover, I suggest to change the use of CONFIG to INFO redis, which gives the same information and usually does not have the issue of being restricted by the hosting providers. It is also supported in both libraries, phpredis and predis.

https://github.com/phpredis/phpredis#info
https://github.com/ProgerXP/predis-doc/blob/master/Commands.md#infosection

technoveltyco’s picture

Status: Needs review » Needs work
yuraosn’s picture

Status: Needs work » Needs review
StatusFileSize
new3.33 KB

Change patch #16
Aplied for my

chris3proud’s picture

Change patch #20

Small fix to patch #20 that gave this error
Warning: Undefined array key "used_memory_human" in Drupal\redis\Controller\ReportController

ericdsd’s picture

Hi patch #21 works like a charm with AWS

firewaller’s picture

Status: Needs review » Reviewed & tested by the community

#21 works for me

miguelds’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new3.37 KB

Change patch #21

Small fix to patch #21 that gave me this error

Warning: Trying to access array offset on value of type bool in Drupal\redis\Controller\ReportController->overview() (line 176 of modules/contrib/redis/src/Controller/ReportController.php).

berdir’s picture

Status: Needs review » Needs work

watchdog_exception() is deprecated and removed in D11.

renrhaf’s picture

Status: Needs work » Needs review
StatusFileSize
new3.29 KB

Adding a patch compatible with the 1.8 version of the module, deprecating watchdog_exception when possible.

abhou’s picture

Having the same issue with version 1.7.0 on AWS, the patch #21 is working for me as expected.

jonhattan’s picture

StatusFileSize
new2.4 KB

Sorry for making more noise. Here's a simplified approach that rely on INFO command instead of CONFIG.

summit’s picture

patch #26 worked for me on latest version module, thanks! greetings,

pene’s picture

#21 still works like a charm with AWS Redis cache. thanks!

Client PhpRedis
Version 6.2.6
Drupal 9.5.11
Redis 8.x-1.7

mark-mackenzie-nexus’s picture

Please can the patch at comment #28 please be added to a production release. It is necessary to allow the module to work with Azure Cache for Redis. Tested successfully from Azure App Service with Drupal 10.3.

mitokens’s picture

Thanks for the fix. I can confirm the patch at #28 works for me in an Azure hosted environment with Drupal `v10.4.5` using Redis `v1.9.0` and Predis `v1.1.10`. I would be very interested in seeing it merged so I don't have to manually track this issue anymore.

amy_farrell’s picture

Patch at #28 works for me with AWS Elasticache-Redis with Drupal 10.4.5, drupal/redis 1.9.0, and predis 2.4.0.

(I also had to apply a patch from Support TLS for Predis to enable this module to provide the "tls" scheme to predis and apparently I'm following @mitokens around on this.)

berdir’s picture

Status: Needs review » Closed (duplicate)

I believe this has been addressed by #3537948: Abstract info-collection RedisController to deal with special environments, if not, feel free to reopen.

eelkeblok’s picture

I'm a little doubtful, as #3537948: Abstract info-collection RedisController to deal with special environments is still calling config() to retrieve the value. I have been running with #28 on a project for a while now, that eliminates that completely. But maybe the condition in there is enough to prevent that from happening.

berdir’s picture

Yes, but it only calls it if the information isn't already available. stats/info/config output seems to vary wildly between different, it is very much possible that while config() might not work on Azure, info() might contain that somewhere else. There also are patches here wit different approaches. if necessary we can extend the logic with a try/catch, removing it completely does not seem like a viable option.

eelkeblok’s picture

FWIW, I can't reproduce the original problem anymore. 🙃 I had this patch for a site on Platform.sh, maybe they've changed something.

berdir’s picture

I saw that comment and was surprised, we've been using redis on platform.sh since 2015 and never needed this.

eelkeblok’s picture

Weird. I looked through my Git history, but no details. Only confirmation that it was for Platform.sh. I do see that the project is on Redis 6.0 and has been since we added Redis. That's not supported anymore, not sure what the status was when it was added.

pfrenssen’s picture

Status: Closed (duplicate) » Active

Reopening. I updated to Redis 8.0 on Upsun (Platform SH) and I am now getting this error. It seems this is a security recommendation from Redis when running in a hosted environment, to prevent customers from reconfiguring Redis (ref. https://redis.io/docs/latest/operate/oss_and_stack/management/security/#...).

pfrenssen changed the visibility of the branch 3173988-azureaws-take-into to hidden.

pfrenssen’s picture

Status: Active » Needs review

I created a new MR because the previous one is outdated now that #3537948: Abstract info-collection RedisController to deal with special environments is in.

Thanks to the improvements made in that ticket, the fix is now very trivial.

milanbombschliip’s picture

I reviewed the MR 77 and successfully tested it on Upsun.

milanbombschliip’s picture

Status: Needs review » Reviewed & tested by the community
berdir’s picture

I'd appreciate a second MR against 2.x which moved that code, that will make it easier for me to merge this.

pfrenssen’s picture

Opened a MR against 2.x. I did not test this out manually, the porting was quite straightforward.

berdir’s picture

Status: Reviewed & tested by the community » Needs work

Thanks.

Accessing $memory_config lines outside of the try looks a bit strange, but if we actually fall back to an empty string instead of NULL then we don't need the ?? '' fallback in the ReportController, so lets keep and change that, otherwise looks good to me.

pfrenssen’s picture

Status: Needs work » Needs review

Thanks for the suggestion, both MRs are updated.

  • berdir committed 3e7fa1dd on 8.x-1.x authored by pfrenssen
    feat: #3173988 Azure/AWS: Take into account CONFIG command may not work...
berdir’s picture

Status: Needs review » Needs work

Merged the 8.x-1.x MR but noticed that the 2.x MR seems to be missing the change in the Relay client. Maybe that bit could be in a trait or so to avoid the duplication, but off topic for this and might also have some minor differences (and will definitely have that with the cluster clients)

pfrenssen’s picture

Status: Needs work » Needs review

I missed that there is now a third client. Added the fix for this one also, sorry for keeping you busy!

berdir’s picture

Status: Needs review » Fixed

Thanks, merged.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • berdir committed 0edf21b7 on 2.x authored by pfrenssen
    feat: #3173988 Azure/AWS: Take into account CONFIG command may not work...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.