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
159 changes: 117 additions & 42 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.9</version>
<relativePath />
<relativePath/>
</parent>

<artifactId>spotinst</artifactId>
<version>2.2.19-SNAPSHOT</version>
<version>2.2.20-SNAPSHOT</version>
<packaging>hpi</packaging>

<name>Spotinst plugin</name>
Expand All @@ -33,113 +34,187 @@
</developers>

<scm>
<connection>scm:git:git://github.com/jenkinsci/spotinst-plugin.git</connection>
<connection>scm:git:https://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>
</scm>

<properties>
<jenkins.version>2.222.4</jenkins.version>
<java.level>8</java.level>
<jenkins.version>2.426.3</jenkins.version>
<java.level>11</java.level>
<java.version>11</java.version>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.release>11</maven.compiler.release>
<access-modifier.version>1.33</access-modifier.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-2.249.x</artifactId>
<version>13</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5</version>
<version>4.5.14</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.1</version>
<version>4.4.16</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.7.4</version>
<version>2.17.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.7.4</version>
<version>2.17.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.7.4</version>
<version>2.17.0</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.8.4</version>
<version>2.0.2-beta</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>jenkins-test-harness</artifactId>
<version>2182.v0138ccb_c0b_cb_</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>trilead-api</artifactId>
<version>1.0.13</version>
<version>2.142.v748523a_76693</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>ssh-slaves</artifactId>
<version>1.31.3</version>
</dependency>
<version>2.948.vb_8050d697fec</version>
<exclusions>
<exclusion>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>trilead-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>ssh-credentials</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plain-credentials</artifactId>
<version>1.7</version>
<version>179.vc5cb_98f6db_38</version>
<exclusions>
<exclusion>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>credentials</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.4</version>
<scope>compile</scope>
</dependency>
</dependencies>

<repositories>
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
<url>https://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>

<pluginRepositories>
<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
<url>https://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>

<build>
<pluginManagement>
<plugins>
<plugins>
<plugin>
<groupId>org.jenkins-ci.tools</groupId>
<artifactId>maven-hpi-plugin</artifactId>
<version>3.48</version>
</plugin>
<plugin>
<configuration>
<skip>true</skip>
</configuration>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<executions>
<execution>
<phase>none</phase>
</execution>
</executions>
</plugin>
<version>3.0.5</version>
</plugin>
</plugins>
</pluginManagement>

<plugins>
<plugin>
<groupId>org.jenkins-ci.tools</groupId>
<artifactId>maven-hpi-plugin</artifactId>
<version>3.48</version>
</plugin>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.4.1</version>
<dependencies>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>extra-enforcer-rules</artifactId>
<version>1.8.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-maven-plugin</artifactId>
<version>1.19</version>
<executions>
<execution>
<id>check</id>
<phase>test</phase>
<goals>
<goal>check</goal>
</goals>
<configuration>
<signature>
<groupId>org.codehaus.mojo.signature</groupId>
<artifactId>java18</artifactId>
</signature>
</configuration>
</execution>
</executions>
<configuration>
<skip>true</skip>
<signature>
<groupId>org.codehaus.mojo.signature</groupId>
<artifactId>java18</artifactId>
<version>1.0</version>
</signature>
<ignores>java.lang.invoke.MethodHandle</ignores>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>11.0.20</version>
</plugin>
</plugins>
</build>
</project>
4 changes: 2 additions & 2 deletions src/main/java/hudson/plugins/spotinst/api/SpotinstApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
import hudson.plugins.spotinst.model.redis.LockGroupControllerRequest;
import hudson.plugins.spotinst.model.redis.LockGroupControllerResponse;
import jenkins.model.Jenkins;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.http.HttpStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
26 changes: 17 additions & 9 deletions src/main/java/hudson/plugins/spotinst/cloud/AwsSpotinstCloud.java
Original file line number Diff line number Diff line change
Expand Up @@ -298,26 +298,34 @@ protected BlResponse<Boolean> checkIsStatefulGroup() {
ApiResponse<AwsGroup> groupResponse = awsGroupRepo.getGroup(groupId, this.accountId);

if (groupResponse.isRequestSucceed()) {
Boolean result = false;
AwsGroup awsGroup = groupResponse.getValue();
Boolean result = getIsStatefulFromGroup(groupResponse.getValue());

retVal = new BlResponse<>(result);
}
else {
LOGGER.error(String.format("Failed to get group %s. Errors: %s", groupId, groupResponse.getErrors()));
retVal = new BlResponse<>(false);
}

return retVal;
}

private static Boolean getIsStatefulFromGroup(AwsGroup awsGroup) {
boolean retVal = false;

if(awsGroup != null) {
AwsGroupStrategy groupStrategy = awsGroup.getStrategy();

if (groupStrategy != null) {
AwsGroupPersistence groupPersistence = groupStrategy.getPersistence();

if (groupPersistence != null) {
result = BooleanUtils.isTrue(groupPersistence.getShouldPersistPrivateIp()) ||
retVal = BooleanUtils.isTrue(groupPersistence.getShouldPersistPrivateIp()) ||
BooleanUtils.isTrue(groupPersistence.getShouldPersistBlockDevices()) ||
BooleanUtils.isTrue(groupPersistence.getShouldPersistRootDevice()) ||
StringUtils.isNotEmpty(groupPersistence.getBlockDevicesMode());
}
}

retVal = new BlResponse<>(result);
}
else {
LOGGER.error(String.format("Failed to get group %s. Errors: %s", groupId, groupResponse.getErrors()));
retVal = new BlResponse<>(false);
}

return retVal;
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/hudson/plugins/spotinst/cloud/BaseSpotinstCloud.java
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ public Collection<PlannedNode> provision(Label label, int excessWorkload) {
return Collections.emptyList();
}

@Override
public Collection<NodeProvisioner.PlannedNode> provision(CloudState state, int excessWorkload) {
return this.provision(state.getLabel(), excessWorkload);
}

@Override
public boolean canProvision(Label label) {
boolean canProvision = true;
Expand All @@ -193,6 +198,11 @@ public boolean canProvision(Label label) {
return canProvision;
}

@Override
public boolean canProvision(CloudState state) {
return this.canProvision(state.getLabel());
}

@Override
public DescriptorImpl getDescriptor() {
return (DescriptorImpl) super.getDescriptor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import hudson.plugins.spotinst.cloud.AwsSpotinstCloud;
import hudson.slaves.Cloud;
import jenkins.model.Jenkins;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections4.CollectionUtils;

import java.util.*;
import java.util.stream.Collectors;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import hudson.plugins.spotinst.common.GroupLockingManager;
import hudson.plugins.spotinst.common.SpotinstCloudCommunicationState;
import jenkins.model.Jenkins;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections4.CollectionUtils;

import java.util.*;
import java.util.stream.Collectors;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import hudson.plugins.spotinst.jobs.jobSynchronizer.JobSynchronizer;
import hudson.slaves.Cloud;
import jenkins.model.Jenkins;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/index.jelly
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form">
<div>
This plugin allows Jenkins to start agents with the Spot framework and terminate them as they become idle.
</div>
</j:jelly>
Loading