Run Glance initialization when Glance is enabled, not just registry (v2)

Per [1] Glance registry should not be required to run since Queens.

v2 improves on v1 [2] (now reverted [3]) by applying minor comments
from reviews so far and ensuring nova-live-migration job does not see
a change in behavior and hence does not break [4].
[5] tried to fix the issue but it did only partially, regarding
the database but not the image upload [6].
This patch ensures double cirros image upload does not happen as well.

[1] https://specs.openstack.org/openstack/glance-specs/specs/queens/approved/glance/deprecate-registry.html
[2] https://review.opendev.org/702707
[3] https://review.opendev.org/703131
[4] https://bugs.launchpad.net/devstack/+bug/1860021
[5] https://review.opendev.org/702960
[6] https://bugs.launchpad.net/devstack/+bug/1860021/comments/16

Change-Id: I61538acd6bd4c7b3da26c4084225b220d7d1aa2c
Closes-bug: #1859847
Related-bug: #1860021
diff --git a/stack.sh b/stack.sh
index 089510f..fe71eae 100755
--- a/stack.sh
+++ b/stack.sh
@@ -1155,7 +1155,8 @@
 # Glance
 # ------
 
-if is_service_enabled g-reg; then
+# NOTE(yoctozepto): limited to node hosting the database which is the controller
+if is_service_enabled $DATABASE_BACKENDS && is_service_enabled glance; then
     echo_summary "Configuring Glance"
     init_glance
 fi
@@ -1280,8 +1281,8 @@
 # scripts as userdata.
 # See https://help.ubuntu.com/community/CloudInit for more on ``cloud-init``
 
-if is_service_enabled g-reg; then
-
+# NOTE(yoctozepto): limited to node hosting the database which is the controller
+if is_service_enabled $DATABASE_BACKENDS && is_service_enabled glance; then
     echo_summary "Uploading images"
 
     for image_url in ${IMAGE_URLS//,/ }; do