Skip to content

Commit c603d7c

Browse files
committed
Add lua deploy variables
1 parent 579df76 commit c603d7c

File tree

4 files changed

+64
-2
lines changed

4 files changed

+64
-2
lines changed

config/schema.yaml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,28 @@ variables:
466466
backend: file
467467
page_cache:
468468
backend: file
469-
469+
USE_LUA:
470+
description: "Enable/Disable LUA in environments starting from Magento 2.4.7"
471+
type: boolean
472+
stages:
473+
- deploy
474+
default:
475+
deploy: false
476+
examples:
477+
- stage:
478+
deploy:
479+
USE_LUA: true
480+
LUA_KEY:
481+
description: "LUA KEY for environments starting from Magento 2.4.7"
482+
type: boolean
483+
stages:
484+
- deploy
485+
default:
486+
deploy: true
487+
examples:
488+
- stage:
489+
deploy:
490+
LUA_KEY: false
470491
SESSION_CONFIGURATION:
471492
description: "Replace or modify the Magento session configuration generated during the deployment process.
472493
By default, ece-tools configures Magento to store Redis session data. To replace the existing configuration,

src/Config/Stage/DeployInterface.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,14 @@ interface DeployInterface extends StageConfigInterface
8686
* The variable responsible for enabling google analytics in environments other than prod.
8787
*/
8888
public const VAR_ENABLE_GOOGLE_ANALYTICS = 'ENABLE_GOOGLE_ANALYTICS';
89+
90+
/**
91+
* The variable responsible for enabling LUA cache in environments starting from Magento 2.4.7.
92+
*/
93+
public const VAR_USE_LUA = 'USE_LUA';
94+
95+
/**
96+
* The variable responsible for LUA KEY in environments starting from Magento 2.4.7.
97+
*/
98+
public const VAR_LUA_KEY = 'LUA_KEY';
8999
}

src/Config/Validator/Deploy/AppropriateVersion.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,24 @@ public function validate(): Validator\ResultInterface
8181
);
8282
}
8383

84+
if (!$this->magentoVersion->satisfies('>= 2.4.7')
85+
&& $this->configurationChecker->isConfigured(DeployInterface::VAR_USE_LUA, true)
86+
) {
87+
$errors[] = sprintf(
88+
'%s is available for Magento 2.4.7 and above',
89+
DeployInterface::VAR_USE_LUA
90+
);
91+
}
92+
93+
if (!$this->magentoVersion->satisfies('>= 2.4.7')
94+
&& $this->configurationChecker->isConfigured(DeployInterface::VAR_LUA_KEY, true)
95+
) {
96+
$errors[] = sprintf(
97+
'%s is available for Magento 2.4.7 and above',
98+
DeployInterface::VAR_LUA_KEY
99+
);
100+
}
101+
84102
if ($errors) {
85103
return $this->resultFactory->error(
86104
'The current configuration is not compatible with this version of Magento',

src/Step/Deploy/PreDeploy/ConfigUpdate/Cache.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Magento\MagentoCloud\Step\StepInterface;
1717
use Psr\Log\LoggerInterface;
1818
use Magento\MagentoCloud\Package\MagentoVersion;
19+
use Magento\MagentoCloud\Config\Stage\DeployInterface;
1920

2021
/**
2122
* Processes cache configuration.
@@ -49,25 +50,33 @@ class Cache implements StepInterface
4950
*/
5051
private $magentoVersion;
5152

53+
/**
54+
* @var DeployInterface
55+
*/
56+
private $stageConfig;
57+
5258
/**
5359
* @param ConfigReader $configReader
5460
* @param ConfigWriter $configWriter
5561
* @param LoggerInterface $logger
5662
* @param CacheFactory $cacheConfig
5763
* @param MagentoVersion $magentoVersion
64+
* @param DeployInterface $stageConfig
5865
*/
5966
public function __construct(
6067
ConfigReader $configReader,
6168
ConfigWriter $configWriter,
6269
LoggerInterface $logger,
6370
CacheFactory $cacheConfig,
64-
MagentoVersion $magentoVersion
71+
MagentoVersion $magentoVersion,
72+
DeployInterface $stageConfig
6573
) {
6674
$this->configReader = $configReader;
6775
$this->configWriter = $configWriter;
6876
$this->logger = $logger;
6977
$this->cacheConfig = $cacheConfig;
7078
$this->magentoVersion = $magentoVersion;
79+
$this->stageConfig = $stageConfig;
7180
}
7281

7382
/**
@@ -79,6 +88,8 @@ public function execute()
7988
$config = $this->configReader->read();
8089
$cacheConfig = $this->cacheConfig->get();
8190
$graphqlConfig = $config['cache']['graphql'] ?? [];
91+
$luaConfig = (boolean)$this->stageConfig->get(DeployInterface::VAR_USE_LUA);
92+
$luaConfigKey = (boolean)$this->stageConfig->get(DeployInterface::VAR_LUA_KEY);
8293

8394
if (isset($cacheConfig['frontend'])) {
8495
$cacheConfig['frontend'] = array_filter($cacheConfig['frontend'], function ($cacheFrontend) {
@@ -120,6 +131,8 @@ public function execute()
120131
$config['cache']['graphql'] = $graphqlConfig;
121132
}
122133

134+
$config['cache']['frontend']['default']['backend_options']['_useLua'] = $luaConfigKey;
135+
$config['cache']['frontend']['default']['backend_options']['use_lua'] = $luaConfig;
123136
$this->configWriter->create($config);
124137
} catch (FileSystemException $e) {
125138
throw new StepException($e->getMessage(), Error::DEPLOY_ENV_PHP_IS_NOT_WRITABLE);

0 commit comments

Comments
 (0)