Procházet zdrojové kódy

Raise exception on KeyboardInterrupt

Using subprocess with tenacity can lead to issues when a keyboard
interrupt occurs because the logic we have will actually trigger a
retry. This can lead to the inability to stop some of the commands with
a ctrl+c.

Conflicts:
    tripleo_common/image/image_uploader.py

Change-Id: I294910384fc9dd9ca8c7114d08842868909d9e9f
Closes-Bug: #1746724
(cherry picked from commit 9003b7ac5b)
changes/19/704819/1
Alex Schultz před 4 měsíci
rodič
revize
5a93687ab1
1 změnil soubory, kde provedl 17 přidání a 14 odebrání
  1. +17
    -14
      tripleo_common/image/image_uploader.py

+ 17
- 14
tripleo_common/image/image_uploader.py Zobrazit soubor

@@ -258,21 +258,24 @@ class DockerImageUploader(ImageUploader):

LOG.info('Running %s' % ' '.join(cmd))
env = os.environ.copy()
process = subprocess.Popen(cmd, env=env, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)

out, err = process.communicate()
if process.returncode != 0:
not_found_msgs = (
'manifest unknown',
# returned by docker.io
'requested access to the resource is denied'
)
if any(n in err for n in not_found_msgs):
raise ImageNotFoundException('Not found image: %s\n%s' %
try:
process = subprocess.Popen(cmd, env=env, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)

out, err = process.communicate()
if process.returncode != 0:
not_found_msgs = (
'manifest unknown',
# returned by docker.io
'requested access to the resource is denied'
)
if any(n in err for n in not_found_msgs):
raise ImageNotFoundException('Not found image: %s\n%s' %
(image, err))
raise ImageUploaderException('Error inspecting image: %s\n%s' %
(image, err))
raise ImageUploaderException('Error inspecting image: %s\n%s' %
(image, err))
except KeyboardInterrupt:
raise Exception('Action interrupted with ctrl+c')
return json.loads(out)

@staticmethod


Načítá se…
Zrušit
Uložit