Skip to content

Commit 3e2582c

Browse files
nfebekesselb
authored andcommitted
feat(objectstore): add configurable S3 retry attempts
Add retriesMaxAttempts parameter to S3 objectstore configuration to allow customization of AWS SDK retry behavior for handling unreliable network conditions or proxy issues. Defaults to 5 retries (AWS SDK default) if not specified. Signed-off-by: nfebe <[email protected]> Signed-off-by: Daniel Kesselberg <[email protected]>
1 parent e84960c commit 3e2582c

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

config/config.sample.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1902,6 +1902,25 @@
19021902
],
19031903
],
19041904

1905+
/**
1906+
* To use S3 object storage
1907+
*/
1908+
'objectstore' => [
1909+
'class' => 'OC\\Files\\ObjectStore\\S3',
1910+
'arguments' => [
1911+
'bucket' => 'nextcloud',
1912+
'key' => 'your-access-key',
1913+
'secret' => 'your-secret-key',
1914+
'hostname' => 's3.example.com',
1915+
'port' => 443,
1916+
'use_ssl' => true,
1917+
'region' => 'us-east-1',
1918+
// optional: Maximum number of retry attempts for failed S3 requests
1919+
// Default: 5
1920+
'retriesMaxAttempts' => 5,
1921+
],
1922+
],
1923+
19051924
/**
19061925
* If this is set to true and a multibucket object store is configured, then
19071926
* newly created previews are put into 256 dedicated buckets.

lib/private/Files/ObjectStore/S3ConfigTrait.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,6 @@ trait S3ConfigTrait {
3838
private int|float $copySizeLimit;
3939

4040
private bool $useMultipartCopy = true;
41+
42+
protected int $retriesMaxAttempts;
4143
}

lib/private/Files/ObjectStore/S3ConnectionTrait.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ protected function parseParams($params) {
5353
$this->putSizeLimit = $params['putSizeLimit'] ?? 104857600;
5454
$this->copySizeLimit = $params['copySizeLimit'] ?? 5242880000;
5555
$this->useMultipartCopy = (bool)($params['useMultipartCopy'] ?? true);
56+
$this->retriesMaxAttempts = $params['retriesMaxAttempts'] ?? 5;
5657
$params['region'] = empty($params['region']) ? 'eu-west-1' : $params['region'];
5758
$params['hostname'] = empty($params['hostname']) ? 's3.' . $params['region'] . '.amazonaws.com' : $params['hostname'];
5859
$params['s3-accelerate'] = $params['hostname'] === 's3-accelerate.amazonaws.com' || $params['hostname'] === 's3-accelerate.dualstack.amazonaws.com';
@@ -115,7 +116,7 @@ public function getConnection() {
115116
'use_aws_shared_config_files' => false,
116117
'retries' => [
117118
'mode' => 'standard',
118-
'max_attempts' => 5,
119+
'max_attempts' => $this->retriesMaxAttempts,
119120
],
120121
];
121122

0 commit comments

Comments
 (0)