Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes cache hosts warning / critical levels and continue on multiple hosts #18852

Merged
merged 9 commits into from
Feb 15, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions app/code/Magento/CacheInvalidate/Model/PurgeCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ private function splitTags($tagsPattern)
private function sendPurgeRequestToServers($socketAdapter, $servers, $formattedTagsChunk)
{
$headers = [self::HEADER_X_MAGENTO_TAGS_PATTERN => $formattedTagsChunk];
$unresponsiveServerError = [];
foreach ($servers as $server) {
$headers['Host'] = $server->getHost();
try {
Expand All @@ -131,10 +132,27 @@ private function sendPurgeRequestToServers($socketAdapter, $servers, $formattedT
$socketAdapter->read();
$socketAdapter->close();
} catch (\Exception $e) {
$this->logger->critical($e->getMessage(), compact('server', 'formattedTagsChunk'));
return false;
$unresponsiveServerError[] = "Cache host: " . $server->getHost() . ":" . $server->getPort() .
"resulted in error message: " . $e->getMessage();
continue;
wiardvanrij marked this conversation as resolved.
Show resolved Hide resolved
}
}

$errorCount = count($unresponsiveServerError);

if ($errorCount > 0) {

$loggerMessage = implode(" ", $unresponsiveServerError);

if ($errorCount == count($servers)) {
$this->logger->critical('No cache server(s) could be purged ' . $loggerMessage, compact('server',
Copy link
Member

@sivaschenko sivaschenko Nov 14, 2018

Choose a reason for hiding this comment

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

Each parameter should be in line by itself in multiline function call, example:

$this->logger->critical(
    'No cache server(s) could be purged ' . $loggerMessage,
    compact('server', 'formattedTagsChunk')
);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry I think I misunderstood you :) It is changed now

'formattedTagsChunk'));
} else {
$this->logger->warning('Unresponsive cache server(s) hit' . $loggerMessage, compact('server',
'formattedTagsChunk'));
}
}

$this->logger->execute(compact('servers', 'formattedTagsChunk'));
return true;
}
Expand Down
15 changes: 14 additions & 1 deletion lib/internal/Magento/Framework/Cache/InvalidateLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,17 @@ public function critical($message, $params)
{
$this->logger->critical($message, $this->makeParams($params));
}
}

/**
* Log warning
*
* @param string $message
* @param mixed $params
* @return void
*/
public function warning($message, $params)
{
$this->logger->warning($message, $this->makeParams($params));
}

wiardvanrij marked this conversation as resolved.
Show resolved Hide resolved
}