Skip to content

Commit e06e0e0

Browse files
mkundu1Copilotpyansys-ci-bot
authored
feat: Log from container when health-check fails (#4599)
## Context When the initial health checks fails while launching Fluent, that usually means Fluent has encountered an error during the startup. The Fluent error is recorded in the Fluent transcript which cannot be accessed easily if we are running on a remote machine (like github runner). ## Change Summary If we are launching a Fluent container, the Fluent transcript is also copied to the container log. In this PR, the container error log is also logged in PyFluent when the initial health checks fails. Following is an example of pyfluent session when a wrong license server is set: ``` (.venv) mkundu@AAPAomeLhXO1rdt:~/devel/pyfluent$ export ANSYSLMD_LICENSE_FILE=1055@XYZ (.venv) mkundu@AAPAomeLhXO1rdt:~/devel/pyfluent$ python Python 3.12.3 (main, Aug 14 2025, 17:47:21) [GCC 13.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import ansys.fluent.core as pyfluent >>> solver = pyfluent.launch_fluent(start_container=True) pyfluent.launcher WARNING: Configuring Fluent container to mount to /home/mkundu/devel/pyfluent, with this path available as /home/container/workdir for the Fluent session running inside the container. pyfluent.general ERROR: Error reported from Fluent: pyfluent.general ERROR: Unexpected license problem; exiting. ============================================================================== Stack backtrace generated for process id 163 on signal 11 : 1000000: fluent() [0x924a30] 1000000: /lib64/libc.so.6(+0x4e5b0) [0x7f4b464915b0] <... more Fluent error lines ...> ============================================================================== Stack backtrace generated for process id 163 on signal 6 : Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/mkundu/devel/pyfluent/src/ansys/fluent/core/utils/deprecate.py", line 136, in wrapper return deprecated_func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ <... more PyFluent error lines ...> File "/home/mkundu/devel/pyfluent/src/ansys/fluent/core/services/interceptors.py", line 164, in _intercept_call raise new_ex from None RuntimeError: Deadline Exceeded >>> ``` ## Rationale For Fluent containers, we know the container id, so we can get the log. However, there is no good solution for standalone Fluent case as the transcript file name cannot be deterministically inferred from PyFluent. ## Impact This came up while triaging a container launch failure in a remote machine and will help such triaging in future. --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: pyansys-ci-bot <[email protected]>
1 parent c23cfd0 commit e06e0e0

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

doc/changelog.d/4599.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Log from container when health-check fails

src/ansys/fluent/core/fluent_connection.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,15 @@ def __init__(
451451
# throws, we should not proceed.
452452
# TODO: Show user-friendly error message.
453453
if pyfluent.config.check_health:
454-
self._health_check.check_health()
454+
try:
455+
self._health_check.check_health()
456+
except RuntimeError:
457+
if inside_container:
458+
logger.error("Error reported from Fluent:")
459+
logger.error(
460+
container.logs(stdout=False).decode("utf-8", errors="replace")
461+
)
462+
raise
455463

456464
self._slurm_job_id = slurm_job_id
457465

0 commit comments

Comments
 (0)