From 13b71f7793ee7ba01c24bae7e963066d18940ec3 Mon Sep 17 00:00:00 2001
From: "James E. Blair" <jeblair@redhat.com>
Date: Tue, 3 Mar 2020 14:39:01 -0800
Subject: [PATCH] Pull from intermediate registry in image build job

Move the pull-from-intermediate-registry role from the buildset
registry job into the image build job so that we can be more
specific with provides/requires (by attaching them to the leaf
node jobs instead of the registry job).

Change-Id: I86669a039e391b8c67dcb6a3397edd79d7563186
---
 playbooks/buildset-registry/pre-test.yaml | 34 -----------
 playbooks/buildset-registry/pre.yaml      |  4 --
 zuul.d/jobs.yaml                          | 70 +++++------------------
 3 files changed, 15 insertions(+), 93 deletions(-)
 delete mode 100644 playbooks/buildset-registry/pre-test.yaml

diff --git a/playbooks/buildset-registry/pre-test.yaml b/playbooks/buildset-registry/pre-test.yaml
deleted file mode 100644
index 05d45d9..0000000
--- a/playbooks/buildset-registry/pre-test.yaml
+++ /dev/null
@@ -1,34 +0,0 @@
-- hosts: all
-  tasks:
-    - name: Install docker
-      include_role:
-        name: install-docker
-    - name: Open the IPv4 port for the buildset registry
-      become: true
-      iptables:
-        action: insert
-        chain: openstack-INPUT
-        destination_port: '5000:5001'
-        jump: ACCEPT
-        match: tcp
-        ctstate: NEW
-        protocol: tcp
-        ip_version: ipv4
-    - name: Open the IPv6 port for the buildset registry
-      become: true
-      iptables:
-        action: insert
-        chain: openstack-INPUT
-        destination_port: '5000:5001'
-        jump: ACCEPT
-        match: tcp
-        ctstate: NEW
-        protocol: tcp
-        ip_version: ipv6
-    - name: Run buildset registry (if not already running)
-      when: buildset_registry is not defined
-      include_role:
-        name: run-buildset-registry
-    - name: Use buildset registry
-      include_role:
-        name: use-buildset-registry
diff --git a/playbooks/buildset-registry/pre.yaml b/playbooks/buildset-registry/pre.yaml
index 014429f..05d45d9 100644
--- a/playbooks/buildset-registry/pre.yaml
+++ b/playbooks/buildset-registry/pre.yaml
@@ -32,7 +32,3 @@
     - name: Use buildset registry
       include_role:
         name: use-buildset-registry
-
-- hosts: localhost
-  roles:
-    - pull-from-intermediate-registry
diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml
index 50321c7..1566124 100644
--- a/zuul.d/jobs.yaml
+++ b/zuul.d/jobs.yaml
@@ -142,60 +142,6 @@
           +v5Gg5Wb07OWvBjg0jcL9IvNwQXgWh39y4uq4TmKcYXHL6RnICtN5Hp4Gc7xDxNvp2+uC
           Na/OOailVlvkWMcpO/l77/qFtNXoRxFTDWYqp5rE3fGmdq09hCiflFWgMMre08=
 
-- job:
-    name: opendev-buildset-registry-test
-    description: |
-      Starts a buildset registry which interacts with the intermediate
-      CI registry to share speculative container images between
-      projects.
-
-      Configure any jobs which require the use of a buildset registry
-      to depend on this job using the "dependencies" job attribute.
-
-      This job will pause after starting the registry so that it is
-      available to any jobs which depend on it.  Once all such jobs
-      are complete, this job will finish.
-    pre-run: playbooks/buildset-registry/pre-test.yaml
-    run: playbooks/buildset-registry/run.yaml
-    post-run: playbooks/buildset-registry/post.yaml
-    secrets:
-      - secret: opendev-intermediate-registry
-        name: intermediate_registry
-    requires: docker-image
-
-- job:
-    name: opendev-build-docker-image-base
-    parent: opendev-buildset-registry-test
-    description: |
-      This is a parent for an image build job which expects a
-      buildset registry to be running and pulls images from the
-      intermediate registry into it.  It mostly exists so that
-      the intermediate registry secret need not be supplied to the
-      image build playbook.
-    pre-run: playbooks/docker-image/pre.yaml
-    secrets:
-      - secret: opendev-intermediate-registry
-        name: intermediate_registry
-
-- job:
-    name: opendev-build-docker-image-test
-    parent: opendev-build-docker-image-base
-    description: |
-      Starts a buildset registry (if one has not already been started,
-      e.g., by invoking :zuul:job:`opendev-buildset-registry` and
-      specifying it as a dependency) and builds one or more docker
-      images.
-
-      Analog of build-docker-image job, but with a buildset registry.
-
-      This job will pause after starting the registry so that it is
-      available to any jobs which depend on it.  Once all such jobs
-      are complete, this job will finish.
-
-      .. include:: ../../playbooks/docker-image/README.rst
-    run: playbooks/docker-image/run.yaml
-    provides: docker-image
-
 - job:
     name: opendev-buildset-registry
     description: |
@@ -218,8 +164,22 @@
     requires: docker-image
 
 - job:
-    name: opendev-build-docker-image
+    name: opendev-build-docker-image-base
     parent: opendev-buildset-registry
+    description: |
+      This is a parent for an image build job which expects a
+      buildset registry to be running and pulls images from the
+      intermediate registry into it.  It mostly exists so that
+      the intermediate registry secret need not be supplied to the
+      image build playbook.
+    pre-run: playbooks/docker-image/pre.yaml
+    secrets:
+      - secret: opendev-intermediate-registry
+        name: intermediate_registry
+
+- job:
+    name: opendev-build-docker-image
+    parent: opendev-build-docker-image-base
     description: |
       Starts a buildset registry (if one has not already been started,
       e.g., by invoking :zuul:job:`opendev-buildset-registry` and