@@ -285,11 +285,18 @@ stackhpc_ubuntu_focal_repos:
285285 - " deb {{ stackhpc_repo_ubuntu_focal_security_url }} focal-security main universe"
286286 - " deb {{ stackhpc_repo_ubuntu_cloud_archive_url }} focal-updates/{{ openstack_release }} main"
287287
288+ # Whether to revert to the upstream mirrors in built Kolla container images.
289+ stackhpc_kolla_clean_up_repo_mirrors : true
290+
288291# Dict mapping Jinja2 block names in kolla's Docker images to their contents.
289292kolla_build_blocks :
290293 base_header : |
291294 {% if kolla_base_distro in ['centos', 'rocky'] %}
292295 RUN \
296+ {% if stackhpc_kolla_clean_up_repo_mirrors | bool %}
297+ mkdir -p /etc/yum.repos.d.backup && \
298+ tar -czf /etc/yum.repos.d.backup/repos.tar.gz -C /etc/yum.repos.d . && \
299+ {% endif %}
293300 {% for repo in stackhpc_yum_repos %}
294301 sed -i -e '/\[{{ repo.tag }}\]/,/^\[/ s/^\(mirrorlist *=.*\)/#\1/g' \
295302 -e '/\[{{ repo.tag }}\]/,/^\[/ s/^[# ]*\(baseurl *=.*\)/#\1/g' \
@@ -302,6 +309,10 @@ kolla_build_blocks:
302309 {# fixme #}
303310 {% if kolla_base_distro in ['centos', 'rocky'] %}
304311 && \
312+ {% if stackhpc_kolla_clean_up_repo_mirrors | bool %}
313+ tar -xzf /etc/yum.repos.d.backup/repos.tar.gz -C /etc/yum.repos.d && \
314+ tar -czf /etc/yum.repos.d.backup/repos.tar.gz -C /etc/yum.repos.d . && \
315+ {% endif %}
305316 {% for repo in base_centos_repo_overrides_post_yum_list %}
306317 sed -i -e '/\[{{ repo.tag }}\]/,/^\[/ s/^\(mirrorlist *=.*\)/#\1/g' \
307318 -e '/\[{{ repo.tag }}\]/,/^\[/ s/^[# ]*\(baseurl *=.*\)/#\1/g' \
@@ -311,11 +322,30 @@ kolla_build_blocks:
311322 {% endif %}
312323 base_ubuntu_package_sources_list : |
313324 RUN \
314- rm -f /etc/apt/sources.list && \
325+ mv /etc/apt/sources.list{,.backup} && \
315326 {% for repo in stackhpc_ubuntu_focal_repos %}
316327 echo '{{ repo }}' >> /etc/apt/sources.list {% if not loop.last %} && \
317328 {% endif %}
318329 {% endfor %}
330+ footer : |
331+ {% if stackhpc_kolla_clean_up_repo_mirrors | bool %}
332+ {% if kolla_base_distro == 'centos' %}
333+ RUN \
334+ tar -xzf /etc/yum.repos.d.backup/repos.tar.gz -C /etc/yum.repos.d && \
335+ if grep -r '{{ stackhpc_repo_mirror_url }}' /etc/yum.repos.d; then \
336+ echo "Found repository mirror in Yum repositories"; \
337+ exit 1; \
338+ fi && \
339+ rm -rf /etc/yum.repos.d.backup/
340+ {% else %}
341+ RUN \
342+ mv /etc/apt/sources.list.backup /etc/apt/sources.list && \
343+ if grep -r '{{ stackhpc_repo_mirror_url }}' /etc/apt/sources.list; then \
344+ echo "Found repository mirror in APT repositories"; \
345+ exit 1; \
346+ fi
347+ {% endif %}
348+ {% endif %}
319349 bifrost_base_header : |
320350 ADD additions-archive /
321351 grafana_plugins_install : |
0 commit comments