From 8b86c8194b2726dcecbc1487a8f567043828dcde Mon Sep 17 00:00:00 2001
From: Mark Goddard <mark@stackhpc.com>
Date: Tue, 28 Jan 2020 16:39:40 +0000
Subject: [PATCH] CI: Reduce unnecessary gate image builds

Due to regex matching of images, we are currently building quite a few
unnecessary images in CI. Images that can unexpectedly match:

* barbican-keystone-listener
* ironic-neutron-agent
* prometheus-haproxy-exporter
* prometheus-memcached-exporter

This change improves the situation by anchoring matches to the start of
the name. A full solution would be to specify every image required for
each job. This would be quite verbose and require maintenance.

Change-Id: I7387ccd0cb394c54c79bfba8b1c09fce7ee2973e
---
 tools/setup_gate.sh | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/tools/setup_gate.sh b/tools/setup_gate.sh
index 50da83519d..7cee1467d7 100755
--- a/tools/setup_gate.sh
+++ b/tools/setup_gate.sh
@@ -30,45 +30,45 @@ function setup_openstack_clients {
 
 function setup_config {
     if [[ $SCENARIO != "bifrost" ]]; then
-        GATE_IMAGES="cron,fluentd,glance,haproxy,keepalived,keystone,kolla-toolbox,mariadb,memcached,neutron,nova,openvswitch,rabbitmq,horizon,chrony,heat,placement"
+        GATE_IMAGES="^cron,^fluentd,^glance,^haproxy,^keepalived,^keystone,^kolla-toolbox,^mariadb,^memcached,^neutron,^nova-,^openvswitch,^rabbitmq,^horizon,^chrony,^heat,^placement"
     else
         GATE_IMAGES="bifrost"
     fi
 
     if [[ $SCENARIO == "ceph" ]]; then
-        GATE_IMAGES+=",ceph,cinder"
+        GATE_IMAGES+=",^ceph,^cinder"
     fi
 
     if [[ $SCENARIO == "ceph-ansible" ]]; then
-        GATE_IMAGES+=",cinder"
+        GATE_IMAGES+=",^cinder"
     fi
 
     if [[ $SCENARIO == "cinder-lvm" ]]; then
-        GATE_IMAGES+=",cinder,iscsid"
+        GATE_IMAGES+=",^cinder,^iscsid"
         if [[ $BASE_DISTRO != "centos" ]] || [[ $BASE_DISTRO_MAJOR_VERSION -eq 7 ]]; then
-            GATE_IMAGES+=",tgtd"
+            GATE_IMAGES+=",^tgtd"
         fi
     fi
 
     if [[ $SCENARIO == "zun" ]]; then
-        GATE_IMAGES+=",zun,kuryr,etcd,cinder,iscsid"
+        GATE_IMAGES+=",^zun,^kuryr,^etcd,^cinder,^iscsid"
         if [[ $BASE_DISTRO != "centos" ]] || [[ $BASE_DISTRO_MAJOR_VERSION -eq 7 ]]; then
-            GATE_IMAGES+=",tgtd"
+            GATE_IMAGES+=",^tgtd"
         fi
     fi
 
     if [[ $SCENARIO == "scenario_nfv" ]]; then
-        GATE_IMAGES+=",tacker,mistral,redis,barbican"
+        GATE_IMAGES+=",^tacker,^mistral,^redis,^barbican"
     fi
     if [[ $SCENARIO == "ironic" ]]; then
-        GATE_IMAGES+=",dnsmasq,ironic,iscsid"
+        GATE_IMAGES+=",^dnsmasq,^ironic,^iscsid"
     fi
     if [[ $SCENARIO == "masakari" ]]; then
-        GATE_IMAGES+=",masakari"
+        GATE_IMAGES+=",^masakari"
     fi
 
     if [[ $SCENARIO == "mariadb" ]]; then
-        GATE_IMAGES="cron,haproxy,keepalived,kolla-toolbox,mariadb"
+        GATE_IMAGES="^cron,^haproxy,^keepalived,^kolla-toolbox,^mariadb"
     fi
 
     # NOTE(yoctozepto): we cannot build and push at the same time on debian