Skip to content

Commit 45acd9c

Browse files
committed
ipu: Check if insert fails and retry
Signed-off-by: Salvatore Daniele <[email protected]>
1 parent c882766 commit 45acd9c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

ipu.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,22 @@ def boot_iso_with_redfish(self, iso_path: str) -> None:
349349
self._prepare_imc(extract_server(iso_path))
350350
logger.info("restarting Redfish")
351351
self._restart_redfish()
352+
self._redfish_boot_retry(iso_path)
353+
354+
def _redfish_boot_retry(self, iso_path: str, max_retries: int = 10) -> None:
355+
retries = 0
356+
while True:
357+
try:
358+
self._redfish_boot(iso_path)
359+
break
360+
except Exception as e:
361+
logger.info(f"Encountered exception {e} when booting, retrying... (attempt={retries})")
362+
retries += 1
363+
if retries >= max_retries:
364+
logger.error_and_exit("Redfish boot failed")
365+
time.sleep(5)
366+
367+
def _redfish_boot(self, iso_path: str) -> None:
352368
# W/A delete iso before downloading it if partially downladed
353369
# https://issues.redhat.com/browse/IIC-382
354370
logger.info("Checking if iso needs to be cleaned up")
@@ -376,6 +392,8 @@ def _wait_iso_downloaded(self, iso_path: str) -> None:
376392
rh.ssh_connect("root", password="", discover_auth=False)
377393
loop_count = 0
378394
while True:
395+
if not rh.is_connected():
396+
raise RuntimeError(f"Connection to {rh.hostname} has been dropped, download failed")
379397
result = rh.run("du -b /mnt/imc/acc-os.iso").out.split()
380398
if len(result) == 0:
381399
continue

0 commit comments

Comments
 (0)