summaryrefslogtreecommitdiff
path: root/swiftclient
diff options
context:
space:
mode:
authorTim Burke <tim.burke@gmail.com>2022-11-14 13:17:47 -0800
committerTim Burke <tim.burke@gmail.com>2023-03-21 12:46:44 -0700
commit6a8675e897e634abd26d993181ac4a45b9cf16f7 (patch)
treeb7cedbcb8c87559f28ba472c6a0512585266feaa /swiftclient
parent779cf7484e44855ddbf6f29d48af79104e42a0a6 (diff)
downloadpython-swiftclient-6a8675e897e634abd26d993181ac4a45b9cf16f7.tar.gz
Use SLO by default for segmented uploads if the cluster supports it
We've had SLO for nearly ten years, and it is preferable for most use-cases. It's time to default to SLO rather than DLO. Add a new --use-dlo option to give users a way to return to old behavior; ensure there is still a --use-slo option so we don't break existing scripts that may use it. UpgradeImpact: ============== The default segmented-upload behavior has changed; Static Large Objects are now used by default rather than Dynamic Large Objects. To revert to the old behavior: * CLI users may use the new `--use-dlo` option * Service API users may explicitly set `use_slo` to False in their options dicts Change-Id: Iebcd64ced8eab6efebb9f02a0c4be6bf6338cb3b
Diffstat (limited to 'swiftclient')
-rw-r--r--swiftclient/service.py16
-rwxr-xr-xswiftclient/shell.py20
2 files changed, 27 insertions, 9 deletions
diff --git a/swiftclient/service.py b/swiftclient/service.py
index e905ea6..dd71409 100644
--- a/swiftclient/service.py
+++ b/swiftclient/service.py
@@ -196,7 +196,7 @@ _default_global_options = _build_default_global_options()
_default_local_options = {
'sync_to': None,
'sync_key': None,
- 'use_slo': False,
+ 'use_slo': None,
'segment_size': None,
'segment_container': None,
'leave_segments': False,
@@ -1467,7 +1467,7 @@ class SwiftService:
'meta': [],
'header': [],
'segment_size': None,
- 'use_slo': False,
+ 'use_slo': True,
'segment_container': None,
'leave_segments': False,
'changed': None,
@@ -1493,6 +1493,18 @@ class SwiftService:
except ValueError:
raise SwiftError('Segment size should be an integer value')
+ if segment_size and options['use_slo'] is None:
+ try:
+ cap_result = self.capabilities()
+ except ClientException:
+ # pre-info swift, maybe? assume no slo middleware
+ options['use_slo'] = False
+ else:
+ if not cap_result['success']:
+ options['use_slo'] = False
+ else:
+ options['use_slo'] = 'slo' in cap_result['capabilities']
+
# Incase we have a psudeo-folder path for <container> arg, derive
# the container name from the top path and prepend the rest to
# the object name. (same as passing --object-name).
diff --git a/swiftclient/shell.py b/swiftclient/shell.py
index 882a1c0..319141d 100755
--- a/swiftclient/shell.py
+++ b/swiftclient/shell.py
@@ -978,8 +978,8 @@ def st_copy(parser, args, output_manager, return_parser=False):
st_upload_options = '''[--changed] [--skip-identical] [--segment-size <size>]
[--segment-container <container>] [--leave-segments]
[--object-threads <thread>] [--segment-threads <threads>]
- [--meta <name:value>] [--header <header>]
- [--use-slo] [--ignore-checksum] [--skip-container-put]
+ [--meta <name:value>] [--header <header>] [--use-slo]
+ [--use-dlo] [--ignore-checksum] [--skip-container-put]
[--object-name <object-name>]
<container> <file_or_directory> [<file_or_directory>] [...]
'''
@@ -1024,8 +1024,11 @@ Optional arguments:
repeated. Example: -H "content-type:text/plain"
-H "Content-Length: 4000".
--use-slo When used in conjunction with --segment-size it will
- create a Static Large Object instead of the default
- Dynamic Large Object.
+ create a Static Large Object. Deprecated; this is now
+ the default behavior when the cluster supports it.
+ --use-dlo When used in conjunction with --segment-size it will
+ create a Dynamic Large Object. May be useful with old
+ swift clusters.
--ignore-checksum Turn off checksum validation for uploads.
--skip-container-put Assume all necessary containers already exist; don't
automatically try to create them.
@@ -1087,10 +1090,13 @@ def st_upload(parser, args, output_manager, return_parser=False):
' This option may be repeated. Example: -H "content-type:text/plain" '
'-H "Content-Length: 4000"')
parser.add_argument(
- '--use-slo', action='store_true', default=False,
+ '--use-slo', action='store_true', default=None,
help='When used in conjunction with --segment-size, it will '
- 'create a Static Large Object instead of the default '
- 'Dynamic Large Object.')
+ 'create a Static Large Object.')
+ parser.add_argument(
+ '--use-dlo', action='store_false', dest="use_slo", default=None,
+ help='When used in conjunction with --segment-size, it will '
+ 'create a Dynamic Large Object.')
parser.add_argument(
'--object-name', dest='object_name',
help='Upload file and name object to <object-name> or upload dir and '