|
1 | 1 | <?php |
2 | 2 |
|
3 | 3 | /** |
4 | | - * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors |
| 4 | + * SPDX-FileCopyrightText: 2017-2026 Nextcloud GmbH and Nextcloud contributors |
5 | 5 | * SPDX-License-Identifier: AGPL-3.0-or-later |
6 | 6 | */ |
7 | 7 | namespace OC\Files\ObjectStore; |
@@ -49,7 +49,7 @@ public function readObject($urn) { |
49 | 49 | // via an abstract method (e.g. getLogger()) rather than inline container lookups |
50 | 50 | $logger = \OCP\Server::get(\Psr\Log\LoggerInterface::class); |
51 | 51 |
|
52 | | - $fh = SeekableHttpStream::open(function ($range) use ($urn, $maxAttempts, &$lastError, $logger) { |
| 52 | + $fh = SeekableHttpStream::open(function ($range) use ($urn, $maxAttempts, &$lastError, &$firstError, $logger) { |
53 | 53 | $command = $this->getConnection()->getCommand('GetObject', [ |
54 | 54 | 'Bucket' => $this->bucket, |
55 | 55 | 'Key' => $urn, |
@@ -134,8 +134,14 @@ public function readObject($urn) { |
134 | 134 | } |
135 | 135 |
|
136 | 136 | // fopen returned false - i.e. connection-level failure (DNS, timeout, TLS, etc.) |
137 | | - // log occurences for operator visibility even if retried |
138 | | - $lastError = "connection failure while reading object $urn range $range on attempt $attempt/$maxAttempts (no HTTP response received)"; |
| 137 | + // log occurrences for operator visibility even if retried |
| 138 | + $currentError = "connection failure while reading object $urn range $range on attempt $attempt/$maxAttempts (no HTTP response received)"; |
| 139 | + if ($firstError === 'unknown error') { |
| 140 | + $firstError = $currentError; |
| 141 | + } else { |
| 142 | + $lastError = $currentError; |
| 143 | + } |
| 144 | + |
139 | 145 | $logger->warning($lastError, ['app' => 'objectstore']); |
140 | 146 |
|
141 | 147 | if ($attempt < $maxAttempts) { |
@@ -235,7 +241,7 @@ private function formatS3ReadError( |
235 | 241 |
|
236 | 242 | if ($statusCode === 416) { |
237 | 243 | return sprintf( |
238 | | - 'HTTP 416 reading object %s range %s on attempt %d/%d: requested range not satisfiable', |
| 244 | + 'HTTP 416 reading object %s range %s on attempt %d/%d: requested range not satisfiable [%s - %s (RequestId: %s, ExtendedRequestId: %s)]', |
239 | 245 | $urn, |
240 | 246 | $range, |
241 | 247 | $attempt, |
|
0 commit comments