From 8772465eccc7bf926a92f3de01a69e2da72eb064 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Thu, 17 Oct 2019 09:54:22 -0700 Subject: [PATCH] Disable namespacing We don't strictly need namespacing in order to have a buildset registry serve as multiple registries. If we don't configure it in zuul-registry itself, and treat dockerhub images as non-namespaced, then both docker and oci configurations can use the same buildset registry. We would configure docker to talk to the registry as normal and it will fetch unqualified image names, but we would set up containers/registries.conf to prepend urls for non-dockerhub registries, and it would not prepend anything for dockerhub. In this way, both configurations can use the same buildset registry. Change-Id: I8af4ea0f5da5ad835384400108250e14a8435656 --- .../{namespaced-conf => conf}/registry.yaml | 0 playbooks/functional-test/docker-buildset.yaml | 8 ++++---- ...andard-compose.yaml => docker-compose.yaml} | 2 +- playbooks/functional-test/docker.yaml | 12 ++++++------ .../functional-test/files/registries.conf | 2 +- .../functional-test/namespaced-compose.yaml | 13 ------------- playbooks/functional-test/podman-buildset.yaml | 18 +++++++++--------- playbooks/functional-test/podman.yaml | 12 ++++++------ .../standard-conf/registry.yaml | 14 -------------- zuul_registry/main.py | 2 +- 10 files changed, 28 insertions(+), 55 deletions(-) rename playbooks/functional-test/{namespaced-conf => conf}/registry.yaml (100%) rename playbooks/functional-test/{standard-compose.yaml => docker-compose.yaml} (86%) delete mode 100644 playbooks/functional-test/namespaced-compose.yaml delete mode 100644 playbooks/functional-test/standard-conf/registry.yaml diff --git a/playbooks/functional-test/namespaced-conf/registry.yaml b/playbooks/functional-test/conf/registry.yaml similarity index 100% rename from playbooks/functional-test/namespaced-conf/registry.yaml rename to playbooks/functional-test/conf/registry.yaml diff --git a/playbooks/functional-test/docker-buildset.yaml b/playbooks/functional-test/docker-buildset.yaml index 29c6648..4f7f1bd 100644 --- a/playbooks/functional-test/docker-buildset.yaml +++ b/playbooks/functional-test/docker-buildset.yaml @@ -20,9 +20,9 @@ register: docker_restart failed_when: docker_restart is failed and not 'Could not find the requested service' in docker_restart.msg -- name: Start the standard registry +- name: Start the registry shell: - cmd: docker-compose -f standard-compose.yaml up -d + cmd: docker-compose up -d chdir: "{{ ansible_user_dir }}/src/opendev.org/zuul/zuul-registry/playbooks/functional-test" - name: Wait for registry to come up @@ -84,9 +84,9 @@ - name: Remove the test image from the local cache command: docker rmi alpine -- name: Stop the standard registry +- name: Stop the registry shell: - cmd: docker-compose -f standard-compose.yaml down + cmd: docker-compose down chdir: "{{ ansible_user_dir }}/src/opendev.org/zuul/zuul-registry/playbooks/functional-test" - name: Clean up docker volumes diff --git a/playbooks/functional-test/standard-compose.yaml b/playbooks/functional-test/docker-compose.yaml similarity index 86% rename from playbooks/functional-test/standard-compose.yaml rename to playbooks/functional-test/docker-compose.yaml index 092fe5e..4d6c45d 100644 --- a/playbooks/functional-test/standard-compose.yaml +++ b/playbooks/functional-test/docker-compose.yaml @@ -6,7 +6,7 @@ services: registry: image: zuul/zuul-registry volumes: - - "./standard-conf/:/conf/:z" + - "./conf/:/conf/:z" - "/tmp/registry-test/tls/:/tls:z" ports: - "9000:9000" diff --git a/playbooks/functional-test/docker.yaml b/playbooks/functional-test/docker.yaml index b19b63b..b539336 100644 --- a/playbooks/functional-test/docker.yaml +++ b/playbooks/functional-test/docker.yaml @@ -1,8 +1,8 @@ # Test push and pull from the standard registry -- name: Start the standard registry +- name: Start the registry shell: - cmd: docker-compose -f standard-compose.yaml up -d + cmd: docker-compose up -d chdir: "{{ ansible_user_dir }}/src/opendev.org/zuul/zuul-registry/playbooks/functional-test" - name: Print list of images @@ -19,7 +19,7 @@ - name: Log in to registry command: docker login localhost:9000 -u testuser -p testpass -- name: Push the test image to the standard registry +- name: Push the test image to the registry command: docker push localhost:9000/test/image - name: Remove the test image from the local cache @@ -30,7 +30,7 @@ register: image_list failed_when: "'test/image' in image_list.stdout" -- name: Pull the image from the standard registry +- name: Pull the image from the registry command: docker pull localhost:9000/test/image - name: Print list of images @@ -46,9 +46,9 @@ - name: Remove the test image from the local cache command: docker rmi localhost:9000/test/image -- name: Stop the standard registry +- name: Stop the registry shell: - cmd: docker-compose -f standard-compose.yaml down + cmd: docker-compose down chdir: "{{ ansible_user_dir }}/src/opendev.org/zuul/zuul-registry/playbooks/functional-test" - name: Clean up docker volumes diff --git a/playbooks/functional-test/files/registries.conf b/playbooks/functional-test/files/registries.conf index 95ffdf4..60dd178 100644 --- a/playbooks/functional-test/files/registries.conf +++ b/playbooks/functional-test/files/registries.conf @@ -5,7 +5,7 @@ prefix = "docker.io" location = "docker.io" [[registry.mirror]] -location = "localhost:9000/docker.io" +location = "localhost:9000" [[registry.mirror]] location = "docker.io" diff --git a/playbooks/functional-test/namespaced-compose.yaml b/playbooks/functional-test/namespaced-compose.yaml deleted file mode 100644 index 487ed70..0000000 --- a/playbooks/functional-test/namespaced-compose.yaml +++ /dev/null @@ -1,13 +0,0 @@ -# Version 2 is the latest that is supported by docker-compose in -# Ubuntu Xenial. -version: '2' - -services: - registry: - image: zuul/zuul-registry - volumes: - - "./namespaced-conf/:/conf/:z" - - "/tmp/registry-test/storage/:/storage:z" - - "/tmp/registry-test/tls/:/tls:z" - ports: - - "9000:9000" diff --git a/playbooks/functional-test/podman-buildset.yaml b/playbooks/functional-test/podman-buildset.yaml index 10e3ba8..47c6776 100644 --- a/playbooks/functional-test/podman-buildset.yaml +++ b/playbooks/functional-test/podman-buildset.yaml @@ -6,9 +6,9 @@ src: files/registries.conf become: true -- name: Start the namespaced registry +- name: Start the registry shell: - cmd: docker-compose -f namespaced-compose.yaml up -d + cmd: docker-compose up -d chdir: "{{ ansible_user_dir }}/src/opendev.org/zuul/zuul-registry/playbooks/functional-test" - name: Wait for registry to come up @@ -35,13 +35,13 @@ content: "{{ new_user_config | to_nice_json }}" dest: "/run/user/{{ ansible_user_uid }}/auth.json" -- name: Copy the test image into the buildset registry +- name: Copy the test image into the registry command: > skopeo copy --dest-creds testuser:testpass docker-archive:{{ workspace }}/test.img - docker://localhost:9000/docker.io/test/image:latest + docker://localhost:9000/test/image:latest -- name: Copy the test image into the buildset registry +- name: Copy the test image into the registry command: > skopeo copy --dest-creds testuser:testpass docker-archive:{{ workspace }}/test.img @@ -55,7 +55,7 @@ - "'test/quay-image' in image_list.stdout" - "'alpine' in image_list.stdout" -- name: Pull the shadowed docker image from the buildset registry +- name: Pull the shadowed docker image from the registry command: podman pull test/image - name: Print list of images @@ -66,7 +66,7 @@ - name: Remove the test image from the local cache command: podman rmi docker.io/test/image -- name: Pull the shadowed quay image from the buildset registry +- name: Pull the shadowed quay image from the registry command: podman pull quay.io/test/quay-image - name: Print list of images @@ -104,9 +104,9 @@ - name: Remove the test image from the local cache command: podman rmi quay.io/0xff/alpine-sshd -- name: Stop the namespaced registry +- name: Stop the registry shell: - cmd: docker-compose -f namespaced-compose.yaml down + cmd: docker-compose down chdir: "{{ ansible_user_dir }}/src/opendev.org/zuul/zuul-registry/playbooks/functional-test" - name: Clean up docker volumes diff --git a/playbooks/functional-test/podman.yaml b/playbooks/functional-test/podman.yaml index 4f25cde..33054d9 100644 --- a/playbooks/functional-test/podman.yaml +++ b/playbooks/functional-test/podman.yaml @@ -1,8 +1,8 @@ # Test push and pull from the standard registry -- name: Start the standard registry +- name: Start the registry shell: - cmd: docker-compose -f standard-compose.yaml up -d + cmd: docker-compose up -d chdir: "{{ ansible_user_dir }}/src/opendev.org/zuul/zuul-registry/playbooks/functional-test" - name: Print list of images @@ -19,7 +19,7 @@ - name: Log in to registry command: podman login localhost:9000 -u testuser -p testpass -- name: Push the test image to the standard registry +- name: Push the test image to the registry command: podman push localhost:9000/test/image - name: Remove the test image from the local cache @@ -33,7 +33,7 @@ register: image_list failed_when: "'test/image' in image_list.stdout" -- name: Pull the image from the standard registry +- name: Pull the image from the registry command: podman pull localhost:9000/test/image - name: Print list of images @@ -46,9 +46,9 @@ register: result failed_when: result.rc != 125 -- name: Stop the standard registry +- name: Stop the registry shell: - cmd: docker-compose -f standard-compose.yaml down + cmd: docker-compose down chdir: "{{ ansible_user_dir }}/src/opendev.org/zuul/zuul-registry/playbooks/functional-test" - name: Clean up podman volumes diff --git a/playbooks/functional-test/standard-conf/registry.yaml b/playbooks/functional-test/standard-conf/registry.yaml deleted file mode 100644 index af97dd5..0000000 --- a/playbooks/functional-test/standard-conf/registry.yaml +++ /dev/null @@ -1,14 +0,0 @@ -registry: - address: '0.0.0.0' - port: 9000 - public-url: https://localhost:9000 - tls-cert: /tls/cert.pem - tls-key: /tls/cert.key - secret: test_token_secret - users: - - name: testuser - pass: testpass - access: write - storage: - driver: filesystem - root: /storage diff --git a/zuul_registry/main.py b/zuul_registry/main.py index de9454d..18b4817 100644 --- a/zuul_registry/main.py +++ b/zuul_registry/main.py @@ -320,7 +320,7 @@ class RegistryServer: route_map = cherrypy.dispatch.RoutesDispatcher() api = RegistryAPI(self.store, - self.conf.get('namespaced', False), + False, authz) cherrypy.tools.check_auth = authz