Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion kolla-build.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ template_override = template_overrides.j2
# not supported yet
# patches_path = patches

[glance-api-additions-patches]
type = local
location = patches/glance-api/

[neutron-l3-agent-additions-patches]
type = local
location = patches/neutron-l3-agent/
Expand All @@ -19,4 +23,4 @@ type = local
location = patches/neutron-bgp-dragent/

[profiles]
custom = fluentd,^keystone$,neutron-l3-agent,neutron-bgp-dragent
custom = fluentd,^keystone$,glance-api,neutron-l3-agent,neutron-bgp-dragent
46 changes: 46 additions & 0 deletions patches/glance-api/8c265bb_add_urllib_user_agent_header.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
From 8c265bb5a376e3aed5a59e0b69c4f851a94cc242 Mon Sep 17 00:00:00 2001
From: Mathieu Tortuyaux <mathieu.tortuyaux@gmail.com>
Date: Mon, 05 Jan 2026 14:28:42 +0100
Subject: [PATCH] glance/utils: override urllib 'User-agent' header

Using default urllib 'User-agent' header creates error 403
with CloudFlare in web-download image import.

Change-Id: Ieb9ef2775dc3ebfab46c9cd3b4dc29a5a3ec6093
Closes-Bug: #2137731
Signed-off-by: Mathieu Tortuyaux <mathieu.tortuyaux@gmail.com>
---

diff --git a/glance/async_/flows/ovf_process.py b/glance/async_/flows/ovf_process.py
index 2f3ac15..f8f5042 100644
--- a/glance/async_/flows/ovf_process.py
+++ b/glance/async_/flows/ovf_process.py
@@ -75,7 +75,12 @@
uri = uri.split("file://")[-1]
return open(uri, "rb")

- return urllib.request.urlopen(uri)
+ # Override 'User-agent' header to avoid CloudFlare 403 errors.
+ req = urllib.request.Request(
+ uri,
+ headers={'User-agent': 'glance-client'},
+ )
+ return urllib.request.urlopen(req)

def execute(self, image_id, file_path):
"""
diff --git a/glance/common/scripts/utils.py b/glance/common/scripts/utils.py
index f7c6a9f..bc3d07d 100644
--- a/glance/common/scripts/utils.py
+++ b/glance/common/scripts/utils.py
@@ -148,7 +148,9 @@
# into memory. Some images may be quite heavy.
return open(uri, "rb")

- return urllib.request.urlopen(uri)
+ # Override 'User-agent' header to avoid CloudFlare 403 errors.
+ req = urllib.request.Request(uri, headers={'User-agent': 'glance-client'})
+ return urllib.request.urlopen(req)


class CallbackIterator(object):
1 change: 1 addition & 0 deletions patches/glance-api/series
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8c265bb_add_urllib_user_agent_header.patch
7 changes: 7 additions & 0 deletions template_overrides.j2
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ RUN dnf install -y --enablerepo epel \
&& dnf clean all
{% endblock %}

# glance
{% set glance_base_packages_append = ['patch'] %}
{% block glance_api_footer %}
ADD additions-archive /
RUN bash -c 'while read patch; do patch -d /var/lib/kolla/venv/lib/python3.9/site-packages -p 1 -i /additions/$patch; done < /additions/series'
{% endblock %}

# neutron
{% set neutron_base_packages_append = ['patch'] %}
{% block neutron_l3_agent_footer %}
Expand Down