Skip to content

Unable to enable maintenance mode when env.php is read only #24229

Closed
@ihor-sviziev

Description

@ihor-sviziev

Preconditions (*)

  1. Magento 2.3.2 & 2.3-develop
  2. Make env.php file read only: chmod -w app/etc/env.php or chmod 754 app/etc/env.php

Steps to reproduce (*)

  1. Run php bin/magento maintenance:enable -v

Expected result (*)

  1. Maintenance mode should be enabled

Actual result (*)

  1. Maintenance mode is not enabled
  2. Command fails with following output
    image
In PathValidator.php line 63:
                                                                                                          
  [Magento\Framework\Exception\ValidatorException]                                                        
  Path "/var/www/html/magento2/app/etc/" cannot be used with directory "/var/www/html/magento2/app/etc/"  
                                                                                                          

Exception trace:
 () at /var/www/html/magento2/vendor/magento/framework/Filesystem/Directory/PathValidator.php:63
 Magento\Framework\Filesystem\Directory\PathValidator->validate() at /var/www/html/magento2/vendor/magento/framework/Filesystem/Directory/Read.php:82
 Magento\Framework\Filesystem\Directory\Read->validatePath() at /var/www/html/magento2/vendor/magento/framework/Filesystem/Directory/Read.php:111
 Magento\Framework\Filesystem\Directory\Read->getAbsolutePath() at /var/www/html/magento2/vendor/magento/framework/Filesystem/Directory/Write.php:57
 Magento\Framework\Filesystem\Directory\Write->assertWritable() at /var/www/html/magento2/vendor/magento/framework/Filesystem/Directory/Write.php:326
 Magento\Framework\Filesystem\Directory\Write->openFile() at /var/www/html/magento2/vendor/magento/framework/Filesystem/Directory/Write.php:343
 Magento\Framework\Filesystem\Directory\Write->writeFile() at /var/www/html/magento2/vendor/magento/framework/App/DeploymentConfig/Writer.php:146
 Magento\Framework\App\DeploymentConfig\Writer->saveConfig() at /var/www/html/magento2/vendor/magento/framework/App/Cache/State.php:104
 Magento\Framework\App\Cache\State->persist() at /var/www/html/magento2/vendor/magento/framework/App/Cache/Manager.php:77
 Magento\Framework\App\Cache\Manager->setEnabled() at /var/www/html/magento2/vendor/magento/module-page-cache/Observer/SwitchPageCacheOnMaintenance.php:73
 Magento\PageCache\Observer\SwitchPageCacheOnMaintenance->turnOffFullPageCache() at /var/www/html/magento2/vendor/magento/module-page-cache/Observer/SwitchPageCacheOnMaintenance.php:55
 Magento\PageCache\Observer\SwitchPageCacheOnMaintenance->execute() at /var/www/html/magento2/vendor/magento/framework/Event/Invoker/InvokerDefault.php:88
 Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod() at /var/www/html/magento2/vendor/magento/framework/Event/Invoker/InvokerDefault.php:74
 Magento\Framework\Event\Invoker\InvokerDefault->dispatch() at /var/www/html/magento2/vendor/magento/framework/Event/Manager.php:66
 Magento\Framework\Event\Manager->dispatch() at /var/www/html/magento2/vendor/magento/framework/App/MaintenanceMode.php:82
 Magento\Framework\App\MaintenanceMode->set() at /var/www/html/magento2/setup/src/Magento/Setup/Console/Command/AbstractMaintenanceCommand.php:90
 Magento\Setup\Console\Command\AbstractMaintenanceCommand->execute() at /var/www/html/magento2/vendor/symfony/console/Command/Command.php:255
 Symfony\Component\Console\Command\Command->run() at /var/www/html/magento2/vendor/symfony/console/Application.php:893
 Symfony\Component\Console\Application->doRunCommand() at /var/www/html/magento2/vendor/symfony/console/Application.php:262
 Symfony\Component\Console\Application->doRun() at /var/www/html/magento2/vendor/magento/framework/Console/Cli.php:105
 Magento\Framework\Console\Cli->doRun() at /var/www/html/magento2/vendor/symfony/console/Application.php:145
 Symfony\Component\Console\Application->run() at /var/www/html/magento2/bin/magento:23

maintenance:enable [--ip IP] [--magento-init-params MAGENTO-INIT-PARAMS]
  1. Exception message isn't saying anything, message not valid at all.

Additional info

Why it's important to keep env.php file read only - on production servers it's the only one way to make sure that no one will disable cache --> website will work fine.

My investigation shown that this issue appeared in 0e37353.
If i'll remove following observer - it works fine:

<event name="maintenance_mode_changed">
<observer name="page_cache_switcher_for_maintenance" instance="Magento\PageCache\Observer\SwitchPageCacheOnMaintenance"/>
</event>

I reviewed this commit and actually it's ok that FPC should not cache pages in maintenance mode, but disabling FPC at all- the wrong way.

What I would suggest - revert changes that were done in 0e37353 and add checking for maintenance flag in when we're sending public Cache-Control headers

Metadata

Metadata

Assignees

Labels

Component: DeveloperEvent: cd-cologne19Fixed in 2.4.xThe issue has been fixed in 2.4-develop branchIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.3.xThe issue has been reproduced on latest 2.3 release

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions