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
7 changes: 7 additions & 0 deletions ocp_resources/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,12 +677,19 @@ def wait_for_status(
namespace=self.namespace,
)
current_status = None
last_logged_status = None
try:
for sample in samples:
if sample.items:
sample_status = sample.items[0].status
if sample_status:
current_status = sample_status.phase
if current_status != last_logged_status:
last_logged_status = current_status
self.logger.info(
f"Status of {self.kind} {self.name} is {current_status}"
)

if current_status == status:
return

Expand Down
21 changes: 16 additions & 5 deletions ocp_resources/virtual_machine_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ def virt_launcher_pod(self):
else:
return pods[0]

raise ResourceNotFoundError
raise ResourceNotFoundError(
f"VIRT launcher POD not found for {self.kind}:{self.name}"
)

@property
def virt_handler_pod(self):
Expand Down Expand Up @@ -115,17 +117,26 @@ def wait_until_running(self, timeout=TIMEOUT_4MINUTES, logs=True, stop_status=No
TimeoutExpiredError: If VMI failed to run.
"""
try:
self.logger.info(
f"VMI {self.name} status before wait: {self.instance.status.phase}"
)
self.wait_for_status(
status=self.Status.RUNNING, timeout=timeout, stop_status=stop_status
)
except TimeoutExpiredError:
except TimeoutExpiredError as sampler_ex:
if not logs:
raise

virt_pod = self.virt_launcher_pod
if virt_pod:
self.logger.error(f"VMI {self.name} status: {self.instance.status.phase}")
try:
virt_pod = self.virt_launcher_pod
self.logger.error(
f"Status of virt-launcher pod {virt_pod.name}: {virt_pod.status}"
)
self.logger.debug(f"{virt_pod.name} *****LOGS*****")
self.logger.debug(virt_pod.log(container="compute"))
except ResourceNotFoundError as virt_pod_ex:
self.logger.error(virt_pod_ex)
raise sampler_ex

raise

Expand Down