Skip to content

Commit

Permalink
handling issue 329 (#386)
Browse files Browse the repository at this point in the history
* handling issue 329

* updating additonal slave terminology
  • Loading branch information
naraharip2017 authored Jul 13, 2023
1 parent 550080c commit b5b4021
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 33 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ automatically scaling the capacity with the load.
* [Setup](#setup)
* [Scaling](#scaling)
* [Groovy](#groovy)
* [Preconfigure Slave](#preconfigure-slave)
* [Preconfigure Agent](#preconfigure-agent)
* [Label Based Configuration (beta)](docs/LABEL-BASED-CONFIGURATION.md)
* [Windows Slave](docs/SETUP-WINDOWS-SLAVE.md)
* [Windows Agent](docs/SETUP-WINDOWS-AGENT.md)
* [Configuration As Code](docs/CONFIGURATION-AS-CODE.md)
* [Development](#development)

Expand Down Expand Up @@ -276,9 +276,9 @@ jenkins.clouds.add(ec2FleetCloud)
jenkins.save()
```

## Preconfigure Slave
## Preconfigure Agent

Sometimes you need to prepare a slave (an EC2 instance) before Jenkins can use it.
Sometimes you need to prepare an agent (an EC2 instance) before Jenkins can use it.
For example, you need to install some software which is required by your builds like Maven, etc.

For those cases you have a few options, described below:
Expand Down Expand Up @@ -313,7 +313,7 @@ launcher can be found [here](https://github.com/jenkinsci/ssh-slaves-plugin/blob
1. Open Jenkins
1. Go to ```Manage Jenkins > Configure System```
1. Find proper fleet configuration and click ```Advanced...``` for SSH Launcher
1. Add checking command into field ```Prefix Start Slave Command```
1. Add checking command into field ```Prefix Start Agent Command```
- example ```java -version && ```
1. To apply for existing instances, restart Jenkins or Delete Nodes from Jenkins so they will be reconnected

Expand Down
10 changes: 5 additions & 5 deletions docs/SETUP-WINDOWS-SLAVE.md → docs/SETUP-WINDOWS-AGENT.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Windows Slave with EC2 Fleet Plugin
# Windows Agent with EC2 Fleet Plugin

This guide describes how to configure Windows EC2 Instance to be good for run
as Slave for EC2 Fleet Jenkins Plugin. At the end of this guide you
as Agent for EC2 Fleet Jenkins Plugin. At the end of this guide you
will get AWS EC2 AMI (Image) which could be used for Auto Scaling Group
or EC2 Spot Fleet to run Windows slaves.
or EC2 Spot Fleet to run Windows agents.

**Big thanks to @Michenux for help to find all details**

**Note** Before this, please consider to use Windows OpenSSH
https://github.com/jenkinsci/ssh-slaves-plugin/blob/master/doc/CONFIGURE.md#launch-windows-slaves-using-microsoft-openssh

**Note** This guide uses Windows DCOM technology (not open ssh) it doesn't work over NAT,
so Jenkins Master EC2 Instance should be placed in same VPC as Slaves managed by EC2 Fleet Plugin.
so Jenkins Master EC2 Instance should be placed in same VPC as Agents managed by EC2 Fleet Plugin.

## Run EC2 Instance with Windows

Expand Down Expand Up @@ -93,7 +93,7 @@ so Jenkins Master EC2 Instance should be placed in same VPC as Slaves managed by

1. Goto to AWS Console and create image of preconfigured instance

## Before using this AMI for Jenkins Slave
## Before using this AMI for Jenkins Agent

- Make sure you required traffic could go to Windows from Jenkins. You can find
required ports above in ```Configure Firewall``` section
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* * 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 slave was disconnected
* 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>
Expand Down Expand Up @@ -55,9 +55,9 @@ public EC2FleetAutoResubmitComputerLauncher(final ComputerLauncher launcher) {
* <p>
* EC2 Fleet plugin overrides this method to detect jobs which were failed because of
* EC2 instance was terminated/stopped. It could be manual stop or because of Spot marked.
* In all cases as soon as job aborted because of broken connection and slave is offline
* In all cases as soon as job aborted because of broken connection and agent is offline
* it will try to resubmit aborted job back to the queue, so user doesn't need to do that manually
* and another slave could take it.
* and another agent could take it.
* <p>
* Implementation details
* <p>
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/amazon/jenkins/ec2fleet/EC2FleetCloud.java
Original file line number Diff line number Diff line change
Expand Up @@ -708,14 +708,14 @@ public void run() {
warning(e, "Failed to tag new instances: %s", newFleetInstances.keySet());
}

// addNewSlave will call addNode which calls queue lock.
// addNewAgent will call addNode which calls queue lock.
// We speed this up by getting one lock for all nodes to add
Queue.withLock(new Runnable() {
@Override
public void run() {
try {
for (final Instance instance : newFleetInstances.values()) {
addNewSlave(ec2, instance, updatedState);
addNewAgent(ec2, instance, updatedState);
}
} catch (final Exception ex) {
warning(ex, "Unable to set label on node");
Expand Down Expand Up @@ -825,7 +825,7 @@ private void removeNode(final String instanceId) {
* @param ec2 ec2 client
* @param instance instance
*/
private void addNewSlave(final AmazonEC2 ec2, final Instance instance, FleetStateStats stats) throws Exception {
private void addNewAgent(final AmazonEC2 ec2, final Instance instance, FleetStateStats stats) throws Exception {
final String instanceId = instance.getInstanceId();

// instance state check enabled and not running, skip adding
Expand Down Expand Up @@ -862,7 +862,7 @@ private void addNewSlave(final AmazonEC2 ec2, final Instance instance, FleetStat
final EC2FleetAutoResubmitComputerLauncher computerLauncher = new EC2FleetAutoResubmitComputerLauncher(
computerConnector.launch(address, TaskListener.NULL));
final Node.Mode nodeMode = restrictUsage ? Node.Mode.EXCLUSIVE : Node.Mode.NORMAL;
final EC2FleetNode node = new EC2FleetNode(instanceId, "Fleet slave for " + instanceId,
final EC2FleetNode node = new EC2FleetNode(instanceId, "Fleet agent for " + instanceId,
effectiveFsRoot, effectiveNumExecutors, nodeMode, labelString, new ArrayList<NodeProperty<?>>(),
this, computerLauncher, maxTotalUses);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,14 +546,14 @@ public void run() {
warning(e, "failed to tag new instances %s, skip", newFleetInstances.keySet());
}

// addNewSlave will call addNode which call queue lock
// addNewAgent will call addNode which call queue lock
// we speed up this by getting one lock for all nodes to all
Queue.withLock(new Runnable() {
@Override
public void run() {
try {
for (final Instance instance : newFleetInstances.values()) {
addNewSlave(ec2, instance, entry.getKey(), state);
addNewAgent(ec2, instance, entry.getKey(), state);
}
} catch (final Exception ex) {
warning(ex, "Unable to set label on node");
Expand Down Expand Up @@ -612,7 +612,7 @@ private void init() {
states = new HashMap<>();
}

private void addNewSlave(
private void addNewAgent(
final AmazonEC2 ec2, final Instance instance, final String labelString, final State state) throws Exception {
final String instanceId = instance.getInstanceId();

Expand Down Expand Up @@ -651,7 +651,7 @@ private void addNewSlave(
computerConnector.launch(address, TaskListener.NULL));
final Node.Mode nodeMode = restrictUsage ? Node.Mode.EXCLUSIVE : Node.Mode.NORMAL;
//TODO: Add maxTotalUses to EC2FleetLabelCloud similar to EC2FleetCloud
final EC2FleetNode node = new EC2FleetNode(instanceId, "Fleet slave for " + instanceId,
final EC2FleetNode node = new EC2FleetNode(instanceId, "Fleet agent for " + instanceId,
effectiveFsRoot, effectiveNumExecutors, nodeMode, labelString, new ArrayList<NodeProperty<?>>(),
this, computerLauncher, -1);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public class EC2FleetNodeComputer extends SlaveComputer implements EC2FleetCloud
private volatile AbstractEC2FleetCloud cloud;
private boolean isMarkedForDeletion;

public EC2FleetNodeComputer(final Slave slave, @Nonnull final String name, @Nonnull final AbstractEC2FleetCloud cloud) {
super(slave);
public EC2FleetNodeComputer(final Slave agent, @Nonnull final String name, @Nonnull final AbstractEC2FleetCloud cloud) {
super(agent);
this.name = name;
this.cloud = cloud;
this.isMarkedForDeletion = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<p>
<b>Note:</b> Due to Jenkins organization,
Build Executor Status section in Jenkins UI could show old cloud name
for slaves. To fix that, just wait until slaves are recreated (could be long)
or delete the slave (will not delete underlying EC2 instances).
Deleting a slave agent will cause the plugin to recreate it with correct cloud name.
for agents. To fix that, just wait until agents are recreated (could be long)
or delete the agent (will not delete underlying EC2 instances).
Deleting an agent will cause the plugin to recreate it with correct cloud name.
</p>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class EC2FleetAutoResubmitComputerLauncherTest {
private Queue.Executable executable2;

@Mock
private Slave slave;
private Slave agent;

@Mock
private EC2FleetNodeComputer computer;
Expand Down Expand Up @@ -95,7 +95,7 @@ public void before() {
when(Jenkins.get()).thenReturn(jenkins);
when(Queue.getInstance()).thenReturn(queue);

when(slave.getNumExecutors()).thenReturn(1);
when(agent.getNumExecutors()).thenReturn(1);

when(fleetNode.getDisplayName()).thenReturn("fleet node name");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
public class EC2FleetNodeComputerTest {

@Mock
private Slave slave;
private Slave agent;

@Mock
private Jenkins jenkins;
Expand All @@ -38,26 +38,26 @@ public void before() {
when(Jenkins.get()).thenReturn(jenkins);
when(Queue.getInstance()).thenReturn(queue);

when(slave.getNumExecutors()).thenReturn(1);
when(agent.getNumExecutors()).thenReturn(1);
}

@Test
public void getDisplayName_should_be_ok_with_init_null_cloud() {
EC2FleetNodeComputer computer = spy(new EC2FleetNodeComputer(slave, "a", null));
EC2FleetNodeComputer computer = spy(new EC2FleetNodeComputer(agent, "a", null));
Assert.assertEquals("unknown fleet a", computer.getDisplayName());
}

@Test
public void getDisplayName_should_be_ok_with_set_null_cloud() {
EC2FleetNodeComputer computer = spy(new EC2FleetNodeComputer(slave, "a", cloud));
EC2FleetNodeComputer computer = spy(new EC2FleetNodeComputer(agent, "a", cloud));
computer.setCloud(null);
Assert.assertEquals("unknown fleet a", computer.getDisplayName());
}

@Test
public void getDisplayName_returns_node_display_name() {
when(cloud.getDisplayName()).thenReturn("a");
EC2FleetNodeComputer computer = spy(new EC2FleetNodeComputer(slave, "n", cloud));
EC2FleetNodeComputer computer = spy(new EC2FleetNodeComputer(agent, "n", cloud));
Assert.assertEquals("a n", computer.getDisplayName());
}

Expand Down

0 comments on commit b5b4021

Please sign in to comment.