Browse code

Make Glance standalone-ness a separate flag

Full Glance functionality requires Glance being run in a configuration
where it can spawn long-running task threads. The default uwsgi mode
does not allow this, and the current workaround is to set WSGI_MODE
to something other than uwsgi to get the devstack code to deploy
Glance as a standalone service. Since this affects the entire rest of
the deployment, this patch separates out a flag to control this behavior
specifically for Glance. When WSGI_MODE=uwsgi, control of the Glance
deployment mechanism is allowed via GLANCE_STANDALONE=True|False. If
WSGI_MODE!= uwsgi then we deploy standalone Glance anyway.

Change-Id: I79068ce0bd7414bc48ff534ee22f0de5d7b091cb

Dan Smith authored on 2020/07/10 00:31:51
Showing 3 changed files
... ...
@@ -103,10 +103,10 @@ function _upload_image {
103 103
     done
104 104
 
105 105
     if [[ "$GLANCE_USE_IMPORT_WORKFLOW" == "True" ]]; then
106
-        if [[ "$WSGI_MODE" != "uwsgi" ]]; then
106
+        if [[ "$GLANCE_STANDALONE" == "True" ]]; then
107 107
             useimport="--import"
108 108
         else
109
-            echo "*** Unable to use glance import workflow because WSGI_MODE=uwsgi! ***"
109
+            echo "*** Unable to use glance import workflow because glance is not standalone! ***"
110 110
         fi
111 111
     fi
112 112
 
... ...
@@ -372,6 +372,25 @@ function write_local_uwsgi_http_config {
372 372
     restart_apache_server
373 373
 }
374 374
 
375
+# Write a straight-through proxy for a service that runs locally and just needs
376
+# to be reachable via the main http proxy at $loc
377
+function write_local_proxy_http_config {
378
+    local name=$1
379
+    local url=$2
380
+    local loc=$3
381
+    local apache_conf
382
+    apache_conf=$(apache_site_config_for $name)
383
+
384
+    enable_apache_mod proxy
385
+    enable_apache_mod proxy_http
386
+
387
+    echo "KeepAlive Off" | sudo tee $apache_conf
388
+    echo "SetEnv proxy-sendchunked 1" | sudo tee -a $apache_conf
389
+    echo "ProxyPass \"${loc}\" \"$url\" retry=0 " | sudo tee -a $apache_conf
390
+    enable_apache_site $name
391
+    restart_apache_server
392
+}
393
+
375 394
 function remove_uwsgi_config {
376 395
     local file=$1
377 396
     local wsgi=$2
... ...
@@ -55,6 +55,13 @@ GLANCE_DEFAULT_BACKEND=${GLANCE_DEFAULT_BACKEND:-fast}
55 55
 
56 56
 GLANCE_CACHE_DIR=${GLANCE_CACHE_DIR:=$DATA_DIR/glance/cache}
57 57
 
58
+# Full Glance functionality requires running in standalone mode. If we are
59
+# not in uwsgi mode, then we are standalone, otherwise allow separate control.
60
+if [[ "$WSGI_MODE" != "uwsgi" ]]; then
61
+    GLANCE_STANDALONE=True
62
+fi
63
+GLANCE_STANDALONE=${GLANCE_STANDALONE:-False}
64
+
58 65
 # File path for each store specified in GLANCE_MULTIPLE_FILE_STORES, the store
59 66
 # identifier will be appended to this path at runtime. If GLANCE_MULTIPLE_FILE_STORES
60 67
 # has fast,cheap specified then filepath will be generated like $DATA_DIR/glance/fast
... ...
@@ -240,9 +247,10 @@ function configure_glance {
240 240
         iniset $GLANCE_CACHE_CONF DEFAULT cinder_endpoint_template "https://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT/v3/%(project_id)s"
241 241
     fi
242 242
 
243
-    if [[ "$WSGI_MODE" == "uwsgi" ]]; then
243
+    if [[ "$GLANCE_STANDALONE" == False ]]; then
244 244
         write_local_uwsgi_http_config "$GLANCE_UWSGI_CONF" "$GLANCE_UWSGI" "/image"
245 245
     else
246
+        write_local_proxy_http_config glance "http://$GLANCE_SERVICE_HOST:$GLANCE_SERVICE_PORT_INT" "/image"
246 247
         iniset $GLANCE_API_CONF DEFAULT bind_host $GLANCE_SERVICE_LISTEN_ADDRESS
247 248
         iniset $GLANCE_API_CONF DEFAULT workers "$API_WORKERS"
248 249
     fi
... ...
@@ -342,7 +350,7 @@ function start_glance {
342 342
         fi
343 343
     fi
344 344
 
345
-    if [[ "$WSGI_MODE" == "uwsgi" ]]; then
345
+    if [[ "$GLANCE_STANDALONE" == False ]]; then
346 346
         run_process g-api "$(which uwsgi) --procname-prefix glance-api --ini $GLANCE_UWSGI_CONF"
347 347
     else
348 348
         run_process g-api "$GLANCE_BIN_DIR/glance-api --config-dir=$GLANCE_CONF_DIR"