Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Java 11 #49

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
416 changes: 394 additions & 22 deletions pom.xml

Large diffs are not rendered by default.

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>
95 changes: 53 additions & 42 deletions src/test/java/hudson/plugins/spotinst/SpotinstCloudTest.java

Large diffs are not rendered by default.