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

Refresh plugin #53

Merged
merged 1 commit into from
Oct 19, 2020
Merged
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ hs_err_pid*
*.iml
target/*
work/*

aci-deployment.out
140 changes: 77 additions & 63 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>3.42</version>
<version>4.1</version>
</parent>

<artifactId>azure-container-agents</artifactId>
Expand Down Expand Up @@ -42,20 +42,20 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<azuresdk.version>1.19.0</azuresdk.version>
<jackson.version>2.10.0</jackson.version>
<jenkins.version>2.89.4</jenkins.version>
<jenkins.version>2.164.3</jenkins.version>
<java.level>8</java.level>
<findbugs.failOnError>true</findbugs.failOnError>
<findbugs.excludeFilterFile>findbugs-exclude.xml</findbugs.excludeFilterFile>
<maven.javadoc.skip>true</maven.javadoc.skip>
<azure-credentials.version>1.6.1</azure-credentials.version>
<azure-credentials.version>4.0.2</azure-credentials.version>
<kubernetes-client.version>2.3.1</kubernetes-client.version>
<azure-commons.version>1.0.4</azure-commons.version>
<docker-commons.version>1.3.1</docker-commons.version>
<windows-azure-storage.version>1.1.1</windows-azure-storage.version>
</properties>

<dependencies>
<!-- libraries -->
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure</artifactId>
Expand All @@ -65,8 +65,42 @@
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-client</artifactId>
<version>${kubernetes-client.version}</version>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- jenkins plugins -->
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>docker-commons</artifactId>
Expand All @@ -81,6 +115,10 @@
<groupId>com.microsoft.azure</groupId>
<artifactId>azure</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
Expand All @@ -94,75 +132,71 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.4.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>ssh-credentials</artifactId>
<version>1.13</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plain-credentials</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-client</artifactId>
<version>${kubernetes-client.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.26</version>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>jsch</artifactId>
<version>0.1.55.1</version>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.54</version>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>jackson2-api</artifactId>
<version>2.10.3</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>azure-commons</artifactId>
<version>${azure-commons.version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>azure-commons-core</artifactId>
<version>${azure-commons.version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- Jenkins modules (scope should be provided -->
<dependency>
<groupId>org.jenkins-ci.modules</groupId>
<artifactId>instance-identity</artifactId>
<version>2.1</version>
<version>2.2</version>
<scope>provided</scope>
</dependency>

<!-- test dependencies -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-2.164.x</artifactId>
<version>9</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
Expand All @@ -182,7 +216,7 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.7</version>
<version>3.9</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
Expand All @@ -204,36 +238,16 @@
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.11</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-storage</artifactId>
<version>6.1.0</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>credentials</artifactId>
<version>2.1.16</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-container-default</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>structs</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-jaxb-annotations</artifactId>
<version>2.9.8</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import hudson.security.ACL;
import hudson.slaves.Cloud;
import hudson.slaves.NodeProvisioner;
import hudson.slaves.SlaveComputer;
import hudson.util.FormValidation;
import hudson.util.ListBoxModel;
import io.fabric8.kubernetes.api.model.Pod;
Expand Down Expand Up @@ -221,10 +222,11 @@ private void waitToOnline(KubernetesAgent slave, String podId, StopWatch stopwat
throw new IllegalStateException(Messages.Kubernetes_Pod_Start_Failed(podId,
podTemp.getStatus().getPhase()));
}
if (slave.getComputer() == null) {
SlaveComputer computer = slave.getComputer();
if (computer == null) {
throw new IllegalStateException(Messages.Kubernetes_Pod_Deleted());
}
if (slave.getComputer().isOnline()) {
if (computer.isOnline()) {
break;
}
Thread.sleep(RETRY_INTERVAL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import hudson.model.labels.LabelAtom;
import hudson.security.ACL;
import hudson.slaves.RetentionStrategy;
import hudson.slaves.SlaveComputer;
import hudson.util.FormValidation;
import hudson.util.ListBoxModel;
import io.fabric8.kubernetes.api.model.Container;
Expand Down Expand Up @@ -65,8 +66,6 @@
import java.util.logging.Level;
import java.util.logging.Logger;



public class PodTemplate extends AbstractDescribableImpl<PodTemplate> {
private static final Logger LOGGER = Logger.getLogger(PodTemplate.class.getName());

Expand Down Expand Up @@ -153,9 +152,15 @@ public Pod buildPod(KubernetesAgent agent, String additionalSecret) {
podImagePullSecrets.add(new LocalObjectReference(additionalSecret));
}

String serverUrl = Jenkins.getInstance().getRootUrl();
String serverUrl = Jenkins.get().getRootUrl();
String nodeName = agent.getNodeName();
String secret = agent.getComputer().getJnlpMac();

SlaveComputer computer = agent.getComputer();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the source code changes are to make spotbugs happy for the record

if (computer == null) {
throw new IllegalStateException("Agent must be online at this point");
}

String secret = computer.getJnlpMac();
EnvVars arguments = new EnvVars("rootUrl", serverUrl, "nodeName", nodeName, "secret", secret);

// If using SSH, we need to open a SSH port
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.microsoft.jenkins.containeragents.util.DockerRegistryUtils;
import hudson.EnvVars;
import hudson.security.ACL;
import hudson.slaves.SlaveComputer;
import jenkins.model.Jenkins;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.time.StopWatch;
Expand All @@ -35,8 +36,6 @@
import java.util.logging.Level;
import java.util.logging.Logger;



public final class AciService {
private static final Logger LOGGER = Logger.getLogger(AciService.class.getName());

Expand Down Expand Up @@ -244,9 +243,15 @@ private static void addAzureFileVolumeNode(JsonNode tmp, ObjectMapper mapper, Az
}

private static String commandReplace(String command, AciAgent agent) {
String serverUrl = Jenkins.getInstance().getRootUrl();
String serverUrl = Jenkins.get().getRootUrl();
String nodeName = agent.getNodeName();
String secret = agent.getComputer().getJnlpMac();

SlaveComputer computer = agent.getComputer();
if (computer == null) {
throw new IllegalStateException("Agent must be online at this point");
}

String secret = computer.getJnlpMac();
EnvVars arguments = new EnvVars("rootUrl", serverUrl, "nodeName", nodeName, "secret", secret);
return arguments.expand(command);
}
Expand Down