Skip to content

Commit dcb4c99

Browse files
committed
Merge branch 'master' of https://github.com/jenkinsci/kubernetes-plugin into migrate_to_junit5
2 parents 63d38a9 + 3a18554 commit dcb4c99

14 files changed

Lines changed: 126 additions & 42 deletions

File tree

.git-blame-ignore-revs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# https://github.com/jenkinsci/kubernetes-plugin/pull/1478
1+
# Spotless
22
9c1d58d9badd988622b4772632037126176e1ef0
3-
# https://github.com/jenkinsci/kubernetes-plugin/pull/1756
43
ba318e03a58277ab79f3636343544e882f368a88
4+
252a43c89fe7e942ae962bae1ba3a40569d2ff77

.github/release-drafter.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ then
10151015
```bash
10161016
kubectl krew install tunnel # as needed; install Krew first
10171017
kubectl tunnel expose jenkins 8000:8000 8001:8001 &
1018-
mvn test -Djenkins.host.address=jenkins.default.svc.cluster.local -Dport=8000 -DslaveAgentPort=8001 -Dtest=KubernetesPipelineTest#runInPod
1018+
mvn test -Pktunnel -Dtest=KubernetesPipelineTest#runInPod
10191019
```
10201020

10211021
Alternately, you can run everything like in CI:
@@ -1028,7 +1028,7 @@ export KIND_PRELOAD=true # optionally
10281028
You can also run interactively after setting up the tunnel:
10291029

10301030
```bash
1031-
mvn hpi:run -Djenkins.host.address=jenkins.default -Dport=8000 -Djenkins.model.Jenkins.slaveAgentPort=8001
1031+
mvn hpi:run -Pktunnel
10321032
```
10331033

10341034
# Docker image

kind.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ ktunnel_pid=$!
5454
mvn \
5555
-B \
5656
-ntp \
57-
-Djenkins.host.address=jenkins.default \
58-
-Dport=8000 \
59-
-DslaveAgentPort=8001 \
57+
-Pktunnel \
6058
-Dmaven.test.failure.ignore \
6159
verify \
6260
"$@"

pom.xml

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>org.jenkins-ci.plugins</groupId>
66
<artifactId>plugin</artifactId>
7-
<version>6.2111.v8b_6a_1d599df3</version>
7+
<version>6.2189.v695a_c41f5249</version>
88
<relativePath />
99
</parent>
1010

@@ -41,8 +41,6 @@
4141

4242
<properties>
4343
<changelist>999999-SNAPSHOT</changelist>
44-
<jenkins.host.address />
45-
<slaveAgentPort />
4644
<jenkins.baseline>2.504</jenkins.baseline>
4745
<jenkins.version>${jenkins.baseline}.3</jenkins.version>
4846
<no-test-jar>false</no-test-jar>
@@ -52,6 +50,7 @@
5250
<spotbugs.threshold>Low</spotbugs.threshold>
5351
<spotless.check.skip>false</spotless.check.skip>
5452
<ban-junit4-imports.skip>false</ban-junit4-imports.skip>
53+
<banObsoleteDependencyOverrides.skip>false</banObsoleteDependencyOverrides.skip>
5554
</properties>
5655

5756
<dependencyManagement>
@@ -289,12 +288,7 @@
289288
<artifactId>maven-surefire-plugin</artifactId>
290289
<configuration>
291290
<systemPropertyVariables>
292-
<hudson.slaves.NodeProvisioner.initialDelay>0</hudson.slaves.NodeProvisioner.initialDelay>
293-
<hudson.slaves.NodeProvisioner.recurrencePeriod>3000</hudson.slaves.NodeProvisioner.recurrencePeriod>
294291
<org.jenkinsci.plugins.workflow.support.pickles.ExecutorPickle.timeoutForNodeMillis>60000</org.jenkinsci.plugins.workflow.support.pickles.ExecutorPickle.timeoutForNodeMillis>
295-
<!-- have pods connect to this address for Jenkins -->
296-
<jenkins.host.address>${jenkins.host.address}</jenkins.host.address>
297-
<slaveAgentPort>${slaveAgentPort}</slaveAgentPort>
298292
</systemPropertyVariables>
299293
</configuration>
300294
</plugin>
@@ -303,11 +297,6 @@
303297
<artifactId>maven-hpi-plugin</artifactId>
304298
<configuration>
305299
<systemProperties>
306-
<hudson.slaves.NodeProvisioner.initialDelay>0</hudson.slaves.NodeProvisioner.initialDelay>
307-
<hudson.slaves.NodeProvisioner.MARGIN>50</hudson.slaves.NodeProvisioner.MARGIN>
308-
<hudson.slaves.NodeProvisioner.MARGIN0>0.85</hudson.slaves.NodeProvisioner.MARGIN0>
309-
<jenkins.host.address>${jenkins.host.address}</jenkins.host.address>
310-
<port>${port}</port>
311300
<org.csanchez.jenkins.plugins.kubernetes.pipeline.PodTemplateStepExecution.verbose>true</org.csanchez.jenkins.plugins.kubernetes.pipeline.PodTemplateStepExecution.verbose>
312301
</systemProperties>
313302
</configuration>
@@ -383,6 +372,38 @@
383372
</plugins>
384373
</build>
385374
</profile>
375+
<profile>
376+
<!-- kubectl tunnel expose jenkins 8000:8000 8001:8001 -->
377+
<id>ktunnel</id>
378+
<build>
379+
<pluginManagement>
380+
<plugins>
381+
<plugin>
382+
<groupId>org.apache.maven.plugins</groupId>
383+
<artifactId>maven-surefire-plugin</artifactId>
384+
<configuration>
385+
<systemPropertyVariables>
386+
<jenkins.host.address>jenkins.default.svc.cluster.local</jenkins.host.address>
387+
<port>8000</port>
388+
<slaveAgentPort>8001</slaveAgentPort>
389+
</systemPropertyVariables>
390+
</configuration>
391+
</plugin>
392+
<plugin>
393+
<groupId>org.jenkins-ci.tools</groupId>
394+
<artifactId>maven-hpi-plugin</artifactId>
395+
<configuration>
396+
<defaultPort>8000</defaultPort>
397+
<systemProperties>
398+
<jenkins.host.address>jenkins.default.svc.cluster.local</jenkins.host.address>
399+
<jenkins.model.Jenkins.slaveAgentPort>8001</jenkins.model.Jenkins.slaveAgentPort>
400+
</systemProperties>
401+
</configuration>
402+
</plugin>
403+
</plugins>
404+
</pluginManagement>
405+
</build>
406+
</profile>
386407
</profiles>
387408

388409
</project>

src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1466,7 +1466,7 @@ public static void hpiRunInit() {
14661466
&& jenkins.clouds.getAll(KubernetesCloud.class).isEmpty()) {
14671467
KubernetesCloud cloud = new KubernetesCloud("kubernetes");
14681468
cloud.setJenkinsUrl(
1469-
"http://" + hostAddress + ":" + SystemProperties.getInteger("port", 8080) + "/jenkins/");
1469+
"http://" + hostAddress + ":" + SystemProperties.getInteger("port", 8000) + "/jenkins/");
14701470
jenkins.clouds.add(cloud);
14711471
}
14721472
}

src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesLauncher.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,9 @@ public synchronized void launch(SlaveComputer computer, TaskListener listener) {
177177
namespace,
178178
pod.getMetadata().getName(),
179179
e.getMessage());
180-
} else if (httpCode == 409
181-
&& e.getMessage().contains("Operation cannot be fulfilled on resourcequotas")) {
180+
} else if (isResourceQuotaUpdateConflict(httpCode, e.getMessage())) {
182181
// See: https://github.com/kubernetes/kubernetes/issues/67761 ; A retry usually works.
182+
// OpenShift ClusterResourceQuota conflicts use clusterresourcequotas.quota.openshift.io.
183183
node.getRunListener()
184184
.getLogger()
185185
.printf(
@@ -391,6 +391,19 @@ private void logLastLines(
391391
}
392392
}
393393

394+
/**
395+
* Detects transient quota update conflicts during pod creation.
396+
* These occur when concurrent pod creations race to update ResourceQuota or OpenShift ClusterResourceQuota.
397+
*
398+
* @see <a href="https://github.com/kubernetes/kubernetes/issues/67761">kubernetes#67761</a>
399+
*/
400+
static boolean isResourceQuotaUpdateConflict(int httpCode, @CheckForNull String message) {
401+
return httpCode == 409
402+
&& message != null
403+
&& message.contains("Operation cannot be fulfilled on")
404+
&& message.contains("resourcequotas");
405+
}
406+
394407
/**
395408
* The last problem that occurred, if any.
396409
* @return

src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesSlave.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,10 @@ protected void _terminate(TaskListener listener) throws IOException, Interrupted
402402
// the slave pod's current state and the pod retention policy.
403403
// Healthy slave pods should still have a JNLP agent running at this point.
404404
boolean deletePod = getPodRetention(cloud)
405-
.shouldDeletePod(cloud, () -> KubernetesCloud.getPodResource(client, getNamespace(), name)
406-
.get());
405+
.shouldDeletePod(
406+
cloud,
407+
() -> KubernetesCloud.getPodResource(client, getNamespace(), name)
408+
.get());
407409

408410
Computer computer = toComputer();
409411
if (computer == null) {

src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesAgentErrorCondition.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,10 @@ public boolean test(@NonNull Throwable t, @CheckForNull StepContext context)
115115
} else {
116116
// May have been removed already, but we can look up the labels to see what it was.
117117
Set<LabelAtom> labels = ws.getLabels();
118-
if (labels.stream().noneMatch(l -> Jenkins.get().clouds.stream()
119-
.anyMatch(c ->
120-
c instanceof KubernetesCloud && ((KubernetesCloud) c).getTemplate(l) != null))) {
118+
if (labels.stream()
119+
.noneMatch(l -> Jenkins.get().clouds.stream()
120+
.anyMatch(c -> c instanceof KubernetesCloud
121+
&& ((KubernetesCloud) c).getTemplate(l) != null))) {
121122
if (!handleNonKubernetes) {
122123
listener.getLogger()
123124
.println(node + " did not look like a Kubernetes agent judging by " + labels
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
FROM jenkins/inbound-agent:3355.v388858a_47b_33-3-jdk21
1+
FROM jenkins/inbound-agent:3383.vc8881d4b_0e76-1-jdk25

0 commit comments

Comments
 (0)