Skip to content

Added connection_parameters to redis and redis.cluster config section in order to allow redis with TLS/SSL#38386

Merged
AlexAndBear merged 1 commit intomasterfrom
enterprise/issues/4368
Feb 11, 2021
Merged

Added connection_parameters to redis and redis.cluster config section in order to allow redis with TLS/SSL#38386
AlexAndBear merged 1 commit intomasterfrom
enterprise/issues/4368

Conversation

@AlexAndBear
Copy link
Copy Markdown

@AlexAndBear AlexAndBear commented Feb 9, 2021

Description

Since php-redis 5.3.0 it is possible to pass extra connection parameters as the last argument of Redis::Connect or RedisCluster::constructor.
This arguments can now be defined in the config.php redis.cluser:connection_parameters or redis:connection_parameters.
Due we don't rely on php-redis >= 5.3.0 we check if the extra connection parameters are supported and throw an exception if defined but not supported by the current version.

Related Issue

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Database schema changes (next release will require increase of minor version instead of patch)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:
  • Changelog item, see TEMPLATE

@update-docs
Copy link
Copy Markdown

update-docs bot commented Feb 9, 2021

Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes.

@mmattel
Copy link
Copy Markdown
Contributor

mmattel commented Feb 9, 2021

pls do not forget to add a doc issue in case there is a config.sample change 😄

@AlexAndBear AlexAndBear self-assigned this Feb 9, 2021
@AlexAndBear AlexAndBear force-pushed the enterprise/issues/4368 branch from 7093a24 to a9dd9b6 Compare February 9, 2021 17:18
@owncloud owncloud deleted a comment from sonarqubecloud bot Feb 9, 2021
@AlexAndBear AlexAndBear force-pushed the enterprise/issues/4368 branch from a9dd9b6 to 81f3e74 Compare February 10, 2021 11:12
@AlexAndBear AlexAndBear changed the title [WIP] added extraParams support to redis factory Added connection_parameters to redis and redis.cluster config section in order to allow redis with TLS/SSL Feb 10, 2021
@AlexAndBear AlexAndBear marked this pull request as ready for review February 10, 2021 11:14
@AlexAndBear
Copy link
Copy Markdown
Author

pls do not forget to add a doc issue in case there is a config.sample change

@mmattel done 👍

@AlexAndBear
Copy link
Copy Markdown
Author

@jvillafanez So, I think the error suppression is nonsense, after changing lib/base.php as well, we get now a better error like connection refused instead of redis server went away. Can you have a closer look?

@AlexAndBear AlexAndBear force-pushed the enterprise/issues/4368 branch from dd9a869 to 3a8dd4a Compare February 10, 2021 13:59
Copy link
Copy Markdown
Member

@jvillafanez jvillafanez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a little touch

@jvillafanez
Copy link
Copy Markdown
Member

@janackermann could you post what you've tested for the change in the lib/base.php to ensure we're not missing anything? The code is executed quite early and I'm not sure if there is any scenario where it could break really bad.
I expect the exception to end up in the owncloud.log file.

Assuming it doesn't give any trouble, the code looks good to me.

@AlexAndBear
Copy link
Copy Markdown
Author

@jvillafanez
Without change:

  1. Enter faulty redis Data
  2. Open owncloud in Browser
  3. Generic Error Page appears
  4. Redis exception: Redis Server went away in Logos

With Change:

  1. Enter faulty redis Data
  2. Open owncloud in Browser
  3. Generic Error Page appears
  4. Redis exceptions: Connection refused in Logs

@AlexAndBear
Copy link
Copy Markdown
Author

@jvillafanez If this is a blocker, i will revert the Changes here, as this is not Part of the ticket

@jvillafanez
Copy link
Copy Markdown
Member

We should also check what happens with the command line, ocs and webdav.

@AlexAndBear
Copy link
Copy Markdown
Author

Encountered webdav erros which won't happen on master, revert these changes, leave it for now, not context of the issue. Please review again @jvillafanez

@AlexAndBear AlexAndBear force-pushed the enterprise/issues/4368 branch from f44aa9f to 1bcd469 Compare February 10, 2021 18:42
@AlexAndBear AlexAndBear force-pushed the enterprise/issues/4368 branch from 05be01b to 45e4882 Compare February 11, 2021 09:46
@owncloud owncloud deleted a comment from sonarqubecloud bot Feb 11, 2021
@sonarqubecloud
Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@AlexAndBear AlexAndBear merged commit a236f87 into master Feb 11, 2021
@delete-merged-branch delete-merged-branch bot deleted the enterprise/issues/4368 branch February 11, 2021 11:07
@jnweiger
Copy link
Copy Markdown
Contributor

jnweiger commented Mar 18, 2021

Confirmed decent error handling in 10.7.0 RC1

  • with faulty redis port number, the logs have
"message":"Exception: {\"Exception\":\"RedisException\",\"Message\":\"Connection refused\",\"Code\":0,\"Trace\":\"#0 \\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/RedisFactory.php(117): Redis->connect()\\n#1 \\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/RedisFactory.php(139): OC\\\\RedisFactory->create()\\n#2 \\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/Memcache\\\/Redis.php(37): OC\\\\RedisFactory->getInstance()\\n#3 \\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/Memcache\\\/Factory.php(131): OC\\\\Memcache\\\\Redis->__construct()\\n#4 \\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/Server.php(731): OC\\\\Memcache\\\\Factory->createLocking()\\n#5 \\\/var\\\/www\\\/owncloud\\\/lib\\\/composer\\\/pimple\\\/pimple\\\/src\\\/Pimple\\\/Container.php(118): OC\\\\Server->OC\\\\{closure}(*** sensitive parameters replaced ***)\\n#6 \\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/AppFramework\\\/Utility\\\/SimpleContainer.php(108): Pimple\\\\Container->offsetGet()\\n#7 \\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/ServerContainer.php(86): OC\\\\AppFramework\\\\Utility\\\\SimpleContainer->query()\\n#8 \\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/Server.php(1511): OC\\\\ServerContainer->query()\\n#9 \\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/Files\\\/View.php(124): OC\\\\Server->getLockingProvider()\\n#10 \\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/Server.php(179): OC\\\\Files\\\\View->__construct()\\n#11 \\\/var\\\/www\\\/owncloud\\\/lib\\\/composer\\\/pimple\\\/pimple\\\/src\\\/Pimple\\\/Container.php(118): OC\\\\Server->OC\\\\{closure}(*** sensitive parameters replaced ***)\\n#12 \\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/AppFramework\\\/Utility\\\/SimpleContainer.php(108): Pimple\\\\Container->offsetGet()\\n#13 \\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/ServerContainer.php(86): OC\\\\AppFramework\\\\Utility\\\\SimpleContainer->query()\\n#14 \\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/Server.php(942): OC\\\\ServerContainer->query()\\n#15 \\\/var\\\/www\\\/owncloud\\\/lib\\\/base.php(754): OC\\\\Server->getEncryptionManager()\\n#16 \\\/var\\\/www\\\/owncloud\\\/lib\\\/base.php(668): OC::registerEncryptionWrapper()\\n#17 \\\/var\\\/www\\\/owncloud\\\/lib\\\/base.php(1058): OC::init()\\n#18 \\\/var\\\/www\\\/owncloud\\\/index.php(53): require_once('\\\/var\\\/www\\\/ownclo...')\\n#19 {main}\",\"File\":\"\\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/RedisFactory.php\",\"Line\":117}"}

  • Or with added connection_parameters with stock ubuntu 20.04 php-redis 5.1.1+4.3.0-1:
"message":"Exception: {\"Exception\":\"UnexpectedValueException\",\"Message\":\"php-redis extension must be version 5.3.0 or higher to support connection parameters\",\"Code\":0,\"Trace\":\"#0 \\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/RedisFactory.php(139): OC\\\\RedisFactory->create()\\n#1 \\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/Memcache\\\/Redis.php(37): OC\\\\RedisFactory->getInstance()\\n#2 \\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/Memcache\\\/Factory.php(131): OC\\\\Memcache\\\\Redis->__construct()\\n#3 \\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/Server.php(731): OC\\\\Memcache\\\\Factory->createLocking()\\n#4 \\\/var\\\/www\\\/owncloud\\\/lib\\\/composer\\\/pimple\\\/pimple\\\/src\\\/Pimple\\\/Container.php(118): OC\\\\Server->OC\\\\{closure}(*** sensitive parameters replaced ***)\\n#5 \\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/AppFramework\\\/Utility\\\/SimpleContainer.php(108): Pimple\\\\Container->offsetGet()\\n#6 \\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/ServerContainer.php(86): OC\\\\AppFramework\\\\Utility\\\\SimpleContainer->query()\\n#7 \\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/Server.php(1511): OC\\\\ServerContainer->query()\\n#8 \\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/Files\\\/View.php(124): OC\\\\Server->getLockingProvider()\\n#9 \\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/Server.php(179): OC\\\\Files\\\\View->__construct()\\n#10 \\\/var\\\/www\\\/owncloud\\\/lib\\\/composer\\\/pimple\\\/pimple\\\/src\\\/Pimple\\\/Container.php(118): OC\\\\Server->OC\\\\{closure}(*** sensitive parameters replaced ***)\\n#11 \\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/AppFramework\\\/Utility\\\/SimpleContainer.php(108): Pimple\\\\Container->offsetGet()\\n#12 \\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/ServerContainer.php(86): OC\\\\AppFramework\\\\Utility\\\\SimpleContainer->query()\\n#13 \\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/Server.php(942): OC\\\\ServerContainer->query()\\n#14 \\\/var\\\/www\\\/owncloud\\\/lib\\\/base.php(754): OC\\\\Server->getEncryptionManager()\\n#15 \\\/var\\\/www\\\/owncloud\\\/lib\\\/base.php(668): OC::registerEncryptionWrapper()\\n#16 \\\/var\\\/www\\\/owncloud\\\/lib\\\/base.php(1058): OC::init()\\n#17 \\\/var\\\/www\\\/owncloud\\\/index.php(53): require_once('\\\/var\\\/www\\\/ownclo...')\\n#18 {main}\",\"File\":\"\\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/RedisFactory.php\",\"Line\":104}"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants