Skip to content

Commit 0599453

Browse files
committed
Restore upstream mirrors in container image package repos
Currently the Kolla container images configure Yum repositories to use pulp-server on SMS Cloud: (nova-compute) $ grep baseurl /etc/yum.repos.d/CentOS-Stream-BaseOS.repo baseurl=http://pulp-server.internal.sms-cloud:8080/pulp/content/centos/8-stream/BaseOS/x86_64/os/20211122T102435 This makes it difficult to install/update packages for debugging issues in customer environments. This change restores Yum repository files at the end of the container image build to point to distribution repositories. It also makes an attempt to do the same for Apt repos, although these are not enabled in Wallaby currently.
1 parent 8383728 commit 0599453

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

etc/kayobe/kolla.yml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,18 @@ stackhpc_ubuntu_focal_repos:
216216
- "deb {{ stackhpc_repo_ubuntu_focal_security_url }} focal-security main universe"
217217
- "deb {{ stackhpc_repo_ubuntu_cloud_archive_url }} focal-updates/wallaby main"
218218

219+
# Whether to revert to the upstream mirrors in built Kolla container images.
220+
stackhpc_kolla_clean_up_repo_mirrors: true
221+
219222
# Dict mapping Jinja2 block names in kolla's Docker images to their contents.
220223
kolla_build_blocks:
221224
base_header: |
222225
{% if kolla_base_distro == 'centos' %}
223226
RUN \
227+
{% if stackhpc_kolla_clean_up_repo_mirrors | bool %}
228+
mkdir -p /etc/yum.repos.d.backup && \
229+
tar -czf /etc/yum.repos.d.backup/repos.tar.gz -C /etc/yum.repos.d . && \
230+
{% endif %}
224231
{% for repo in stackhpc_centos_stream_repos %}
225232
sed -i -e 's/^\(mirrorlist *=.*\)/#\1/g' \
226233
-e 's/^[# ]*\(baseurl *=.*\)/#\1/g' \
@@ -231,11 +238,34 @@ kolla_build_blocks:
231238
base_centos_repo_overrides_post_yum: |
232239
{# fixme #}
233240
&& \
241+
{% if stackhpc_kolla_clean_up_repo_mirrors | bool %}
242+
tar -xzf /etc/yum.repos.d.backup/repos.tar.gz -C /etc/yum.repos.d && \
243+
tar -czf /etc/yum.repos.d.backup/repos.tar.gz -C /etc/yum.repos.d . && \
244+
{% endif %}
234245
{% for repo in stackhpc_centos_stream_repos + stackhpc_epel_repos + stackhpc_centos_additional_repos + stackhpc_third_party_repos %}
235246
sed -i -e 's/^\(mirrorlist *=.*\)/#\1/g' \
236247
-e 's/^[# ]*\(baseurl *=.*\)/#\1/g' \
237248
-e '/#baseurl.*/a baseurl={{ repo.url }}' /etc/yum.repos.d/{{ repo.file }}{% if not loop.last %} &&{% endif %} \
238249
{% endfor %}
250+
footer: |
251+
{% if stackhpc_kolla_clean_up_repo_mirrors | bool %}
252+
{% if kolla_base_distro == 'centos' %}
253+
RUN \
254+
tar -xzf /etc/yum.repos.d.backup/repos.tar.gz -C /etc/yum.repos.d && \
255+
if grep -r '{{ stackhpc_repo_mirror_url }}' /etc/yum.repos.d; then \
256+
echo "Found repository mirror in Yum repositories"; \
257+
exit 1; \
258+
fi && \
259+
rm -rf /etc/yum.repos.d.backup/
260+
{% else %}
261+
# RUN \
262+
# mv /etc/apt/sources.list.backup /etc/apt/sources.list && \
263+
# if grep -r '{{ stackhpc_repo_mirror_url }}' /etc/apt/sources.list; then \
264+
# echo "Found repository mirror in APT repositories"; \
265+
# exit 1; \
266+
# fi
267+
{% endif %}
268+
{% endif %}
239269
# NOTE: The Open vSwitch and OVN packages in Ubuntu Wallaby UCA repository
240270
# are quite old - 2.15 and 20.12 respectively. Pull in these packages from
241271
# the Yoga UCA, which are 2.17 and 22.03, to more closely match the CentOS
@@ -262,7 +292,7 @@ kolla_build_blocks:
262292
# sometimes).
263293
# base_ubuntu_package_sources_list: |
264294
# RUN \
265-
# rm -f /etc/apt/sources.list && \
295+
# mv /etc/apt/sources.list{,.backup} && \
266296
# {% for repo in stackhpc_ubuntu_focal_repos %}
267297
# echo '{{ repo }}' >> /etc/apt/sources.list {% if not loop.last %} && \
268298
# {% endif %}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
fixes:
3+
- |
4+
Upstream package repository mirrors are now restored in Kolla container
5+
images. This makes it possible to install or update packages for debugging
6+
purposes.

0 commit comments

Comments
 (0)