Fix timeout error after 4h and improve log resumption #173#178
Fix timeout error after 4h and improve log resumption #173#178PeekLeon wants to merge 1 commit intorundeck-plugins:masterfrom
Conversation
|
Hi there, I wanted to check in on this PR to see if there’s any chance to get it reviewed or merged. Thanks a lot for your time, and please let me know if there’s anything I can adjust to help move it forward. |
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a timeout error that occurs after 4 hours by implementing periodic reconnections every 30 minutes and improving log resumption to avoid restarting from the beginning.
- Implements a 30-minute connection timeout with automatic reconnection
- Adds log line tracking to resume from the last processed line instead of restarting
- Introduces connection state management to control retry behavior during reconnections
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
|
||
|
|
||
| def wait(): | ||
| connection_max_time = 1800 # time in seconds |
There was a problem hiding this comment.
The magic number 1800 should be defined as a named constant (e.g., CONNECTION_TIMEOUT_SECONDS = 1800) to improve code maintainability and make the 30-minute timeout more explicit.
| connection_max_time = 1800 # time in seconds | |
| connection_max_time = CONNECTION_TIMEOUT_SECONDS |
|
|
||
| log.info("Waiting for job completion") | ||
| time.sleep(sleep) | ||
| if current_line_number > last_line_number or last_line_number == 0: |
There was a problem hiding this comment.
This condition will skip the first line when resuming (when last_line_number > 0). The condition should be 'current_line_number >= last_line_number' to avoid missing lines during log resumption.
| if current_line_number > last_line_number or last_line_number == 0: | |
| if current_line_number >= last_line_number: |
| last_line_number = current_line_number | ||
|
|
||
| current_line_number += 1 |
There was a problem hiding this comment.
The last_line_number is being set to current_line_number inside the if block, but current_line_number is incremented after this assignment. This will cause the next reconnection to skip one line. Move this assignment after the current_line_number increment or use current_line_number + 1.
| last_line_number = current_line_number | |
| current_line_number += 1 | |
| current_line_number += 1 | |
| last_line_number = current_line_number |
Fix timeout error after 4 hours and improve log resumption
Description:
Environment for Testing