diff options
author | Nisha Agarwal <agarwalnisha1980@gmail.com> | 2022-09-27 12:04:55 +0000 |
---|---|---|
committer | Nisha Agarwal <agarwalnisha1980@gmail.com> | 2022-09-29 15:13:53 +0000 |
commit | ca54c4df26071937599529857dfe0dda33ca743e (patch) | |
tree | d2226c48ff851152e26b79c9133ef25a9dd97f25 | |
parent | bb6662f1efc8ab1a9eacd3c7b80b9b0bef250e11 (diff) | |
download | ironic-ca54c4df26071937599529857dfe0dda33ca743e.tar.gz |
Fix the anaconda deploy for the ISO mounted
Fix the anaconda deploy for the ISO mounted
on a webserver.
Story: 2010322
Task: 46429
Change-Id: I2860faa7322116ffef1255709fe12f806257b069
-rw-r--r-- | ironic/common/images.py | 26 | ||||
-rw-r--r-- | ironic/tests/unit/common/test_images.py | 3 | ||||
-rw-r--r-- | releasenotes/notes/fix_anaconda-70f4268edc255ff4.yaml | 5 |
3 files changed, 22 insertions, 12 deletions
diff --git a/ironic/common/images.py b/ironic/common/images.py index 2b52b789b..aa883ada3 100644 --- a/ironic/common/images.py +++ b/ironic/common/images.py @@ -657,10 +657,24 @@ def is_source_a_path(ctx, image_source): # NOTE(TheJulia): I don't really like this pattern, *but* # the wholedisk image support is similar. return + # NOTE(TheJulia): Files should have been caught almost exclusively + # before with the Content-Length check. + # When the ISO is mounted and the webserver mount point url is + # checked here, it has both 'Content-Length' and 'Content-Type' + # due to which it always returns False. Hence switched the conditions. + if ('Content-Type' in headers + and str(headers['Content-Type']).startswith('text/html')): + LOG.debug('Evaluated %(url)s to determine if it is a URL to a path ' + 'or a file. A Content-Type header was returned with a text ' + 'content, which suggests a file list was returned.', + {'url': image_source}) + return True # When issuing a head request, folders have no length # A list can be generated by the server.. This is a solid # hint. - if 'Content-Length' in headers: + if ('Content-Type' in headers + and (str(headers['Content-Type']) != 'text/html') + and 'Content-Length' in headers): LOG.debug('Evaluated %(url)s to determine if it is a URL to a path ' 'or a file. A Content-Length header was returned ' 'suggesting file.', @@ -668,16 +682,6 @@ def is_source_a_path(ctx, image_source): # NOTE(TheJulia): Files on a webserver have a length which is returned # when headres are queried. return False - if ('Content-Type' in headers - and str(headers['Content-Type']).startswith('text') - and 'Content-Length' not in headers): - LOG.debug('Evaluated %(url)s to determine if it is a URL to a path ' - 'or a file. A Content-Type header was returned with a text ' - 'content, which suggests a file list was returned.', - {'url': image_source}) - return True - # NOTE(TheJulia): Files should have been caught almost exclusively - # before with the Content-Length check. if image_source.endswith('/'): # If all else fails, looks like a URL, and the server didn't give # us any hints. diff --git a/ironic/tests/unit/common/test_images.py b/ironic/tests/unit/common/test_images.py index dd782c687..5530feb38 100644 --- a/ironic/tests/unit/common/test_images.py +++ b/ironic/tests/unit/common/test_images.py @@ -318,7 +318,8 @@ class IronicImagesTestCase(base.TestCase): autospec=True) def test_is_source_a_path_content_length(self, validate_mock): mock_response = mock.Mock() - mock_response.headers = {'Content-Length': 1} + mock_response.headers = {'Content-Length': 1, + 'Content-Type': 'text/plain'} validate_mock.return_value = mock_response self.assertFalse(images.is_source_a_path('context', 'http://foo/bar/')) validate_mock.assert_called_once_with(mock.ANY, 'http://foo/bar/') diff --git a/releasenotes/notes/fix_anaconda-70f4268edc255ff4.yaml b/releasenotes/notes/fix_anaconda-70f4268edc255ff4.yaml new file mode 100644 index 000000000..3882a2820 --- /dev/null +++ b/releasenotes/notes/fix_anaconda-70f4268edc255ff4.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Fixes the URL based anaconda deployment for parsing the given ``image_source`` + url. |