Skip to content

Commit eb9a239

Browse files
Merge pull request #146 from magento-commerce/develop
MCLOUD-12266: Cloud Tools Release 2002.1.19
2 parents 568b354 + e4d5076 commit eb9a239

File tree

22 files changed

+206
-87
lines changed

22 files changed

+206
-87
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"consolidation/robo": "^1.2 || ^3.0",
4646
"php-mock/php-mock-phpunit": "^2.0",
4747
"phpmd/phpmd": "@stable",
48-
"phpstan/phpstan": "^0.12",
48+
"phpstan/phpstan": "^1.10",
4949
"phpunit/php-code-coverage": "^7.0 || ^9.2",
5050
"phpunit/phpunit": "^8.5 || ^9.5",
5151
"squizlabs/php_codesniffer": "^3.0",

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/App/Logger/Gelf/TransportFactory.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ class TransportFactory
2222
public const TRANSPORT_UDP = 'udp';
2323
public const TRANSPORT_TCP = 'tcp';
2424

25+
private const DEFAULT_HOST = '127.0.0.1';
26+
private const DEFAULT_PORT_HTTP = 12202;
27+
private const DEFAULT_PORT_TCP = 12201;
28+
private const DEFAULT_PORT_UDP = 12201;
29+
private const DEFAULT_PATH_HTTP = '/gelf';
30+
2531
/**
2632
* @param string $type
2733
* @param array $config
@@ -34,27 +40,27 @@ public function create(string $type, array $config): AbstractTransport
3440
switch ($type) {
3541
case self::TRANSPORT_HTTP:
3642
$transport = new HttpTransport(
37-
$config['host'] ?? null,
38-
$config['port'] ?? null,
39-
$config['path'] ?? null
43+
$config['host'] ?? self::DEFAULT_HOST,
44+
$config['port'] ?? self::DEFAULT_PORT_HTTP,
45+
$config['path'] ?? self::DEFAULT_PATH_HTTP
4046
);
4147
if (isset($config['connection_timeout'])) {
4248
$transport->setConnectTimeout($config['connection_timeout']);
4349
}
4450
break;
4551
case self::TRANSPORT_TCP:
4652
$transport = new TcpTransport(
47-
$config['host'] ?? TcpTransport::DEFAULT_HOST,
48-
$config['port'] ?? TcpTransport::DEFAULT_PORT
53+
$config['host'] ?? self::DEFAULT_HOST,
54+
$config['port'] ?? self::DEFAULT_PORT_TCP
4955
);
5056
if (isset($config['connection_timeout'])) {
5157
$transport->setConnectTimeout($config['connection_timeout']);
5258
}
5359
break;
5460
case self::TRANSPORT_UDP:
5561
$transport = new UdpTransport(
56-
$config['host'] ?? UdpTransport::DEFAULT_HOST,
57-
$config['port'] ?? UdpTransport::DEFAULT_PORT,
62+
$config['host'] ?? self::DEFAULT_HOST,
63+
$config['port'] ?? self::DEFAULT_PORT_UDP,
5864
$config['chunk_size'] ?? UdpTransport::CHUNK_SIZE_WAN
5965
);
6066
break;

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
@@ -50,6 +50,8 @@ public function __construct(
5050

5151
/**
5252
* @return Validator\ResultInterface
53+
*
54+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
5355
*/
5456
public function validate(): Validator\ResultInterface
5557
{
@@ -81,6 +83,22 @@ public function validate(): Validator\ResultInterface
8183
);
8284
}
8385

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

src/Filesystem/DirectoryList.php

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ public function getPath(string $code, bool $relativePath = false): string
8080
throw new \RuntimeException("Code {$code} is not registered");
8181
}
8282

83-
if (!array_key_exists(static::PATH, $directories[$code])) {
83+
if (!array_key_exists(self::PATH, $directories[$code])) {
8484
throw new \RuntimeException(
85-
sprintf('Config var "%s" does not exists', static::PATH)
85+
sprintf('Config var "%s" does not exists', self::PATH)
8686
);
8787
}
8888

@@ -113,7 +113,7 @@ public function getMagentoRoot(): string
113113
*/
114114
public function getInit(): string
115115
{
116-
return $this->getPath(static::DIR_INIT);
116+
return $this->getPath(self::DIR_INIT);
117117
}
118118

119119
/**
@@ -122,7 +122,7 @@ public function getInit(): string
122122
*/
123123
public function getVar(): string
124124
{
125-
return $this->getPath(static::DIR_VAR);
125+
return $this->getPath(self::DIR_VAR);
126126
}
127127

128128
/**
@@ -131,7 +131,7 @@ public function getVar(): string
131131
*/
132132
public function getLog(): string
133133
{
134-
return $this->getPath(static::DIR_LOG);
134+
return $this->getPath(self::DIR_LOG);
135135
}
136136

137137
/**
@@ -140,7 +140,7 @@ public function getLog(): string
140140
*/
141141
public function getGeneratedCode(): string
142142
{
143-
return $this->getPath(static::DIR_GENERATED_CODE);
143+
return $this->getPath(self::DIR_GENERATED_CODE);
144144
}
145145

146146
/**
@@ -149,7 +149,7 @@ public function getGeneratedCode(): string
149149
*/
150150
public function getGeneratedMetadata(): string
151151
{
152-
return $this->getPath(static::DIR_GENERATED_METADATA);
152+
return $this->getPath(self::DIR_GENERATED_METADATA);
153153
}
154154

155155
/**
@@ -161,15 +161,15 @@ public function getGeneratedMetadata(): string
161161
public function getWritableDirectories(): array
162162
{
163163
$writableDirs = [
164-
static::DIR_ETC,
165-
static::DIR_MEDIA,
166-
static::DIR_LOG,
167-
static::DIR_VIEW_PREPROCESSED,
164+
self::DIR_ETC,
165+
self::DIR_MEDIA,
166+
self::DIR_LOG,
167+
self::DIR_VIEW_PREPROCESSED,
168168
];
169169

170170
if ($this->magentoVersion->satisfies('2.1.*')) {
171-
$writableDirs[] = static::DIR_GENERATED_METADATA;
172-
$writableDirs[] = static::DIR_GENERATED_CODE;
171+
$writableDirs[] = self::DIR_GENERATED_METADATA;
172+
$writableDirs[] = self::DIR_GENERATED_CODE;
173173
}
174174

175175
return array_map(function ($path) {
@@ -186,10 +186,10 @@ public function getWritableDirectories(): array
186186
public function getMountPoints(): array
187187
{
188188
$mountPoints = [
189-
static::DIR_ETC,
190-
static::DIR_VAR,
191-
static::DIR_MEDIA,
192-
static::DIR_STATIC
189+
self::DIR_ETC,
190+
self::DIR_VAR,
191+
self::DIR_MEDIA,
192+
self::DIR_STATIC
193193
];
194194

195195
return array_map(function ($path) {
@@ -203,13 +203,13 @@ public function getMountPoints(): array
203203
private function getDefaultDirectories(): array
204204
{
205205
$config = [
206-
static::DIR_INIT => [static::PATH => 'init'],
207-
static::DIR_VAR => [static::PATH => 'var'],
208-
static::DIR_LOG => [static::PATH => 'var/log'],
209-
static::DIR_ETC => [static::PATH => 'app/etc'],
210-
static::DIR_MEDIA => [static::PATH => 'pub/media'],
211-
static::DIR_STATIC => [static::PATH => 'pub/static'],
212-
static::DIR_VIEW_PREPROCESSED => [static::PATH => 'var/view_preprocessed'],
206+
self::DIR_INIT => [self::PATH => 'init'],
207+
self::DIR_VAR => [self::PATH => 'var'],
208+
self::DIR_LOG => [self::PATH => 'var/log'],
209+
self::DIR_ETC => [self::PATH => 'app/etc'],
210+
self::DIR_MEDIA => [self::PATH => 'pub/media'],
211+
self::DIR_STATIC => [self::PATH => 'pub/static'],
212+
self::DIR_VIEW_PREPROCESSED => [self::PATH => 'var/view_preprocessed'],
213213
];
214214

215215
return $config;
@@ -224,11 +224,11 @@ private function getDefaultVariadicDirectories(): array
224224
$config = [];
225225

226226
if ($this->magentoVersion->satisfies('2.1.*')) {
227-
$config[static::DIR_GENERATED_CODE] = [static::PATH => 'var/generation'];
228-
$config[static::DIR_GENERATED_METADATA] = [static::PATH => 'var/di'];
227+
$config[self::DIR_GENERATED_CODE] = [self::PATH => 'var/generation'];
228+
$config[self::DIR_GENERATED_METADATA] = [self::PATH => 'var/di'];
229229
} else {
230-
$config[static::DIR_GENERATED_CODE] = [static::PATH => 'generated/code'];
231-
$config[static::DIR_GENERATED_METADATA] = [static::PATH => 'generated/metadata'];
230+
$config[self::DIR_GENERATED_CODE] = [self::PATH => 'generated/code'];
231+
$config[self::DIR_GENERATED_METADATA] = [self::PATH => 'generated/metadata'];
232232
}
233233

234234
return $config;

src/Service/Validator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Validator
2020
* Supported version constraints of Redis services
2121
*/
2222
private const REDIS_SUPPORT_VERSIONS = [
23-
'*' => '~3.2.0 || ~4.0.0 || ~5.0.0 || ~6.0.0 || ~6.2.0 || ~7.0.0',
23+
'*' => '~3.2.0 || ~4.0.0 || ~5.0.0 || ~6.0.0 || ~6.2.0 || ~7.0.0 || ~7.2.0',
2424
];
2525

2626
/**
@@ -91,7 +91,7 @@ class Validator
9191
'>=2.3.0 <2.3.7-p4 || >=2.4.0 <2.4.3-p3' => '~3.5.0 || ~3.7.0 || ~3.8.0',
9292
'>=2.4.3-p3 <2.4.5-p3 || ~2.3.7-p4' => '~3.5.0 || ~3.7.0 || ~3.8.0 || ~3.9.0',
9393
'>=2.4.5-p3 <2.4.7' => '~3.9.0 || ~3.11.0',
94-
'>=2.4.7' => '~3.11.0',
94+
'>=2.4.7' => '~3.12.0 || ~3.13.0',
9595
],
9696
ServiceInterface::NAME_NODE => [
9797
'*' => '^6 || ^8 || ^10 || ^11',

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

Lines changed: 16 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) {
@@ -112,6 +123,10 @@ public function execute()
112123
);
113124
unset($config['cache']);
114125
} else {
126+
if (isset($cacheConfig['frontend']['default'])) {
127+
$cacheConfig['frontend']['default']['backend_options']['_useLua'] = $luaConfigKey;
128+
$cacheConfig['frontend']['default']['backend_options']['use_lua'] = $luaConfig;
129+
}
115130
$this->logger->info('Updating cache configuration.');
116131
$config['cache'] = $cacheConfig;
117132
}

src/Test/Unit/App/Logger/Gelf/MessageFormatterTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,14 @@ public function testSetAdditional()
4040
'datetime' => new \DateTime(),
4141
'level' => Logger::INFO,
4242
'extra' => [],
43-
'context' => []
43+
'context' => [],
44+
'channel' => 'some_channel'
4445
]);
4546

4647
$this->assertEquals(
4748
[
48-
'some_key' => 'some_value'
49+
'some_key' => 'some_value',
50+
'facility' => 'some_channel'
4951
],
5052
$message->getAllAdditionals()
5153
);

0 commit comments

Comments
 (0)