swift 2.32.0__py2.py3-none-any.whl → 2.34.0__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. swift/account/auditor.py +11 -0
  2. swift/account/reaper.py +11 -1
  3. swift/account/replicator.py +22 -0
  4. swift/account/server.py +13 -12
  5. swift-2.32.0.data/scripts/swift-account-audit → swift/cli/account_audit.py +6 -2
  6. swift-2.32.0.data/scripts/swift-config → swift/cli/config.py +1 -1
  7. swift-2.32.0.data/scripts/swift-dispersion-populate → swift/cli/dispersion_populate.py +6 -2
  8. swift-2.32.0.data/scripts/swift-drive-audit → swift/cli/drive_audit.py +12 -3
  9. swift-2.32.0.data/scripts/swift-get-nodes → swift/cli/get_nodes.py +6 -2
  10. swift/cli/info.py +131 -3
  11. swift-2.32.0.data/scripts/swift-oldies → swift/cli/oldies.py +6 -3
  12. swift-2.32.0.data/scripts/swift-orphans → swift/cli/orphans.py +7 -2
  13. swift-2.32.0.data/scripts/swift-recon-cron → swift/cli/recon_cron.py +9 -18
  14. swift-2.32.0.data/scripts/swift-reconciler-enqueue → swift/cli/reconciler_enqueue.py +2 -3
  15. swift/cli/relinker.py +1 -1
  16. swift/cli/reload.py +141 -0
  17. swift/cli/ringbuilder.py +24 -0
  18. swift/common/daemon.py +12 -2
  19. swift/common/db.py +14 -9
  20. swift/common/db_auditor.py +2 -2
  21. swift/common/db_replicator.py +6 -0
  22. swift/common/exceptions.py +12 -0
  23. swift/common/http_protocol.py +76 -3
  24. swift/common/manager.py +120 -5
  25. swift/common/memcached.py +24 -25
  26. swift/common/middleware/account_quotas.py +144 -43
  27. swift/common/middleware/backend_ratelimit.py +166 -24
  28. swift/common/middleware/catch_errors.py +1 -3
  29. swift/common/middleware/cname_lookup.py +3 -5
  30. swift/common/middleware/container_sync.py +6 -10
  31. swift/common/middleware/crypto/crypto_utils.py +4 -5
  32. swift/common/middleware/crypto/decrypter.py +4 -5
  33. swift/common/middleware/crypto/kms_keymaster.py +2 -1
  34. swift/common/middleware/proxy_logging.py +57 -43
  35. swift/common/middleware/ratelimit.py +6 -7
  36. swift/common/middleware/recon.py +6 -7
  37. swift/common/middleware/s3api/acl_handlers.py +10 -1
  38. swift/common/middleware/s3api/controllers/__init__.py +3 -0
  39. swift/common/middleware/s3api/controllers/acl.py +3 -2
  40. swift/common/middleware/s3api/controllers/logging.py +2 -2
  41. swift/common/middleware/s3api/controllers/multi_upload.py +31 -15
  42. swift/common/middleware/s3api/controllers/obj.py +20 -1
  43. swift/common/middleware/s3api/controllers/object_lock.py +44 -0
  44. swift/common/middleware/s3api/s3api.py +6 -0
  45. swift/common/middleware/s3api/s3request.py +190 -74
  46. swift/common/middleware/s3api/s3response.py +48 -8
  47. swift/common/middleware/s3api/s3token.py +2 -2
  48. swift/common/middleware/s3api/utils.py +2 -1
  49. swift/common/middleware/slo.py +508 -310
  50. swift/common/middleware/staticweb.py +45 -14
  51. swift/common/middleware/tempauth.py +6 -4
  52. swift/common/middleware/tempurl.py +134 -93
  53. swift/common/middleware/x_profile/exceptions.py +1 -4
  54. swift/common/middleware/x_profile/html_viewer.py +9 -10
  55. swift/common/middleware/x_profile/profile_model.py +1 -2
  56. swift/common/middleware/xprofile.py +1 -2
  57. swift/common/request_helpers.py +101 -8
  58. swift/common/statsd_client.py +207 -0
  59. swift/common/storage_policy.py +1 -1
  60. swift/common/swob.py +5 -2
  61. swift/common/utils/__init__.py +331 -1774
  62. swift/common/utils/base.py +138 -0
  63. swift/common/utils/config.py +443 -0
  64. swift/common/utils/logs.py +999 -0
  65. swift/common/utils/timestamp.py +23 -2
  66. swift/common/wsgi.py +19 -3
  67. swift/container/auditor.py +11 -0
  68. swift/container/backend.py +136 -31
  69. swift/container/reconciler.py +11 -2
  70. swift/container/replicator.py +64 -7
  71. swift/container/server.py +276 -146
  72. swift/container/sharder.py +86 -42
  73. swift/container/sync.py +11 -1
  74. swift/container/updater.py +12 -2
  75. swift/obj/auditor.py +20 -3
  76. swift/obj/diskfile.py +63 -25
  77. swift/obj/expirer.py +154 -47
  78. swift/obj/mem_diskfile.py +2 -1
  79. swift/obj/mem_server.py +1 -0
  80. swift/obj/reconstructor.py +28 -4
  81. swift/obj/replicator.py +63 -24
  82. swift/obj/server.py +76 -59
  83. swift/obj/updater.py +12 -2
  84. swift/obj/watchers/dark_data.py +72 -34
  85. swift/proxy/controllers/account.py +3 -2
  86. swift/proxy/controllers/base.py +254 -148
  87. swift/proxy/controllers/container.py +274 -289
  88. swift/proxy/controllers/obj.py +120 -166
  89. swift/proxy/server.py +17 -13
  90. {swift-2.32.0.dist-info → swift-2.34.0.dist-info}/AUTHORS +14 -4
  91. {swift-2.32.0.dist-info → swift-2.34.0.dist-info}/METADATA +9 -7
  92. {swift-2.32.0.dist-info → swift-2.34.0.dist-info}/RECORD +97 -120
  93. {swift-2.32.0.dist-info → swift-2.34.0.dist-info}/entry_points.txt +39 -0
  94. swift-2.34.0.dist-info/pbr.json +1 -0
  95. swift-2.32.0.data/scripts/swift-account-auditor +0 -23
  96. swift-2.32.0.data/scripts/swift-account-info +0 -52
  97. swift-2.32.0.data/scripts/swift-account-reaper +0 -23
  98. swift-2.32.0.data/scripts/swift-account-replicator +0 -34
  99. swift-2.32.0.data/scripts/swift-account-server +0 -23
  100. swift-2.32.0.data/scripts/swift-container-auditor +0 -23
  101. swift-2.32.0.data/scripts/swift-container-info +0 -56
  102. swift-2.32.0.data/scripts/swift-container-reconciler +0 -21
  103. swift-2.32.0.data/scripts/swift-container-replicator +0 -34
  104. swift-2.32.0.data/scripts/swift-container-server +0 -23
  105. swift-2.32.0.data/scripts/swift-container-sharder +0 -37
  106. swift-2.32.0.data/scripts/swift-container-sync +0 -23
  107. swift-2.32.0.data/scripts/swift-container-updater +0 -23
  108. swift-2.32.0.data/scripts/swift-dispersion-report +0 -24
  109. swift-2.32.0.data/scripts/swift-form-signature +0 -20
  110. swift-2.32.0.data/scripts/swift-init +0 -119
  111. swift-2.32.0.data/scripts/swift-object-auditor +0 -29
  112. swift-2.32.0.data/scripts/swift-object-expirer +0 -33
  113. swift-2.32.0.data/scripts/swift-object-info +0 -60
  114. swift-2.32.0.data/scripts/swift-object-reconstructor +0 -33
  115. swift-2.32.0.data/scripts/swift-object-relinker +0 -23
  116. swift-2.32.0.data/scripts/swift-object-replicator +0 -37
  117. swift-2.32.0.data/scripts/swift-object-server +0 -27
  118. swift-2.32.0.data/scripts/swift-object-updater +0 -23
  119. swift-2.32.0.data/scripts/swift-proxy-server +0 -23
  120. swift-2.32.0.data/scripts/swift-recon +0 -24
  121. swift-2.32.0.data/scripts/swift-ring-builder +0 -37
  122. swift-2.32.0.data/scripts/swift-ring-builder-analyzer +0 -22
  123. swift-2.32.0.data/scripts/swift-ring-composer +0 -22
  124. swift-2.32.0.dist-info/pbr.json +0 -1
  125. {swift-2.32.0.dist-info → swift-2.34.0.dist-info}/LICENSE +0 -0
  126. {swift-2.32.0.dist-info → swift-2.34.0.dist-info}/WHEEL +0 -0
  127. {swift-2.32.0.dist-info → swift-2.34.0.dist-info}/top_level.txt +0 -0
@@ -17,6 +17,7 @@ import errno
17
17
  import json
18
18
  import logging
19
19
  import operator
20
+ from optparse import OptionParser
20
21
  import time
21
22
  from collections import defaultdict
22
23
  from operator import itemgetter
@@ -32,6 +33,7 @@ from swift.common import internal_client
32
33
  from swift.common.constraints import check_drive, AUTO_CREATE_ACCOUNT_PREFIX
33
34
  from swift.common.direct_client import (direct_put_container,
34
35
  DirectClientException)
36
+ from swift.common.daemon import run_daemon
35
37
  from swift.common.request_helpers import USE_REPLICATION_NETWORK_HEADER
36
38
  from swift.common.ring.utils import is_local_device
37
39
  from swift.common.swob import str_to_wsgi
@@ -39,7 +41,7 @@ from swift.common.utils import get_logger, config_true_value, \
39
41
  dump_recon_cache, whataremyips, Timestamp, ShardRange, GreenAsyncPile, \
40
42
  config_positive_int_value, quorum_size, parse_override_options, \
41
43
  Everything, config_auto_int_value, ShardRangeList, config_percent_value, \
42
- node_to_string
44
+ node_to_string, parse_options
43
45
  from swift.container.backend import ContainerBroker, \
44
46
  RECORD_TYPE_SHARD, UNSHARDED, SHARDING, SHARDED, COLLAPSED, \
45
47
  SHARD_UPDATE_STATES, sift_shard_ranges, SHARD_UPDATE_STAT_STATES
@@ -50,6 +52,8 @@ CLEAVE_SUCCESS = 0
50
52
  CLEAVE_FAILED = 1
51
53
  CLEAVE_EMPTY = 2
52
54
 
55
+ DEFAULT_PERIODIC_WARNINGS_INTERVAL = 24 * 3600
56
+
53
57
 
54
58
  def sharding_enabled(broker):
55
59
  # NB all shards will by default have been created with
@@ -852,18 +856,7 @@ class ContainerSharder(ContainerSharderConf, ContainerReplicator):
852
856
  ContainerReplicator.__init__(self, conf, logger=logger)
853
857
  ContainerSharderConf.__init__(self, conf)
854
858
  ContainerSharderConf.validate_conf(self)
855
- if conf.get('auto_create_account_prefix'):
856
- self.logger.warning('Option auto_create_account_prefix is '
857
- 'deprecated. Configure '
858
- 'auto_create_account_prefix under the '
859
- 'swift-constraints section of '
860
- 'swift.conf. This option will '
861
- 'be ignored in a future release.')
862
- auto_create_account_prefix = \
863
- self.conf['auto_create_account_prefix']
864
- else:
865
- auto_create_account_prefix = AUTO_CREATE_ACCOUNT_PREFIX
866
- self.shards_account_prefix = (auto_create_account_prefix + 'shards_')
859
+ self.shards_account_prefix = (AUTO_CREATE_ACCOUNT_PREFIX + 'shards_')
867
860
  self.sharding_candidates = []
868
861
  self.shrinking_candidates = []
869
862
  replica_count = self.ring.replica_count
@@ -908,9 +901,13 @@ class ContainerSharder(ContainerSharderConf, ContainerReplicator):
908
901
  (internal_client_conf_path, err))
909
902
  self.stats_interval = float(conf.get('stats_interval', '3600'))
910
903
  self.reported = 0
904
+ self.periodic_warnings_interval = float(
905
+ conf.get('periodic_warnings_interval',
906
+ DEFAULT_PERIODIC_WARNINGS_INTERVAL))
907
+ self.periodic_warnings_start = time.time()
908
+ self.periodic_warnings = set()
911
909
 
912
- def _format_log_msg(self, broker, msg, *args):
913
- # make best effort to include broker properties...
910
+ def _get_broker_details(self, broker):
914
911
  try:
915
912
  db_file = broker.db_file
916
913
  except Exception: # noqa
@@ -919,7 +916,11 @@ class ContainerSharder(ContainerSharderConf, ContainerReplicator):
919
916
  path = broker.path
920
917
  except Exception: # noqa
921
918
  path = ''
919
+ return db_file, path
922
920
 
921
+ def _format_log_msg(self, broker, msg, *args):
922
+ # make best effort to include broker properties...
923
+ db_file, path = self._get_broker_details(broker)
923
924
  if args:
924
925
  msg = msg % args
925
926
  return '%s, path: %s, db: %s' % (msg, quote(path), db_file)
@@ -939,6 +940,19 @@ class ContainerSharder(ContainerSharderConf, ContainerReplicator):
939
940
  def warning(self, broker, msg, *args, **kwargs):
940
941
  self._log(logging.WARNING, broker, msg, *args, **kwargs)
941
942
 
943
+ def periodic_warning(self, broker, msg, *args, **kwargs):
944
+ now = time.time()
945
+ if now - self.periodic_warnings_start >= \
946
+ self.periodic_warnings_interval:
947
+ self.periodic_warnings.clear()
948
+ self.periodic_warnings_start = now
949
+
950
+ db_file, path = self._get_broker_details(broker)
951
+ key = (db_file, msg)
952
+ if key not in self.periodic_warnings:
953
+ self.periodic_warnings.add(key)
954
+ self._log(logging.WARNING, broker, msg, *args, **kwargs)
955
+
942
956
  def error(self, broker, msg, *args, **kwargs):
943
957
  self._log(logging.ERROR, broker, msg, *args, **kwargs)
944
958
 
@@ -1156,6 +1170,7 @@ class ContainerSharder(ContainerSharderConf, ContainerReplicator):
1156
1170
  params = params or {}
1157
1171
  params.setdefault('format', 'json')
1158
1172
  headers = {'X-Backend-Record-Type': 'shard',
1173
+ 'X-Backend-Record-Shard-Format': 'full',
1159
1174
  'X-Backend-Override-Deleted': 'true',
1160
1175
  'X-Backend-Include-Deleted': str(include_deleted)}
1161
1176
  if newest:
@@ -1296,7 +1311,7 @@ class ContainerSharder(ContainerSharderConf, ContainerReplicator):
1296
1311
  # Shrinking is how we resolve overlaps; we've got to
1297
1312
  # allow multiple shards in that state
1298
1313
  continue
1299
- shard_ranges = broker.get_shard_ranges(states=state)
1314
+ shard_ranges = broker.get_shard_ranges(states=[state])
1300
1315
  # Transient overlaps can occur during the period immediately after
1301
1316
  # sharding if a root learns about new child shards before it learns
1302
1317
  # that the parent has sharded. These overlaps are normally
@@ -1549,8 +1564,8 @@ class ContainerSharder(ContainerSharderConf, ContainerReplicator):
1549
1564
  if broker.is_deleted():
1550
1565
  if broker.is_old_enough_to_reclaim(time.time(), self.reclaim_age) \
1551
1566
  and not broker.is_empty_enough_to_reclaim():
1552
- self.warning(broker,
1553
- 'Reclaimable db stuck waiting for shrinking')
1567
+ self.periodic_warning(
1568
+ broker, 'Reclaimable db stuck waiting for shrinking')
1554
1569
  # if the container has been marked as deleted, all metadata will
1555
1570
  # have been erased so no point auditing. But we want it to pass, in
1556
1571
  # case any objects exist inside it.
@@ -1678,11 +1693,15 @@ class ContainerSharder(ContainerSharderConf, ContainerReplicator):
1678
1693
  dest_broker, node_id, info):
1679
1694
  success, responses = self._replicate_object(
1680
1695
  part, dest_broker.db_file, node_id)
1696
+ replication_successes = responses.count(True)
1681
1697
  quorum = quorum_size(self.ring.replica_count)
1682
- if not success and responses.count(True) < quorum:
1683
- self.warning(broker, 'Failed to sufficiently replicate misplaced '
1684
- 'objects to %s (not removing)',
1685
- dest_shard_range)
1698
+ if not success and replication_successes < quorum:
1699
+ self.warning(
1700
+ broker, 'Failed to sufficiently replicate misplaced objects '
1701
+ 'shard %s in state %s: %s successes, %s required '
1702
+ '(not removing objects), shard db: %s',
1703
+ dest_shard_range.name, dest_shard_range.state_text,
1704
+ replication_successes, quorum, dest_broker.db_file)
1686
1705
  return False
1687
1706
 
1688
1707
  if broker.get_info()['id'] != info['id']:
@@ -1700,9 +1719,9 @@ class ContainerSharder(ContainerSharderConf, ContainerReplicator):
1700
1719
  success = True
1701
1720
 
1702
1721
  if not success:
1703
- self.warning(broker,
1704
- 'Refused to remove misplaced objects for dest %s',
1705
- dest_shard_range)
1722
+ self.warning(broker, 'Refused to remove misplaced objects for '
1723
+ 'dest %s in state %s',
1724
+ dest_shard_range.name, dest_shard_range.state_text)
1706
1725
  return success
1707
1726
 
1708
1727
  def _move_objects(self, src_broker, src_shard_range, policy_index,
@@ -1800,12 +1819,12 @@ class ContainerSharder(ContainerSharderConf, ContainerReplicator):
1800
1819
 
1801
1820
  def _make_misplaced_object_bounds(self, broker):
1802
1821
  bounds = []
1803
- state = broker.get_db_state()
1804
- if state == SHARDED:
1822
+ db_state = broker.get_db_state()
1823
+ if db_state == SHARDED:
1805
1824
  # Anything in the object table is treated as a misplaced object.
1806
1825
  bounds.append(('', ''))
1807
1826
 
1808
- if not bounds and state == SHARDING:
1827
+ if not bounds and db_state == SHARDING:
1809
1828
  # Objects outside of this container's own range are misplaced.
1810
1829
  # Objects in already cleaved shard ranges are also misplaced.
1811
1830
  cleave_context = CleavingContext.load(broker)
@@ -1919,7 +1938,7 @@ class ContainerSharder(ContainerSharderConf, ContainerReplicator):
1919
1938
  # Create shard containers that are ready to receive redirected object
1920
1939
  # updates. Do this now, so that redirection can begin immediately
1921
1940
  # without waiting for cleaving to complete.
1922
- found_ranges = broker.get_shard_ranges(states=ShardRange.FOUND)
1941
+ found_ranges = broker.get_shard_ranges(states=[ShardRange.FOUND])
1923
1942
  created_ranges = []
1924
1943
  for shard_range in found_ranges:
1925
1944
  self._increment_stat('created', 'attempted')
@@ -2059,10 +2078,13 @@ class ContainerSharder(ContainerSharderConf, ContainerReplicator):
2059
2078
  # insufficient replication or replication not even attempted;
2060
2079
  # break because we don't want to progress the cleave cursor
2061
2080
  # until each shard range has been successfully cleaved
2062
- self.warning(broker,
2063
- 'Failed to sufficiently replicate cleaved shard '
2064
- '%s: %s successes, %s required', shard_range,
2065
- replication_successes, replication_quorum)
2081
+ self.warning(
2082
+ broker, 'Failed to sufficiently replicate cleaved shard '
2083
+ '%s in state %s: %s successes, %s required, '
2084
+ 'shard db: %s',
2085
+ shard_broker.path, shard_range.state_text,
2086
+ replication_successes, replication_quorum,
2087
+ shard_broker.db_file)
2066
2088
  self._increment_stat('cleaved', 'failure', statsd=True)
2067
2089
  result = CLEAVE_FAILED
2068
2090
  else:
@@ -2214,7 +2236,7 @@ class ContainerSharder(ContainerSharderConf, ContainerReplicator):
2214
2236
  else:
2215
2237
  own_shard_range.update_state(ShardRange.SHARDED)
2216
2238
  modified_shard_ranges = broker.get_shard_ranges(
2217
- states=ShardRange.CLEAVED)
2239
+ states=[ShardRange.CLEAVED])
2218
2240
  for sr in modified_shard_ranges:
2219
2241
  sr.update_state(ShardRange.ACTIVE)
2220
2242
  if (not broker.is_root_container() and not
@@ -2322,9 +2344,9 @@ class ContainerSharder(ContainerSharderConf, ContainerReplicator):
2322
2344
 
2323
2345
  def _process_broker(self, broker, node, part):
2324
2346
  broker.get_info() # make sure account/container are populated
2325
- state = broker.get_db_state()
2347
+ db_state = broker.get_db_state()
2326
2348
  is_deleted = broker.is_deleted()
2327
- self.debug(broker, 'Starting processing, state %s%s', state,
2349
+ self.debug(broker, 'Starting processing, state %s%s', db_state,
2328
2350
  ' (deleted)' if is_deleted else '')
2329
2351
 
2330
2352
  if not self._audit_container(broker):
@@ -2338,7 +2360,7 @@ class ContainerSharder(ContainerSharderConf, ContainerReplicator):
2338
2360
 
2339
2361
  is_leader = node['index'] == 0 and self.auto_shard and not is_deleted
2340
2362
 
2341
- if state in (UNSHARDED, COLLAPSED):
2363
+ if db_state in (UNSHARDED, COLLAPSED):
2342
2364
  if is_leader and broker.is_root_container():
2343
2365
  # bootstrap sharding of root container
2344
2366
  own_shard_range = broker.get_own_shard_range()
@@ -2354,7 +2376,7 @@ class ContainerSharder(ContainerSharderConf, ContainerReplicator):
2354
2376
  # or manually triggered cleaving.
2355
2377
  db_start_ts = time.time()
2356
2378
  if broker.set_sharding_state():
2357
- state = SHARDING
2379
+ db_state = SHARDING
2358
2380
  self.info(broker, 'Kick off container cleaving, '
2359
2381
  'own shard range in state %r',
2360
2382
  own_shard_range.state_text)
@@ -2362,14 +2384,14 @@ class ContainerSharder(ContainerSharderConf, ContainerReplicator):
2362
2384
  'sharder.sharding.set_state', db_start_ts)
2363
2385
  elif is_leader:
2364
2386
  if broker.set_sharding_state():
2365
- state = SHARDING
2387
+ db_state = SHARDING
2366
2388
  else:
2367
2389
  self.debug(broker,
2368
2390
  'Own shard range in state %r but no shard '
2369
2391
  'ranges and not leader; remaining unsharded',
2370
2392
  own_shard_range.state_text)
2371
2393
 
2372
- if state == SHARDING:
2394
+ if db_state == SHARDING:
2373
2395
  cleave_start_ts = time.time()
2374
2396
  if is_leader:
2375
2397
  num_found = self._find_shard_ranges(broker)
@@ -2390,7 +2412,7 @@ class ContainerSharder(ContainerSharderConf, ContainerReplicator):
2390
2412
 
2391
2413
  if cleave_complete:
2392
2414
  if self._complete_sharding(broker):
2393
- state = SHARDED
2415
+ db_state = SHARDED
2394
2416
  self._increment_stat('visited', 'completed', statsd=True)
2395
2417
  self.info(broker, 'Completed cleaving, DB set to sharded '
2396
2418
  'state')
@@ -2402,7 +2424,7 @@ class ContainerSharder(ContainerSharderConf, ContainerReplicator):
2402
2424
  'sharding state')
2403
2425
 
2404
2426
  if not broker.is_deleted():
2405
- if state == SHARDED and broker.is_root_container():
2427
+ if db_state == SHARDED and broker.is_root_container():
2406
2428
  # look for shrink stats
2407
2429
  send_start_ts = time.time()
2408
2430
  self._identify_shrinking_candidate(broker, node)
@@ -2554,3 +2576,25 @@ class ContainerSharder(ContainerSharderConf, ContainerReplicator):
2554
2576
  elapsed = time.time() - begin
2555
2577
  self.logger.info(
2556
2578
  'Container sharder "once" mode completed: %.02fs', elapsed)
2579
+
2580
+
2581
+ def main():
2582
+ parser = OptionParser("%prog CONFIG [options]")
2583
+ parser.add_option('-d', '--devices',
2584
+ help='Shard containers only on given devices. '
2585
+ 'Comma-separated list. '
2586
+ 'Only has effect if --once is used.')
2587
+ parser.add_option('-p', '--partitions',
2588
+ help='Shard containers only in given partitions. '
2589
+ 'Comma-separated list. '
2590
+ 'Only has effect if --once is used.')
2591
+ parser.add_option('--no-auto-shard', action='store_false',
2592
+ dest='auto_shard', default=None,
2593
+ help='Disable auto-sharding. Overrides the auto_shard '
2594
+ 'value in the config file.')
2595
+ conf_file, options = parse_options(parser=parser, once=True)
2596
+ run_daemon(ContainerSharder, conf_file, **options)
2597
+
2598
+
2599
+ if __name__ == '__main__':
2600
+ main()
swift/container/sync.py CHANGED
@@ -29,6 +29,7 @@ from swift.common.db import DatabaseConnectionError
29
29
  from swift.container.backend import ContainerBroker
30
30
  from swift.container.sync_store import ContainerSyncStore
31
31
  from swift.common.container_sync_realms import ContainerSyncRealms
32
+ from swift.common.daemon import run_daemon
32
33
  from swift.common.internal_client import (
33
34
  delete_object, put_object, head_object,
34
35
  InternalClient, UnexpectedResponse)
@@ -39,7 +40,7 @@ from swift.common.swob import normalize_etag
39
40
  from swift.common.utils import (
40
41
  clean_content_type, config_true_value,
41
42
  FileLikeIter, get_logger, hash_path, quote, validate_sync_to,
42
- whataremyips, Timestamp, decode_timestamps)
43
+ whataremyips, Timestamp, decode_timestamps, parse_options)
43
44
  from swift.common.daemon import Daemon
44
45
  from swift.common.http import HTTP_UNAUTHORIZED, HTTP_NOT_FOUND, HTTP_CONFLICT
45
46
  from swift.common.wsgi import ConfigString
@@ -650,3 +651,12 @@ class ContainerSync(Daemon):
650
651
 
651
652
  def select_http_proxy(self):
652
653
  return choice(self.http_proxies) if self.http_proxies else None
654
+
655
+
656
+ def main():
657
+ conf_file, options = parse_options(once=True)
658
+ run_daemon(ContainerSync, conf_file, **options)
659
+
660
+
661
+ if __name__ == '__main__':
662
+ main()
@@ -32,8 +32,8 @@ from swift.common.exceptions import ConnectionTimeout, LockTimeout
32
32
  from swift.common.ring import Ring
33
33
  from swift.common.utils import get_logger, config_true_value, \
34
34
  dump_recon_cache, majority_size, Timestamp, EventletRateLimiter, \
35
- eventlet_monkey_patch, node_to_string
36
- from swift.common.daemon import Daemon
35
+ eventlet_monkey_patch, node_to_string, parse_options
36
+ from swift.common.daemon import Daemon, run_daemon
37
37
  from swift.common.http import is_success, HTTP_INTERNAL_SERVER_ERROR
38
38
  from swift.common.recon import RECON_CONTAINER_FILE, DEFAULT_RECON_CACHE_PATH
39
39
 
@@ -158,6 +158,7 @@ class ContainerUpdater(Daemon):
158
158
  pid2filename[pid] = tmpfilename
159
159
  else:
160
160
  signal.signal(signal.SIGTERM, signal.SIG_DFL)
161
+ os.environ.pop('NOTIFY_SOCKET', None)
161
162
  eventlet_monkey_patch()
162
163
  self.no_changes = 0
163
164
  self.successes = 0
@@ -356,3 +357,12 @@ class ContainerUpdater(Daemon):
356
357
  return HTTP_INTERNAL_SERVER_ERROR
357
358
  finally:
358
359
  conn.close()
360
+
361
+
362
+ def main():
363
+ conf_file, options = parse_options(once=True)
364
+ run_daemon(ContainerUpdater, conf_file, **options)
365
+
366
+
367
+ if __name__ == '__main__':
368
+ main()
swift/obj/auditor.py CHANGED
@@ -18,20 +18,22 @@ import os
18
18
  import sys
19
19
  import time
20
20
  import signal
21
+ from optparse import OptionParser
21
22
  from os.path import basename, dirname, join
22
23
  from random import shuffle
23
24
  from contextlib import closing
24
25
  from eventlet import Timeout
25
26
 
26
27
  from swift.obj import diskfile, replicator
27
- from swift.common.exceptions import DiskFileQuarantined, DiskFileNotExist,\
28
+ from swift.common.exceptions import DiskFileQuarantined, DiskFileNotExist, \
28
29
  DiskFileDeleted, DiskFileExpired, QuarantineRequest
29
- from swift.common.daemon import Daemon
30
+ from swift.common.daemon import Daemon, run_daemon
30
31
  from swift.common.storage_policy import POLICIES
31
32
  from swift.common.utils import (
32
33
  config_auto_int_value, dump_recon_cache, get_logger, list_from_csv,
33
34
  listdir, load_pkg_resource, parse_prefixed_conf, EventletRateLimiter,
34
- readconf, round_robin_iter, unlink_paths_older_than, PrefixLoggerAdapter)
35
+ readconf, round_robin_iter, unlink_paths_older_than, PrefixLoggerAdapter,
36
+ parse_options)
35
37
  from swift.common.recon import RECON_OBJECT_FILE, DEFAULT_RECON_CACHE_PATH
36
38
 
37
39
 
@@ -368,6 +370,7 @@ class ObjectAuditor(Daemon):
368
370
  return pid
369
371
  else:
370
372
  signal.signal(signal.SIGTERM, signal.SIG_DFL)
373
+ os.environ.pop('NOTIFY_SOCKET', None)
371
374
  if zero_byte_fps:
372
375
  kwargs['zero_byte_fps'] = self.conf_zero_byte_fps
373
376
  if sleep_between_zbf_scanner:
@@ -536,3 +539,17 @@ class WatcherWrapper(object):
536
539
  except (Exception, Timeout):
537
540
  self.logger.exception('Error ending watcher')
538
541
  self.watcher_in_error = True
542
+
543
+
544
+ def main():
545
+ parser = OptionParser("%prog CONFIG [options]")
546
+ parser.add_option('-z', '--zero_byte_fps',
547
+ help='Audit only zero byte files at specified files/sec')
548
+ parser.add_option('-d', '--devices',
549
+ help='Audit only given devices. Comma-separated list')
550
+ conf_file, options = parse_options(parser=parser, once=True)
551
+ run_daemon(ObjectAuditor, conf_file, **options)
552
+
553
+
554
+ if __name__ == '__main__':
555
+ main()