Skip to content

Commit

Permalink
Revert name change (#423)
Browse files Browse the repository at this point in the history
* Reverted small name changes in comments and documentation

* Reverted remaming of EC2Fleet to Fleet

* Reverted EC2Fleet to Fleet name changes. Changed EC2Fleet to EC2EC2Fleet

* Reverted additional EC2Fleet to Fleet changes

* Reverted EC2Fleet name change in EC2FleetLabelCloudConfigurationAsCodeTest

* Fixed setting of ExcessCapacityTerminationPolicy in modify fleet request
  • Loading branch information
GavinBurris42 authored Nov 15, 2023
1 parent 903fcfd commit cd67586
Show file tree
Hide file tree
Showing 82 changed files with 1,037 additions and 1,016 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ import hudson.plugins.sshslaves.verifiers.NonVerifyingKeyVerificationStrategy
import com.cloudbees.plugins.credentials.*
import com.cloudbees.plugins.credentials.domains.Domain
import hudson.model.*
import com.amazon.jenkins.ec2fleet.FleetCloud
import com.amazon.jenkins.ec2fleet.EC2FleetCloud
import jenkins.model.Jenkins
// just modify this config other code just logic
Expand Down Expand Up @@ -249,8 +249,8 @@ BasicSSHUserPrivateKey instanceCredentials = new BasicSSHUserPrivateKey(
"my private key to ssh ec2 for jenkins"
)
// find detailed information about parameters on plugin config page or
// https://github.com/jenkinsci/ec2-fleet-plugin/blob/master/src/main/java/com/amazon/jenkins/ec2fleet/FleetCloud.java
FleetCloud fleetCloud = new FleetCloud(
// https://github.com/jenkinsci/ec2-fleet-plugin/blob/master/src/main/java/com/amazon/jenkins/ec2fleet/EC2FleetCloud.java
EC2FleetCloud ec2FleetCloud = new EC2FleetCloud(
"", // fleetCloudName
null,
awsCredentials.id,
Expand All @@ -277,9 +277,9 @@ FleetCloud fleetCloud = new FleetCloud(
false,
180,
null,
false,
30,
true
true,
new EC2FleetCloud.NoScaler()
)
// get Jenkins instance
Expand Down
12 changes: 6 additions & 6 deletions docs/CONFIGURATION-AS-CODE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

## Properties

### FleetCloud
### EC2FleetCloud

[Definition](https://github.com/jenkinsci/ec2-fleet-plugin/blob/master/src/main/java/com/amazon/jenkins/ec2fleet/FleetCloud.java#L156-L179)
[Definition](https://github.com/jenkinsci/ec2-fleet-plugin/blob/master/src/main/java/com/amazon/jenkins/ec2fleet/EC2FleetCloud.java#L156-L179)

| Property | Type | Required | Description |
|----------------------------|---------|------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------|
Expand Down Expand Up @@ -35,15 +35,15 @@
| cloudStatusIntervalSec | int | no, default ```10``` | |
| noDelayProvision | boolean | no, default ```false``` | |

## FleetLabelCloud
## EC2FleetLabelCloud

More about this type [here](LABEL-BASED-CONFIGURATION.md)

[Definition](https://github.com/jenkinsci/ec2-fleet-plugin/blob/master/src/main/java/com/amazon/jenkins/ec2fleet/FleetLabelCloud.java#L123-L145)
[Definition](https://github.com/jenkinsci/ec2-fleet-plugin/blob/master/src/main/java/com/amazon/jenkins/ec2fleet/EC2FleetLabelCloud.java#L123-L145)

## Examples

### FleetCloud (min set of properties)
### EC2FleetCloud (min set of properties)

```yaml
jenkins:
Expand All @@ -61,7 +61,7 @@ jenkins:
maxSize: 10
```
### FleetCloud (All properties)
### EC2FleetCloud (All properties)
```yaml
jenkins:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import hudson.slaves.Cloud;

public abstract class AbstractFleetCloud extends Cloud {
public abstract class AbstractEC2FleetCloud extends Cloud {

protected AbstractFleetCloud(String name) {
protected AbstractEC2FleetCloud(String name) {
super(name);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/amazon/jenkins/ec2fleet/CloudNames.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static String generateUnique(final String proposedName) {
? Jenkins.get().clouds.stream().map(c -> c.name).collect(Collectors.toSet())
: Collections.emptySet();

if (proposedName.equals(FleetCloud.BASE_DEFAULT_FLEET_CLOUD_ID) || proposedName.equals(FleetLabelCloud.BASE_DEFAULT_FLEET_CLOUD_ID) || usedNames.contains(proposedName)) {
if (proposedName.equals(EC2FleetCloud.BASE_DEFAULT_FLEET_CLOUD_ID) || proposedName.equals(EC2FleetLabelCloud.BASE_DEFAULT_FLEET_CLOUD_ID) || usedNames.contains(proposedName)) {
return proposedName + "-" + generateSuffix();
}

Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/amazon/jenkins/ec2fleet/CloudNanny.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import java.util.logging.Logger;

/**
* {@link CloudNanny} is responsible for periodically running update (i.e. sync-state-with-AWS) cycles for {@link FleetCloud}s.
* {@link CloudNanny} is responsible for periodically running update (i.e. sync-state-with-AWS) cycles for {@link EC2FleetCloud}s.
*/
@Extension
@SuppressWarnings("unused")
Expand All @@ -23,7 +23,7 @@ public class CloudNanny extends PeriodicWork {
private static final Logger LOGGER = Logger.getLogger(CloudNanny.class.getName());

// the map should not hold onto fleet instances to allow deletion of fleets.
private final Map<FleetCloud, AtomicInteger> recurrenceCounters = Collections.synchronizedMap(new WeakHashMap<>());
private final Map<EC2FleetCloud, AtomicInteger> recurrenceCounters = Collections.synchronizedMap(new WeakHashMap<>());

@Override
public long getRecurrencePeriod() {
Expand All @@ -39,8 +39,8 @@ public long getRecurrencePeriod() {
@Override
protected void doRun() {
for (final Cloud cloud : getClouds()) {
if (!(cloud instanceof FleetCloud)) continue;
final FleetCloud fleetCloud = (FleetCloud) cloud;
if (!(cloud instanceof EC2FleetCloud)) continue;
final EC2FleetCloud fleetCloud = (EC2FleetCloud) cloud;

final AtomicInteger recurrenceCounter = getRecurrenceCounter(fleetCloud);

Expand Down Expand Up @@ -70,7 +70,7 @@ private static List<Cloud> getClouds() {
return Jenkins.get().clouds;
}

private AtomicInteger getRecurrenceCounter(FleetCloud fleetCloud) {
private AtomicInteger getRecurrenceCounter(EC2FleetCloud fleetCloud) {
AtomicInteger counter = new AtomicInteger(fleetCloud.getCloudStatusIntervalSec());
// If a counter already exists, return the value, otherwise set the new counter value and return it.
AtomicInteger existing = recurrenceCounters.putIfAbsent(fleetCloud, counter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,31 @@
import java.util.logging.Logger;

/**
* The {@link FleetAutoResubmitComputerLauncher} is responsible for controlling:
* * how {@link FleetNodeComputer}s are launched
* * how {@link FleetNodeComputer}s connect to agents {@link FleetNode}
* The {@link EC2FleetAutoResubmitComputerLauncher} is responsible for controlling:
* * how {@link EC2FleetNodeComputer}s are launched
* * how {@link EC2FleetNodeComputer}s connect to agents {@link EC2FleetNode}
*
* This is wrapper for {@link ComputerLauncher} to get notification when agent was disconnected
* and automatically resubmit {@link hudson.model.Queue.Task} if reason is unexpected termination
* which usually means EC2 instance was interrupted.
* <p>
* This is optional feature, it's enabled by default, but could be disabled by
* {@link FleetCloud#isDisableTaskResubmit()}
* {@link EC2FleetCloud#isDisableTaskResubmit()}
*/
@SuppressWarnings("WeakerAccess")
@ThreadSafe
public class FleetAutoResubmitComputerLauncher extends DelegatingComputerLauncher {
public class EC2FleetAutoResubmitComputerLauncher extends DelegatingComputerLauncher {

private static final Level LOG_LEVEL = Level.INFO;
private static final Logger LOGGER = Logger.getLogger(FleetAutoResubmitComputerLauncher.class.getName());
private static final Logger LOGGER = Logger.getLogger(EC2FleetAutoResubmitComputerLauncher.class.getName());

/**
* Delay which will be applied when job {@link Queue#scheduleInternal(Queue.Task, int, List)}
* rescheduled after offline
*/
private static final int RESCHEDULE_QUIET_PERIOD_SEC = 10;

public FleetAutoResubmitComputerLauncher(final ComputerLauncher launcher) {
public EC2FleetAutoResubmitComputerLauncher(final ComputerLauncher launcher) {
super(launcher);
}

Expand All @@ -72,14 +72,14 @@ public FleetAutoResubmitComputerLauncher(final ComputerLauncher launcher) {
*/
@SuppressFBWarnings(
value = "BC_UNCONFIRMED_CAST",
justification = "to ignore FleetNodeComputer cast")
justification = "to ignore EC2FleetNodeComputer cast")
@Override
public void afterDisconnect(final SlaveComputer computer, final TaskListener listener) {
// according to jenkins docs could be null in edge cases, check ComputerLauncher.afterDisconnect
if (computer == null) return;

// in some multi-thread edge cases cloud could be null for some time, just be ok with that
final AbstractFleetCloud cloud = ((FleetNodeComputer) computer).getCloud();
final AbstractEC2FleetCloud cloud = ((EC2FleetNodeComputer) computer).getCloud();
if (cloud == null) {
LOGGER.warning("Cloud is null for computer " + computer.getDisplayName()
+ ". This should be autofixed in a few minutes, if not please create an issue for the plugin");
Expand Down
Loading

0 comments on commit cd67586

Please sign in to comment.