Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .mvn/extensions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<extensions xmlns="http://maven.apache.org/EXTENSIONS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/EXTENSIONS/1.0.0 http://maven.apache.org/xsd/core-extensions-1.0.0.xsd">
<extension>
<groupId>io.jenkins.tools.incrementals</groupId>
<artifactId>git-changelist-maven-extension</artifactId>
<version>1.4</version>
</extension>
</extensions>
2 changes: 2 additions & 0 deletions .mvn/maven.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-Pconsume-incrementals
-Pmight-produce-incrementals
5 changes: 5 additions & 0 deletions JenkinsWiki.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ termination"

[SpotinstPlugin-Versionhistory]
== Version history
[SpotinstPlugin-Version2.2.16(Mar18,2024)]
=== Version 2.2.16 (Mar 18, 2024)

* AWS stateful groups: ignore stateful instances with no running instance

[SpotinstPlugin-Version2.2.15(Sep26,2023)]
=== Version 2.2.15 (Sep 26, 2023)

Expand Down
13 changes: 8 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>

<artifactId>spotinst</artifactId>
<version>2.2.16-SNAPSHOT</version>
<version>${revision}${changelist}</version>
<packaging>hpi</packaging>

<name>Spotinst plugin</name>
Expand All @@ -33,13 +33,16 @@
</developers>

<scm>
<connection>scm:git:git://github.com/jenkinsci/spotinst-plugin.git</connection>
<developerConnection>scm:git:git@github.com:jenkinsci/spotinst-plugin.git</developerConnection>
<url>https://github.com/jenkinsci/spotinst-plugin</url>
<tag>HEAD</tag>
<connection>scm:git:git://github.com/${gitHubRepo}.git</connection>
<developerConnection>scm:git:git@github.com:${gitHubRepo}.git</developerConnection>
<url>https://github.com/${gitHubRepo}</url>
<tag>${scmTag}</tag>
</scm>

<properties>
<revision>2.2.16</revision>
<changelist>-SNAPSHOT</changelist>
<gitHubRepo>jenkinsci/spotinst-plugin</gitHubRepo>
<jenkins.version>2.222.4</jenkins.version>
<java.level>8</java.level>
</properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,14 +306,15 @@ private void syncGroupStatefulInstances() {

if (statefulInstancesResponse.isRequestSucceed()) {
List<AwsStatefulInstance> statefulInstances = statefulInstancesResponse.getValue();
this.ssiByInstanceId = statefulInstances.stream().collect(
this.ssiByInstanceId = statefulInstances.stream().filter(statefulInstance -> StringUtils.isNotEmpty(
statefulInstance.getInstanceId())).collect(
Collectors.toMap(AwsStatefulInstance::getInstanceId, statefulInstance -> statefulInstance));
LOGGER.info("found {} running stateful instances for group {}", ssiByInstanceId.size(), groupId);
}
else {
LOGGER.error(String.format("Failed to get group %s stateful instances. Errors: %s", groupId,
statefulInstancesResponse.getErrors()));
}

}

private List<SpotinstSlave> handleNewAwsSpots(AwsScaleUpResult scaleUpResult, String label) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ List<SpotinstSlave> scaleUp(ProvisionRequest request) {

@Override
protected BlResponse<Boolean> checkIsStatefulGroup() {
return new BlResponse<>(false);
return new BlResponse<>(Boolean.FALSE);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ List<SpotinstSlave> scaleUp(ProvisionRequest request) {

@Override
protected BlResponse<Boolean> checkIsStatefulGroup() {
return new BlResponse<>(false);
return new BlResponse<>(Boolean.FALSE);
}

@Override
Expand Down
30 changes: 15 additions & 15 deletions src/main/java/hudson/plugins/spotinst/cloud/BaseSpotinstCloud.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public abstract class BaseSpotinstCloud extends Cloud {
private SpotGlobalExecutorOverride globalExecutorOverride;
protected Integer pendingThreshold;
private GroupLockingManager groupLockingManager;
private boolean isStatefulGroup;
private Boolean isStatefulGroup;
//endregion

//region Constructor
Expand Down Expand Up @@ -131,15 +131,7 @@ public BaseSpotinstCloud(String groupId, String labelString, String idleTerminat
groupLockingManager = new GroupLockingManager(groupId, accountId);
groupLockingManager.syncGroupController();

BlResponse<Boolean> checkIsStatefulGroupResponse = checkIsStatefulGroup();

if (checkIsStatefulGroupResponse.isSucceed()) {
this.isStatefulGroup = checkIsStatefulGroupResponse.getResult();
}
else {
LOGGER.warn("failed to get the group's details, currently referring to it as stateless");
this.isStatefulGroup = false;
}
initIsStatefulGroup();
}
//endregion

Expand Down Expand Up @@ -890,6 +882,18 @@ public Boolean removeInstance(String instanceId) {

protected abstract BlResponse<Boolean> checkIsStatefulGroup();

private void initIsStatefulGroup(){
BlResponse<Boolean> isStatefulResponse = checkIsStatefulGroup();

if (isStatefulResponse.isSucceed()) {
isStatefulGroup = isStatefulResponse.getResult();
}
else if (isStatefulGroup == null) {
LOGGER.warn("failed to get the group's details, currently referring to it as stateless");
isStatefulGroup = false;
}
}

public Boolean isStatefulGroup() {
return isStatefulGroup;
}
Expand All @@ -906,11 +910,7 @@ public void syncGroup() {
boolean isCloudReadyForGroupCommunication = isCloudReadyForGroupCommunication();

if (isCloudReadyForGroupCommunication) {
BlResponse<Boolean> isStatefulResponse = checkIsStatefulGroup();

if (isStatefulResponse.isSucceed()) {
this.isStatefulGroup = isStatefulResponse.getResult();
}
initIsStatefulGroup();

syncGroupInstances();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ List<SpotinstSlave> scaleUp(ProvisionRequest request) {

@Override
protected BlResponse<Boolean> checkIsStatefulGroup() {
return new BlResponse<>(false);
return new BlResponse<>(Boolean.FALSE);
}

@Override
Expand Down