jenkinsci / jenkinsci/ec2-plugin

[JENKINS-61304] EC2 Plugin terminates instances temporarily offline

Open
#1,741 2 comments 0 reactions 0 assignees View on GitHub
component:ec2-plugin imported-jira-issue priority:minor resolution:unresolved
Dominant language
Java
Stars
292
Forks
709
Avg merge
3d 16h
Merged PRs (30d)
4

Description

The latest version of the plugin added code to catch instances that were started, and then failed to connect to Jenkins. Previously such instances would stay up forever incurring unnecessary costs. The code block that adds this functionality is: https://github.com/jenkinsci/ec2-plugin/blob/master/src/main/java/hudson/plugins/ec2/EC2RetentionStrategy.java#L167-L185

 

Note hos whe termination branch is guarded by the clause `computer.isOffline()` which is unfortunately too broad. Looking up the definition of `computer.isOffline()` yields this code:

{{ @​Exported public boolean isOffline() {}}

return temporarilyOffline || getChannel()==null;

}

 

This reveals that temporarilyOffline is considered too: as a result an instance that has sucessfully connected, but is, for example, under temporary maintenance will be abruptly terminated by the plugin.

AFAICT there is no simple workaround, besides perhaps rewriting `if (computer.isOffline()){` to `if (computer.getChannel()==null){`

 

I'll try to submit a patch asap

---
Originally reported by unicolet, imported from: EC2 Plugin terminates instances temporarily offline


  • assignee: thoulen
  • status: Open
  • priority: Minor
  • component(s): ec2-plugin
  • resolution: Unresolved
  • votes: 1
  • watchers: 2
  • imported: 2025-12-06

Raw content of original issue

The latest version of the plugin added code to catch instances that were started, and then failed to connect to Jenkins. Previously such instances would stay up forever incurring unnecessary costs. The code block that adds this functionality is: https://github.com/jenkinsci/ec2-plugin/blob/master/src/main/java/hudson/plugins/ec2/EC2RetentionStrategy.java#L167-L185

 

Note hos whe termination branch is guarded by the clause `computer.isOffline()` which is unfortunately too broad. Looking up the definition of `computer.isOffline()` yields this code:

{{ @Exported public boolean isOffline() {}}
return temporarilyOffline || getChannel()==null;
}

 

This reveals that temporarilyOffline is considered too: as a result an instance that has sucessfully connected, but is, for example, under temporary maintenance will be abruptly terminated by the plugin.

AFAICT there is no simple workaround, besides perhaps rewriting `if (computer.isOffline()){` to `if (computer.getChannel()==null){`

 

I'll try to submit a patch asap

environment

```
Jenkins 2.204.2

EC2 Plugin 1.49.1
```

Contributor guide

Open the contributing guide

Research direction

Start in src/main/java/hudson/plugins/ec2/EC2RetentionStrategy.java at the termination branch around lines 167-185. Compare the use of computer.isOffline() with the Jenkins Computer.isOffline() definition quoted in the issue, especially temporarilyOffline versus getChannel(). Done means temporarily offline connected instances are not terminated, while instances without a channel still are.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, java
Domain
cloud, devops
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.