Browse code

Merge "Swift: Optionally start only the necessary services"

Jenkins authored on 2017/04/07 09:33:22
Showing 1 changed files
... ...
@@ -128,6 +128,11 @@ SWIFT_PARTITION_POWER_SIZE=${SWIFT_PARTITION_POWER_SIZE:-9}
128 128
 SWIFT_REPLICAS=${SWIFT_REPLICAS:-1}
129 129
 SWIFT_REPLICAS_SEQ=$(seq ${SWIFT_REPLICAS})
130 130
 
131
+# Set ``SWIFT_START_ALL_SERVICES`` to control whether all Swift
132
+# services (including the *-auditor, *-replicator, *-reconstructor, etc.
133
+# daemons) should be started.
134
+SWIFT_START_ALL_SERVICES=$(trueorfalse True SWIFT_START_ALL_SERVICES)
135
+
131 136
 # Set ``SWIFT_LOG_TOKEN_LENGTH`` to configure how many characters of an auth
132 137
 # token should be placed in the logs. When keystone is used with PKI tokens,
133 138
 # the token values can be huge, seemingly larger the 2K, at the least. We
... ...
@@ -786,8 +791,11 @@ function start_swift {
786 786
     fi
787 787
 
788 788
     if [ "$SWIFT_USE_MOD_WSGI" == "True" ]; then
789
+        # Apache should serve the "PACO" a.k.a "main" services
789 790
         restart_apache_server
791
+        # The rest of the services should be started in backgroud
790 792
         swift-init --run-dir=${SWIFT_DATA_DIR}/run rest start
793
+        # Be we still want the logs of Swift Proxy in our screen session
791 794
         tail_log s-proxy /var/log/$APACHE_NAME/proxy-server
792 795
         if [[ ${SWIFT_REPLICAS} == 1 ]]; then
793 796
             for type in object container account; do
... ...
@@ -797,31 +805,42 @@ function start_swift {
797 797
         return 0
798 798
     fi
799 799
 
800
-    # By default with only one replica we are launching the proxy,
801
-    # container, account and object server in screen in foreground and
802
-    # other services in background. If we have ``SWIFT_REPLICAS`` set to something
803
-    # greater than one we first spawn all the Swift services then kill the proxy
804
-    # service so we can run it in foreground in screen.  ``swift-init ...
805
-    # {stop|restart}`` exits with '1' if no servers are running, ignore it just
806
-    # in case
807
-    local todo type
808
-    swift-init --run-dir=${SWIFT_DATA_DIR}/run all restart || true
800
+
801
+    # By default with only one replica we are launching the proxy, container
802
+    # account and object server in screen in foreground. Then, the rest of
803
+    # the services is optionally started.
804
+    #
805
+    # If we have ``SWIFT_REPLICAS`` set to something greater than one
806
+    # we first spawn *all* the Swift services then kill the proxy service
807
+    # so we can run it in foreground in screen.
808
+    #
809
+    # ``swift-init ... {stop|restart}`` exits with '1' if no servers are
810
+    #  running, ignore it just in case
809 811
     if [[ ${SWIFT_REPLICAS} == 1 ]]; then
810
-        todo="object container account"
812
+        local foreground_services type
813
+
814
+        foreground_services="object container account"
815
+        for type in ${foreground_services}; do
816
+            run_process s-${type} "$SWIFT_BIN_DIR/swift-${type}-server ${SWIFT_CONF_DIR}/${type}-server/1.conf -v"
817
+        done
818
+
819
+        if [[ "$SWIFT_START_ALL_SERVICES" == "True" ]]; then
820
+            swift-init --run-dir=${SWIFT_DATA_DIR}/run rest start
821
+        else
822
+            # The container-sync daemon is strictly needed to pass the container
823
+            # sync Tempest tests.
824
+            swift-init --run-dir=${SWIFT_DATA_DIR}/run container-sync start
825
+        fi
826
+    else
827
+        swift-init --run-dir=${SWIFT_DATA_DIR}/run all restart || true
828
+        swift-init --run-dir=${SWIFT_DATA_DIR}/run proxy stop || true
811 829
     fi
812
-    for type in proxy ${todo}; do
813
-        swift-init --run-dir=${SWIFT_DATA_DIR}/run ${type} stop || true
814
-    done
830
+
815 831
     if is_service_enabled tls-proxy; then
816 832
         local proxy_port=${SWIFT_DEFAULT_BIND_PORT}
817 833
         start_tls_proxy swift '*' $proxy_port $SERVICE_HOST $SWIFT_DEFAULT_BIND_PORT_INT
818 834
     fi
819 835
     run_process s-proxy "$SWIFT_BIN_DIR/swift-proxy-server ${SWIFT_CONF_DIR}/proxy-server.conf -v"
820
-    if [[ ${SWIFT_REPLICAS} == 1 ]]; then
821
-        for type in object container account; do
822
-            run_process s-${type} "$SWIFT_BIN_DIR/swift-${type}-server ${SWIFT_CONF_DIR}/${type}-server/1.conf -v"
823
-        done
824
-    fi
825 836
 
826 837
     if [[ "$SWIFT_ENABLE_TEMPURLS" == "True" ]]; then
827 838
         swift_configure_tempurls