Don't include URL params in image filename
With AWS pre-signed URLs the credentials/options are passed as URL
params and were so far included in the download filename of the image.
Since the query string can be very long we observed the following
exception:
2025-05-09 07:46:56,647 ERROR zuul.Launcher: Error in upload job
Traceback (most recent call last):
File "/opt/zuul/lib/python3.11/site-packages/zuul/launcher/server.py", line 154, in run
self._run()
File "/opt/zuul/lib/python3.11/site-packages/zuul/launcher/server.py", line 187, in _run
path = self.launcher.downloadArtifact(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/zuul/lib/python3.11/site-packages/zuul/launcher/server.py", line 2011, in downloadArtifact
with open(path, 'wb') as f:
^^^^^^^^^^^^^^^^
OSError: [Errno 36] File name too long: '/tmp/2a98602315ef4c2bbd0e4bb0a91c057d.raw?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=REDACTED%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250509T074613Z&X-Amz-Expires=604800&X-Amz-SignedHeaders=host&X-Amz-Signature=REDACTED'
Fix this issue by parsing the image URL and only using the request path
to determine the file extension.
Change-Id: I3431f3ac2c1a5c594ee240da602fec6d38fa3c68
This commit is contained in:
@@ -504,7 +504,7 @@ class TestLauncher(LauncherBaseTestCase):
|
||||
'artifacts': [
|
||||
{
|
||||
'name': 'raw image',
|
||||
'url': 'http://example.com/getonly.raw',
|
||||
'url': 'http://example.com/getonly.raw?Dummy-Token=foo',
|
||||
'metadata': {
|
||||
'type': 'zuul_image',
|
||||
'image_name': 'debian-local',
|
||||
|
||||
@@ -28,6 +28,7 @@ import subprocess
|
||||
import threading
|
||||
import time
|
||||
import uuid
|
||||
from urllib.parse import urlparse
|
||||
|
||||
import cachetools
|
||||
import mmh3
|
||||
@@ -1987,7 +1988,8 @@ class Launcher:
|
||||
f.write(chunk)
|
||||
|
||||
def downloadArtifact(self, image_build_artifact):
|
||||
ext = image_build_artifact.url.split('.')[-1]
|
||||
url_components = urlparse(image_build_artifact.url)
|
||||
ext = url_components.path.split('.')[-1]
|
||||
path = os.path.join(self.temp_dir, image_build_artifact.uuid)
|
||||
path = f'{path}.{ext}'
|
||||
self.log.info("Downloading artifact %s from %s into %s",
|
||||
|
||||
Reference in New Issue
Block a user