Browse code

Add variable SWIFT_STORAGE_IPS

If the variable SWIFT_STORAGE_IPS contains a space-separated list of
IPs, we can use this to create consistent rings across all proxy and
storage nodes.

Change-Id: If9307196dc7e74e4a842c95503958ae2d7f7acc7

Christian Schwede authored on 2016/04/12 17:53:46
Showing 2 changed files
... ...
@@ -513,6 +513,18 @@ If you only want to do some testing of a real normal swift cluster
513 513
 with multiple replicas you can do so by customizing the variable
514 514
 ``SWIFT_REPLICAS`` in your ``localrc`` section (usually to 3).
515 515
 
516
+You can manually override the ring building to use specific storage
517
+nodes, for example when you want to test a multinode environment. In
518
+this case you have to set a space-separated list of IPs in
519
+``SWIFT_STORAGE_IPS`` in your ``localrc`` section that should be used
520
+as Swift storage nodes.
521
+Please note that this does not create a multinode setup, it is only
522
+used when adding nodes to the Swift rings.
523
+
524
+::
525
+
526
+    SWIFT_STORAGE_IPS="192.168.1.10 192.168.1.11 192.168.1.12"
527
+
516 528
 Swift S3
517 529
 ++++++++
518 530
 
... ...
@@ -149,6 +149,11 @@ SWIFT_TEMPURL_KEY=${SWIFT_TEMPURL_KEY:-}
149 149
 # Toggle for deploying Swift under HTTPD + mod_wsgi
150 150
 SWIFT_USE_MOD_WSGI=${SWIFT_USE_MOD_WSGI:-False}
151 151
 
152
+# A space-separated list of storage node IPs that
153
+# should be used to create the Swift rings
154
+SWIFT_STORAGE_IPS=${SWIFT_STORAGE_IPS:-}
155
+
156
+
152 157
 # Functions
153 158
 # ---------
154 159
 
... ...
@@ -693,14 +698,35 @@ function init_swift {
693 693
         swift-ring-builder container.builder create ${SWIFT_PARTITION_POWER_SIZE} ${SWIFT_REPLICAS} 1
694 694
         swift-ring-builder account.builder create ${SWIFT_PARTITION_POWER_SIZE} ${SWIFT_REPLICAS} 1
695 695
 
696
-        for node_number in ${SWIFT_REPLICAS_SEQ}; do
697
-            swift-ring-builder object.builder add z${node_number}-${SWIFT_SERVICE_LOCAL_HOST}:$(( OBJECT_PORT_BASE + 10 * (node_number - 1) ))/sdb1 1
698
-            swift-ring-builder container.builder add z${node_number}-${SWIFT_SERVICE_LOCAL_HOST}:$(( CONTAINER_PORT_BASE + 10 * (node_number - 1) ))/sdb1 1
699
-            swift-ring-builder account.builder add z${node_number}-${SWIFT_SERVICE_LOCAL_HOST}:$(( ACCOUNT_PORT_BASE + 10 * (node_number - 1) ))/sdb1 1
700
-        done
701
-        swift-ring-builder object.builder rebalance
702
-        swift-ring-builder container.builder rebalance
703
-        swift-ring-builder account.builder rebalance
696
+        # The ring will be created on each node, and because the order of
697
+        # nodes is identical we can use a seed for rebalancing, making it
698
+        # possible to get a ring on each node that uses the same partition
699
+        # assignment.
700
+        if [[ -n $SWIFT_STORAGE_IPS ]]; then
701
+            local node_number
702
+            node_number=1
703
+
704
+            for node in ${SWIFT_STORAGE_IPS}; do
705
+                swift-ring-builder object.builder add z${node_number}-${node}:${OBJECT_PORT_BASE}/sdb1 1
706
+                swift-ring-builder container.builder add z${node_number}-${node}:${CONTAINER_PORT_BASE}/sdb1 1
707
+                swift-ring-builder account.builder add z${node_number}-${node}:${ACCOUNT_PORT_BASE}/sdb1 1
708
+                let "node_number=node_number+1"
709
+            done
710
+
711
+        else
712
+
713
+            for node_number in ${SWIFT_REPLICAS_SEQ}; do
714
+                swift-ring-builder object.builder add z${node_number}-${SWIFT_SERVICE_LOCAL_HOST}:$(( OBJECT_PORT_BASE + 10 * (node_number - 1) ))/sdb1 1
715
+                swift-ring-builder container.builder add z${node_number}-${SWIFT_SERVICE_LOCAL_HOST}:$(( CONTAINER_PORT_BASE + 10 * (node_number - 1) ))/sdb1 1
716
+                swift-ring-builder account.builder add z${node_number}-${SWIFT_SERVICE_LOCAL_HOST}:$(( ACCOUNT_PORT_BASE + 10 * (node_number - 1) ))/sdb1 1
717
+            done
718
+        fi
719
+
720
+        # We use a seed for rebalancing. Doing this allows us to create
721
+        # identical rings on multiple nodes if SWIFT_STORAGE_IPS is the same
722
+        swift-ring-builder object.builder rebalance 42
723
+        swift-ring-builder container.builder rebalance 42
724
+        swift-ring-builder account.builder rebalance 42
704 725
     } && popd >/dev/null
705 726
 
706 727
     # Create cache dir