Skip to content

Commit 967555e

Browse files
committed
[CI] Trust only infra mirrors
Infra mirrors get their indices rebuilt to avoid broken indices (due to partial update). Unfortunately, this wipes out the cryptographic signatures. Our approach so far was disabling apt security features globally. However, this is not a valid choice for external repos. It hid an issue we introduced with new RabbitMQ repos missing proper keys installed in the image. This caused permanent failures outside of our CI. Our process should be as close as possible to users' experience. This patch makes CI trust only the mirrors that have their indices rebuilt (so infra mirrors). Change-Id: Ic5abc4b87fd76f87aba383abf43e95ba70629fcb (cherry picked from commit c364c8b)
1 parent 29bb43d commit 967555e

File tree

1 file changed

+10
-22
lines changed

1 file changed

+10
-22
lines changed

tests/templates/template_overrides.j2

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,6 @@ RUN echo registry={{ nodepool_npmjs_proxy }} > /etc/npmrc \
1515
&& ln -s /etc/npmrc /usr/etc/npmrc
1616

1717
{% raw %}
18-
{% if base_distro in ['debian', 'ubuntu'] %}
19-
{% endraw %}
20-
21-
# NOTE(hrw): Debian 'buster' and Ubuntu 18.04 refuse to use unsigned repos
22-
RUN echo 'APT::Get::AllowUnauthenticated "true";' > /etc/apt/apt.conf.d/99allow-unauthenticated \
23-
&& echo 'Acquire::AllowInsecureRepositories "true";' > /etc/apt/apt.conf.d/99allow-insecure-repos
24-
25-
{% raw %}
26-
{% endif %}
2718
{% endblock %}
2819

2920
{% block base_centos_repo_overrides_post_copy %}
@@ -64,17 +55,17 @@ RUN sed -i \
6455
{% if base_distro == "debian" %}
6556
{% endraw %}
6657

67-
RUN sed -i -e "s|http://deb.debian.org|http://{{ nodepool_mirror_host }}|" \
68-
-e "s|http://security.debian.org|http://{{ nodepool_mirror_host }}|" \
58+
RUN sed -i -e "s|http://deb.debian.org|[trusted=yes] http://{{ nodepool_mirror_host }}|" \
59+
-e "s|http://security.debian.org|[trusted=yes] http://{{ nodepool_mirror_host }}|" \
6960
/etc/apt/sources.list
7061

7162
{% raw %}
7263
{% elif base_distro == "ubuntu" %}
7364
{% endraw %}
7465

75-
RUN sed -i -e "s|mirror://mirrors.ubuntu.com/mirrors.txt|http://{{ nodepool_mirror_host }}/ubuntu/|" \
76-
-e "s|http://ubuntu-cloud.archive.canonical.com/ubuntu|http://{{ nodepool_mirror_host }}/ubuntu-cloud-archive|" \
77-
-e "s|http://ports.ubuntu.com|http://{{ nodepool_mirror_host }}/ubuntu-ports|" \
66+
RUN sed -i -e "s|mirror://mirrors.ubuntu.com/mirrors.txt|[trusted=yes] http://{{ nodepool_mirror_host }}/ubuntu/|" \
67+
-e "s|http://ubuntu-cloud.archive.canonical.com/ubuntu|[trusted=yes] http://{{ nodepool_mirror_host }}/ubuntu-cloud-archive|" \
68+
-e "s|http://ports.ubuntu.com|[trusted=yes] http://{{ nodepool_mirror_host }}/ubuntu-ports|" \
7869
/etc/apt/sources.list
7970

8071
{% raw %}
@@ -110,20 +101,17 @@ RUN sed -i \
110101
/etc/yum.repos.d/epel*.repo
111102
{% raw %}
112103
{% elif base_package_type == 'deb' %}
113-
{% endraw %}
114-
RUN rm -f /etc/apt/apt.conf.d/99allow-unauthenticated /etc/apt/apt.conf.d/99allow-insecure-repos
115-
{% raw %}
116104
{% if base_distro == "debian" %}
117105
{% endraw %}
118-
RUN sed -i -e "s|http://{{ nodepool_mirror_host }}|http://deb.debian.org|" \
119-
-e "s|http://{{ nodepool_mirror_host }}|http://security.debian.org|" \
106+
RUN sed -i -e "s|\[trusted=yes\] http://{{ nodepool_mirror_host }}|http://deb.debian.org|" \
107+
-e "s|\[trusted=yes\] http://{{ nodepool_mirror_host }}|http://security.debian.org|" \
120108
/etc/apt/sources.list
121109
{% raw %}
122110
{% elif base_distro == "ubuntu" %}
123111
{% endraw %}
124-
RUN sed -i -e "s|http://{{ nodepool_mirror_host }}/ubuntu/|mirror://mirrors.ubuntu.com/mirrors.txt|" \
125-
-e "s|http://{{ nodepool_mirror_host }}/ubuntu-cloud-archive|http://ubuntu-cloud.archive.canonical.com/ubuntu|" \
126-
-e "s|http://{{ nodepool_mirror_host }}/ubuntu-ports|http://ports.ubuntu.com|" \
112+
RUN sed -i -e "s|\[trusted=yes\] http://{{ nodepool_mirror_host }}/ubuntu/|mirror://mirrors.ubuntu.com/mirrors.txt|" \
113+
-e "s|\[trusted=yes\] http://{{ nodepool_mirror_host }}/ubuntu-cloud-archive|http://ubuntu-cloud.archive.canonical.com/ubuntu|" \
114+
-e "s|\[trusted=yes\] http://{{ nodepool_mirror_host }}/ubuntu-ports|http://ports.ubuntu.com|" \
127115
/etc/apt/sources.list
128116
{% raw %}
129117
{% endif %}

0 commit comments

Comments
 (0)