Browse code

Revert "Use uwsgi for glance-api"

This reverts commit e6217a9719b88b550ccbbce7c9bc064cb746c1a3.

Unfortunately it seems to break glance; for examples see some of the
nodepool dib jobs which have all failed to upload images into glance.

Note this has a revert for 43304849cfde41fa86a6fdd334ab6e703598ef8d as
well, since that uses GLANCE_URL defined here.

[1] http://logs.openstack.org/51/475051/2/gate/gate-dsvm-nodepool-redhat-src/e1bdb34/
[2] http://logs.openstack.org/51/475051/2/gate/gate-dsvm-nodepool-ubuntu-src/6a7665b/
[3] http://logs.openstack.org/51/475051/2/gate/gate-dsvm-nodepool-opensuse-src/b357de1/

Change-Id: I2aea120e733b05e806801121ec994f4e31a337d9

Ian Wienand authored on 2017/06/21 21:07:53
Showing 4 changed files
... ...
@@ -275,64 +275,12 @@ function write_uwsgi_config {
275 275
     else
276 276
         local apache_conf=""
277 277
         apache_conf=$(apache_site_config_for $name)
278
-        echo "SetEnv proxy-sendcl 1" | sudo tee $apache_conf
279
-        echo "ProxyPass \"${url}\" \"unix:${socket}|uwsgi://uwsgi-uds-${name}/\" retry=0 " | sudo tee -a $apache_conf
278
+        echo "ProxyPass \"${url}\" \"unix:${socket}|uwsgi://uwsgi-uds-${name}/\" retry=0 " | sudo tee $apache_conf
280 279
         enable_apache_site $name
281 280
         restart_apache_server
282 281
     fi
283 282
 }
284 283
 
285
-# For services using chunked encoding, the only services known to use this
286
-# currently are Glance and Swift, we need to use an http proxy instead of
287
-# mod_proxy_uwsgi because the chunked encoding gets dropped. See:
288
-# https://github.com/unbit/uwsgi/issues/1540 You can workaround this on python2
289
-# but that involves having apache buffer the request before sending it to
290
-# uswgi.
291
-function write_local_uwsgi_http_config {
292
-    local file=$1
293
-    local wsgi=$2
294
-    local url=$3
295
-    name=$(basename $wsgi)
296
-
297
-    # create a home for the sockets; note don't use /tmp -- apache has
298
-    # a private view of it on some platforms.
299
-
300
-    # always cleanup given that we are using iniset here
301
-    rm -rf $file
302
-    iniset "$file" uwsgi wsgi-file "$wsgi"
303
-    port=$(get_random_port)
304
-    iniset "$file" uwsgi http "127.0.0.1:$port"
305
-    iniset "$file" uwsgi processes $API_WORKERS
306
-    # This is running standalone
307
-    iniset "$file" uwsgi master true
308
-    # Set die-on-term & exit-on-reload so that uwsgi shuts down
309
-    iniset "$file" uwsgi die-on-term true
310
-    iniset "$file" uwsgi exit-on-reload true
311
-    iniset "$file" uwsgi enable-threads true
312
-    iniset "$file" uwsgi plugins python
313
-    # uwsgi recommends this to prevent thundering herd on accept.
314
-    iniset "$file" uwsgi thunder-lock true
315
-    # Override the default size for headers from the 4k default.
316
-    iniset "$file" uwsgi buffer-size 65535
317
-    # Make sure the client doesn't try to re-use the connection.
318
-    iniset "$file" uwsgi add-header "Connection: close"
319
-    # This ensures that file descriptors aren't shared between processes.
320
-    iniset "$file" uwsgi lazy-apps true
321
-    iniset "$file" uwsgi chmod-socket 666
322
-    iniset "$file" uwsgi http-raw-body true
323
-    iniset "$file" uwsgi http-chunked-input true
324
-    iniset "$file" uwsgi http-auto-chunked true
325
-
326
-    enable_apache_mod proxy
327
-    enable_apache_mod proxy_http
328
-    local apache_conf=""
329
-    apache_conf=$(apache_site_config_for $name)
330
-    echo "KeepAlive Off" | sudo tee $apache_conf
331
-    echo "ProxyPass \"${url}\" \"http://127.0.0.1:$port\" retry=0 " | sudo tee -a $apache_conf
332
-    enable_apache_site $name
333
-    restart_apache_server
334
-}
335
-
336 284
 function remove_uwsgi_config {
337 285
     local file=$1
338 286
     local wsgi=$2
... ...
@@ -335,7 +335,7 @@ function configure_cinder {
335 335
 
336 336
     iniset $CINDER_CONF DEFAULT osapi_volume_workers "$API_WORKERS"
337 337
 
338
-    iniset $CINDER_CONF DEFAULT glance_api_servers "$GLANCE_URL"
338
+    iniset $CINDER_CONF DEFAULT glance_api_servers "${GLANCE_SERVICE_PROTOCOL}://${GLANCE_HOSTPORT}"
339 339
     if is_service_enabled tls-proxy; then
340 340
         iniset $CINDER_CONF DEFAULT glance_protocol https
341 341
         iniset $CINDER_CONF DEFAULT glance_ca_certificates_file $SSL_BUNDLE_FILE
... ...
@@ -71,16 +71,6 @@ GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$GLANCE_SERVICE_HOST:$GLANCE_SERVICE_PORT}
71 71
 GLANCE_SERVICE_PROTOCOL=${GLANCE_SERVICE_PROTOCOL:-$SERVICE_PROTOCOL}
72 72
 GLANCE_REGISTRY_PORT=${GLANCE_REGISTRY_PORT:-9191}
73 73
 GLANCE_REGISTRY_PORT_INT=${GLANCE_REGISTRY_PORT_INT:-19191}
74
-GLANCE_UWSGI=$GLANCE_BIN_DIR/glance-wsgi-api
75
-GLANCE_UWSGI_CONF=$GLANCE_CONF_DIR/glance-uswgi.ini
76
-# If wsgi mode is uwsgi run glance under uwsgi, else default to eventlet
77
-# TODO(mtreinish): Remove the eventlet path here and in all the similar
78
-# conditionals below after the Pike release
79
-if [[ "$WSGI_MODE" == "uwsgi" ]]; then
80
-    GLANCE_URL="$GLANCE_SERVICE_PROTOCOL://$GLANCE_SERVICE_HOST/image"
81
-else
82
-    GLANCE_URL="$GLANCE_SERVICE_PROTOCOL://$GLANCE_HOSTPORT"
83
-fi
84 74
 
85 75
 # Functions
86 76
 # ---------
... ...
@@ -114,13 +104,16 @@ function configure_glance {
114 114
     dburl=`database_connection_url glance`
115 115
     iniset $GLANCE_REGISTRY_CONF database connection $dburl
116 116
     iniset $GLANCE_REGISTRY_CONF DEFAULT use_syslog $SYSLOG
117
+    iniset $GLANCE_REGISTRY_CONF DEFAULT workers "$API_WORKERS"
117 118
     iniset $GLANCE_REGISTRY_CONF paste_deploy flavor keystone
118 119
     configure_auth_token_middleware $GLANCE_REGISTRY_CONF glance $GLANCE_AUTH_CACHE_DIR/registry
119 120
     iniset $GLANCE_REGISTRY_CONF oslo_messaging_notifications driver messagingv2
120 121
     iniset_rpc_backend glance $GLANCE_REGISTRY_CONF
121 122
     iniset $GLANCE_REGISTRY_CONF DEFAULT graceful_shutdown_timeout "$SERVICE_GRACEFUL_SHUTDOWN_TIMEOUT"
122 123
 
124
+    cp $GLANCE_DIR/etc/glance-api.conf $GLANCE_API_CONF
123 125
     iniset $GLANCE_API_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL
126
+    iniset $GLANCE_API_CONF DEFAULT bind_host $GLANCE_SERVICE_LISTEN_ADDRESS
124 127
     inicomment $GLANCE_API_CONF DEFAULT log_file
125 128
     iniset $GLANCE_API_CONF database connection $dburl
126 129
     iniset $GLANCE_API_CONF DEFAULT use_syslog $SYSLOG
... ...
@@ -148,6 +141,8 @@ function configure_glance {
148 148
     iniset $GLANCE_API_CONF glance_store filesystem_store_datadir $GLANCE_IMAGE_DIR/
149 149
     iniset $GLANCE_API_CONF DEFAULT registry_host $GLANCE_SERVICE_HOST
150 150
 
151
+    iniset $GLANCE_API_CONF DEFAULT workers "$API_WORKERS"
152
+
151 153
     # CORS feature support - to allow calls from Horizon by default
152 154
     if [ -n "$GLANCE_CORS_ALLOWED_ORIGIN" ]; then
153 155
         iniset $GLANCE_API_CONF cors allowed_origin "$GLANCE_CORS_ALLOWED_ORIGIN"
... ...
@@ -186,12 +181,9 @@ function configure_glance {
186 186
         inicomment $GLANCE_API_CONF glance_store swift_store_auth_address
187 187
     fi
188 188
 
189
-    # We need to tell glance what it's public endpoint is so that the version
190
-    # discovery document will be correct
191
-    iniset $GLANCE_API_CONF DEFAULT public_endpoint $GLANCE_URL
192
-
193 189
     if is_service_enabled tls-proxy; then
194 190
         iniset $GLANCE_API_CONF DEFAULT bind_port $GLANCE_SERVICE_PORT_INT
191
+        iniset $GLANCE_API_CONF DEFAULT public_endpoint $GLANCE_SERVICE_PROTOCOL://$GLANCE_HOSTPORT
195 192
         iniset $GLANCE_REGISTRY_CONF DEFAULT bind_port $GLANCE_REGISTRY_PORT_INT
196 193
 
197 194
         iniset $GLANCE_API_CONF keystone_authtoken identity_uri $KEYSTONE_AUTH_URI
... ...
@@ -207,6 +199,7 @@ function configure_glance {
207 207
     setup_logging $GLANCE_REGISTRY_CONF
208 208
 
209 209
     cp -p $GLANCE_DIR/etc/glance-registry-paste.ini $GLANCE_REGISTRY_PASTE_INI
210
+
210 211
     cp -p $GLANCE_DIR/etc/glance-api-paste.ini $GLANCE_API_PASTE_INI
211 212
 
212 213
     cp $GLANCE_DIR/etc/glance-cache.conf $GLANCE_CACHE_CONF
... ...
@@ -239,13 +232,6 @@ function configure_glance {
239 239
         iniset $GLANCE_API_CONF DEFAULT cinder_endpoint_template "https://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT/v1/%(project_id)s"
240 240
         iniset $GLANCE_CACHE_CONF DEFAULT cinder_endpoint_template "https://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT/v1/%(project_id)s"
241 241
     fi
242
-
243
-    if [[ "$WSGI_MODE" == "uwsgi" ]]; then
244
-        write_local_uwsgi_http_config "$GLANCE_UWSGI_CONF" "$GLANCE_UWSGI" "/image"
245
-    else
246
-        iniset $GLANCE_API_CONF DEFAULT bind_host $GLANCE_SERVICE_LISTEN_ADDRESS
247
-        iniset $GLANCE_API_CONF DEFAULT workers "$API_WORKERS"
248
-    fi
249 242
 }
250 243
 
251 244
 # create_glance_accounts() - Set up common required glance accounts
... ...
@@ -270,7 +256,7 @@ function create_glance_accounts {
270 270
         get_or_create_endpoint \
271 271
             "image" \
272 272
             "$REGION_NAME" \
273
-            "$GLANCE_URL"
273
+            "$GLANCE_SERVICE_PROTOCOL://$GLANCE_HOSTPORT"
274 274
 
275 275
         # Note(frickler): Crude workaround for https://bugs.launchpad.net/glance-store/+bug/1620999
276 276
         service_domain_id=$(get_or_create_domain $SERVICE_DOMAIN_NAME)
... ...
@@ -337,21 +323,15 @@ function install_glance {
337 337
 function start_glance {
338 338
     local service_protocol=$GLANCE_SERVICE_PROTOCOL
339 339
     if is_service_enabled tls-proxy; then
340
-        if [[ "$WSGI_MODE" != "uwsgi" ]]; then
341
-            start_tls_proxy glance-service '*' $GLANCE_SERVICE_PORT $GLANCE_SERVICE_HOST $GLANCE_SERVICE_PORT_INT
342
-        fi
340
+        start_tls_proxy glance-service '*' $GLANCE_SERVICE_PORT $GLANCE_SERVICE_HOST $GLANCE_SERVICE_PORT_INT
343 341
         start_tls_proxy glance-registry '*' $GLANCE_REGISTRY_PORT $GLANCE_SERVICE_HOST $GLANCE_REGISTRY_PORT_INT
344 342
     fi
345 343
 
346 344
     run_process g-reg "$GLANCE_BIN_DIR/glance-registry --config-file=$GLANCE_CONF_DIR/glance-registry.conf"
347
-    if [[ "$WSGI_MODE" == "uwsgi" ]]; then
348
-        run_process g-api "$GLANCE_BIN_DIR/uwsgi --ini $GLANCE_UWSGI_CONF"
349
-    else
350
-        run_process g-api "$GLANCE_BIN_DIR/glance-api --config-file=$GLANCE_CONF_DIR/glance-api.conf"
351
-    fi
345
+    run_process g-api "$GLANCE_BIN_DIR/glance-api --config-file=$GLANCE_CONF_DIR/glance-api.conf"
352 346
 
353
-    echo "Waiting for g-api ($GLANCE_SERVICE_HOST) to start..."
354
-    if ! wait_for_service $SERVICE_TIMEOUT $GLANCE_URL; then
347
+    echo "Waiting for g-api ($GLANCE_HOSTPORT) to start..."
348
+    if ! wait_for_service $SERVICE_TIMEOUT $GLANCE_SERVICE_PROTOCOL://$GLANCE_HOSTPORT; then
355 349
         die $LINENO "g-api did not start"
356 350
     fi
357 351
 }
... ...
@@ -575,7 +575,7 @@ function create_nova_conf {
575 575
     # enable notifications, but it will allow them to function when enabled.
576 576
     iniset $NOVA_CONF oslo_messaging_notifications driver "messagingv2"
577 577
     iniset_rpc_backend nova $NOVA_CONF
578
-    iniset $NOVA_CONF glance api_servers "$GLANCE_URL"
578
+    iniset $NOVA_CONF glance api_servers "${GLANCE_SERVICE_PROTOCOL}://${GLANCE_HOSTPORT}"
579 579
 
580 580
     iniset $NOVA_CONF DEFAULT osapi_compute_workers "$API_WORKERS"
581 581
     iniset $NOVA_CONF DEFAULT metadata_workers "$API_WORKERS"