Skip to content

Commit 3030783

Browse files
committed
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]>
1 parent 8e04afc commit 3030783

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
@@ -1964,6 +1964,25 @@
19641964
],
19651965
],
19661966

1967+
/**
1968+
* To use S3 object storage
1969+
*/
1970+
'objectstore' => [
1971+
'class' => 'OC\\Files\\ObjectStore\\S3',
1972+
'arguments' => [
1973+
'bucket' => 'nextcloud',
1974+
'key' => 'your-access-key',
1975+
'secret' => 'your-secret-key',
1976+
'hostname' => 's3.example.com',
1977+
'port' => 443,
1978+
'use_ssl' => true,
1979+
'region' => 'us-east-1',
1980+
// optional: Maximum number of retry attempts for failed S3 requests
1981+
// Default: 5
1982+
'retriesMaxAttempts' => 5,
1983+
],
1984+
],
1985+
19671986
/**
19681987
* If this is set to true and a multibucket object store is configured, then
19691988
* 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
@@ -47,6 +47,7 @@ protected function parseParams($params) {
4747
$this->putSizeLimit = $params['putSizeLimit'] ?? 104857600;
4848
$this->copySizeLimit = $params['copySizeLimit'] ?? 5242880000;
4949
$this->useMultipartCopy = (bool)($params['useMultipartCopy'] ?? true);
50+
$this->retriesMaxAttempts = $params['retriesMaxAttempts'] ?? 5;
5051
$params['region'] = empty($params['region']) ? 'eu-west-1' : $params['region'];
5152
$params['hostname'] = empty($params['hostname']) ? 's3.' . $params['region'] . '.amazonaws.com' : $params['hostname'];
5253
$params['s3-accelerate'] = $params['hostname'] === 's3-accelerate.amazonaws.com' || $params['hostname'] === 's3-accelerate.dualstack.amazonaws.com';
@@ -109,7 +110,7 @@ public function getConnection() {
109110
'use_aws_shared_config_files' => false,
110111
'retries' => [
111112
'mode' => 'standard',
112-
'max_attempts' => 5,
113+
'max_attempts' => $this->retriesMaxAttempts,
113114
],
114115
];
115116

0 commit comments

Comments
 (0)