[JENKINS-76151] - Fix EC2 Continuous attempts to connect to stopped instances #1151
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
JENKINS-76151 - Continuous attempts to connect to the stopped instance
After implementing #1142 in Amazon EC2 Plugin 2034.v0a_11fb_792b_ee, there are some issues with instances stopped (not terminated).
With #1142, the system is continously trying to connect to disconnected nodes, independently of its real status.
In case we have configured the EC2 Cloud in pool mode (nodes are not deleted after using, but just stopped after a idle timeout. When a new job is created, these nodes are started again, instead of provisioning new ones), the previous code is continously trying to reconnect with these stopped instances, leading to the node not able to restart, and continous messages in the logs similar to:
Included a new condition in the
hudson.plugins.ec2.EC2RetentionStrategy#attemptReconnectIfOfflinemethod to only try to reconnect in case the instance is already started.With this, the issue we fixed with #1142 is working properly, and it does not crash with stopped instances:
And Instance pool behavior works as previously:
Testing done
Manual tests based on the original issue in #1142 and the current fixing for EC2 stopped agents.
Submitter checklist