diff --git a/ocp_resources/resource.py b/ocp_resources/resource.py index 5ed67c9c31..62dc50fe8d 100644 --- a/ocp_resources/resource.py +++ b/ocp_resources/resource.py @@ -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 diff --git a/ocp_resources/virtual_machine_instance.py b/ocp_resources/virtual_machine_instance.py index 1e2e8e0e47..70a7aaabd3 100644 --- a/ocp_resources/virtual_machine_instance.py +++ b/ocp_resources/virtual_machine_instance.py @@ -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): @@ -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