Skip to content

Commit 5dd0445

Browse files
authored
Merge branch 'jenkinsci:master' into feature/selection-interface-ssh-multiple-network
2 parents be4f2b8 + b2f3de3 commit 5dd0445

37 files changed

Lines changed: 565 additions & 323 deletions
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Jenkins Security Scan
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
types: [ opened, synchronize, reopened ]
9+
workflow_dispatch:
10+
11+
permissions:
12+
security-events: write
13+
contents: read
14+
actions: read
15+
16+
jobs:
17+
security-scan:
18+
uses: jenkins-infra/jenkins-security-scan/.github/workflows/jenkins-security-scan.yaml@v2
19+
with:
20+
java-cache: 'maven' # Optionally enable use of a build dependency cache. Specify 'maven' or 'gradle' as appropriate.
21+
# java-version: 21 # Optionally specify what version of Java to set up for the build, or remove to use a recent default.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ release.properties
1212
**/dependency-reduced-pom.xml
1313
**/target
1414
.DS_Store
15+
tags

Jenkinsfile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
#!/usr/bin/env groovy
22

33
/* `buildPlugin` step provided by: https://github.com/jenkins-infra/pipeline-library */
4-
buildPlugin()
4+
buildPlugin(
5+
useContainerAgent: true,
6+
failFast: false,
7+
configurations: [
8+
[platform: 'linux', jdk: 11],
9+
[platform: 'linux', jdk: 17],
10+
[platform: 'windows', jdk: 11],
11+
])

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2015 OpenStack Cloud Plugin
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ in effect is printed under the field on hte config page). In case required
3838
field do not have a default nor current value, it will be reported.
3939

4040
The exception is here is the *Instance Cap* field that determines the maximal
41-
ammount of maches to be running either per whole cloud or per template. This is
41+
amount of machines to be running either per whole cloud or per template. This is
4242
so one can limit the total number and number per individual template at the same time.
4343

4444
### User data
@@ -81,6 +81,7 @@ jenkins:
8181
endPointUrl: "https://acme.com:5000"
8282
credentialsId: "openstack_service_credentials"
8383
ignoreSsl: false
84+
cleanfreq: 30
8485
zone: foo
8586
slaveOptions:
8687
bootSource:

plugin/pom.xml

Lines changed: 57 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -5,45 +5,51 @@
55
<dependencies>
66
<dependency>
77
<groupId>io.jenkins.tools.bom</groupId>
8-
<artifactId>bom-2.289.x</artifactId>
9-
<version>950.v396cb834de1e</version>
8+
<artifactId>bom-2.414.x</artifactId>
9+
<version>2516.v113cb_3d00317</version>
1010
<scope>import</scope>
1111
<type>pom</type>
1212
</dependency>
13+
<dependency>
14+
<groupId>org.junit</groupId>
15+
<artifactId>junit-bom</artifactId>
16+
<version>5.10.0</version>
17+
<type>pom</type>
18+
<scope>import</scope>
19+
</dependency>
1320
</dependencies>
1421
</dependencyManagement>
1522

1623
<parent>
1724
<groupId>org.jenkins-ci.plugins</groupId>
1825
<artifactId>plugin</artifactId>
19-
<version>4.25</version>
26+
<version>4.55</version>
2027
<relativePath />
2128
</parent>
2229

2330
<artifactId>openstack-cloud</artifactId>
24-
<version>2.64-SNAPSHOT</version>
31+
<version>2.67-SNAPSHOT</version>
2532
<packaging>hpi</packaging>
2633
<name>OpenStack Cloud Plugin</name>
2734
<description>Allows Jenkins to build on OpenStack nodes</description>
2835
<url>https://github.com/jenkinsci/openstack-cloud-plugin</url>
2936

3037
<properties>
31-
<jenkins.version>2.289.1</jenkins.version>
32-
<java.level>8</java.level>
38+
<jenkins.version>2.419</jenkins.version>
39+
<java.level>11</java.level>
3340
<concurrency>1C</concurrency>
3441
<surefire.useFile>false</surefire.useFile>
3542
<spotbugs.failOnError>false</spotbugs.failOnError>
3643
<spotbugs.excludeFilterFile>src/findbugs-exclude.xml</spotbugs.excludeFilterFile>
37-
<spotbugs.skip>true
38-
</spotbugs.skip> <!-- Upstream Jenkins fails the build if some are found. Excludes does not seem to work. -->
44+
<spotbugs.skip>true</spotbugs.skip> <!-- Upstream Jenkins fails the build if some are found. Excludes do not seem to work. -->
3945
<maven.compiler.showDeprecation>true</maven.compiler.showDeprecation>
4046

41-
<guava.version>20.0</guava.version> <!-- version compatible with openstack4j -->
47+
<guava.version>32.1.1-jre</guava.version> <!-- version compatible with openstack4j -->
4248
<jsr305.version>1.3.9</jsr305.version>
43-
<openstack4j.version>3.10</openstack4j.version>
49+
<openstack4j.version>3.11</openstack4j.version>
4450
<okhttp.version>3.9.1</okhttp.version>
45-
<jenkins-test-harness.version>1626.v46b0925e70db</jenkins-test-harness.version>
46-
<jackson.version>2.12.4</jackson.version>
51+
<!-- Upper bound io.jenkins.configuration-as-code:test-harness -->
52+
<jenkins-test-harness.version>2064.vcd3b_b_8f3f2b_a_</jenkins-test-harness.version>
4753
</properties>
4854

4955
<developers>
@@ -94,16 +100,17 @@
94100
<dependency>
95101
<groupId>org.jenkins-ci.plugins</groupId>
96102
<artifactId>credentials</artifactId>
103+
<version>1305.v04f5ec1f3743</version>
97104
</dependency>
98105
<dependency>
99106
<groupId>org.jenkins-ci.plugins</groupId>
100107
<artifactId>config-file-provider</artifactId>
101-
<version>3.5</version>
108+
<version>3.7.1</version>
102109
</dependency>
103110
<dependency>
104111
<groupId>org.jenkins-ci.plugins</groupId>
105112
<artifactId>cloud-stats</artifactId>
106-
<version>0.21</version>
113+
<version>336.v788e4055508b_</version>
107114
</dependency>
108115
<dependency>
109116
<groupId>org.jenkins-ci.plugins</groupId>
@@ -117,7 +124,6 @@
117124
<dependency>
118125
<groupId>org.jenkins-ci.modules</groupId>
119126
<artifactId>instance-identity</artifactId>
120-
<version>2.2</version>
121127
</dependency>
122128
<dependency>
123129
<groupId>io.jenkins.plugins</groupId>
@@ -136,58 +142,43 @@
136142
<dependency>
137143
<groupId>org.codehaus.plexus</groupId>
138144
<artifactId>plexus-utils</artifactId>
139-
<version>3.0.10</version>
145+
<version>3.5.1</version>
140146
</dependency>
141147
<dependency>
142148
<groupId>org.codehaus.plexus</groupId>
143149
<artifactId>plexus-classworlds</artifactId>
144150
<version>2.4.2</version>
145151
</dependency>
152+
146153
<dependency>
147154
<groupId>org.jenkins-ci</groupId>
148155
<artifactId>symbol-annotation</artifactId>
149156
</dependency>
150157
<dependency>
151158
<groupId>org.yaml</groupId>
152159
<artifactId>snakeyaml</artifactId>
153-
<version>1.29</version>
154-
</dependency>
155-
156-
<!--Specifying jenkins version to avoid maven.plugins.enforcer.RequireUpperBoundDeps error
157-
between configuration as code and openstack4j -->
158-
<dependency>
159-
<groupId>com.fasterxml.jackson.core</groupId>
160-
<artifactId>jackson-databind</artifactId>
161-
<version>${jackson.version}</version>
162-
</dependency>
163-
<dependency>
164-
<groupId>com.fasterxml.jackson.core</groupId>
165-
<artifactId>jackson-annotations</artifactId>
166-
<version>${jackson.version}</version>
167-
</dependency>
168-
<dependency>
169-
<groupId>com.fasterxml.jackson.core</groupId>
170-
<artifactId>jackson-core</artifactId>
171-
<version>${jackson.version}</version>
160+
<version>2.2</version>
172161
</dependency>
173162
<dependency>
174-
<groupId>com.fasterxml.jackson.dataformat</groupId>
175-
<artifactId>jackson-dataformat-yaml</artifactId>
176-
<version>${jackson.version}</version>
163+
<groupId>org.jenkins-ci.plugins</groupId>
164+
<artifactId>jackson2-api</artifactId>
165+
<version>2.14.1-313.v504cdd45c18b</version>
177166
</dependency>
178167

179168
<!-- Test Dependencies -->
180169
<dependency>
181170
<groupId>org.hamcrest</groupId>
182-
<artifactId>hamcrest-core</artifactId>
171+
<artifactId>hamcrest</artifactId>
183172
<scope>test</scope>
173+
<version>2.2</version>
184174
</dependency>
185175
<dependency>
186176
<groupId>org.mockito</groupId>
187177
<artifactId>mockito-all</artifactId>
188178
<version>1.9.5</version>
189179
<scope>test</scope>
190180
</dependency>
181+
191182
<dependency>
192183
<groupId>org.jenkins-ci.plugins.workflow</groupId>
193184
<artifactId>workflow-cps</artifactId>
@@ -231,7 +222,29 @@
231222
<artifactId>test-harness</artifactId>
232223
<groupId>io.jenkins.configuration-as-code</groupId>
233224
<scope>test</scope>
234-
</dependency>
225+
<exclusions>
226+
<exclusion>
227+
<groupId>org.jenkins-ci.plugins</groupId>
228+
<artifactId>jackson2-api</artifactId>
229+
</exclusion>
230+
</exclusions>
231+
</dependency>
232+
<!-- <dependency>-->
233+
<!-- <groupId>net.sourceforge.htmlunit</groupId>-->
234+
<!-- <artifactId>htmlunit</artifactId>-->
235+
<!-- <version>2.70.0</version>-->
236+
<!-- <scope>test</scope>-->
237+
<!-- <exclusions>-->
238+
<!-- <exclusion>-->
239+
<!-- <groupId>org.apache.commons</groupId>-->
240+
<!-- <artifactId>commons-lang3</artifactId>-->
241+
<!-- </exclusion>-->
242+
<!-- <exclusion>-->
243+
<!-- <groupId>org.eclipse.jetty.websocket</groupId>-->
244+
<!-- <artifactId>websocket-client</artifactId>-->
245+
<!-- </exclusion>-->
246+
<!-- </exclusions>-->
247+
<!-- </dependency>-->
235248
</dependencies>
236249

237250
<build>
@@ -255,6 +268,8 @@
255268
<artifactId>maven-surefire-plugin</artifactId>
256269
<configuration>
257270
<reuseForks>false</reuseForks>
271+
<!-- Serializing org.mockito.internal.stubbing.StubbedInvocationMatcher#answers -->
272+
<argLine>${argLine} --add-opens java.base/java.util.concurrent=ALL-UNNAMED</argLine>
258273
</configuration>
259274
</plugin>
260275
</plugins>
@@ -264,9 +279,9 @@
264279

265280
<scm>
266281
<connection>scm:git:ssh://github.com/jenkinsci/openstack-cloud-plugin.git</connection>
267-
<developerConnection>scm:git:ssh://git@github.com/jenkinsci/openstack-cloud-plugin.git</developerConnection>
282+
<developerConnection>scm:git:git@github.com:jenkinsci/openstack-cloud-plugin.git</developerConnection>
268283
<url>https://github.com/jenkinsci/openstack-cloud-plugin</url>
269-
<tag>HEAD</tag>
284+
<tag>parent-2.66</tag>
270285
</scm>
271286

272287
<repositories>

plugin/src/main/java/jenkins/plugins/openstack/compute/JCloudsCleanupThread.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,15 @@ public JCloudsCleanupThread() {
4848

4949
@Override
5050
public long getRecurrencePeriod() {
51-
return MIN * 10;
51+
// fixed value: 1000 millis
52+
long cleanFreq = 1000;
53+
54+
return cleanFreq;
5255
}
5356

5457
@Override
5558
public void execute(TaskListener listener) {
59+
5660
try {
5761
terminateNodesPendingDeletion();
5862

@@ -61,6 +65,9 @@ public void execute(TaskListener listener) {
6165
terminatesNodesWithoutServers(runningServers);
6266

6367
cleanOrphanedFips();
68+
69+
setCloudLastCleanTime();
70+
6471
} catch (JCloudsCloud.LoginFailure ex) {
6572
LOGGER.log(Level.WARNING, "Unable to authenticate: " + ex.getMessage());
6673
} catch (Throwable ex) {
@@ -70,6 +77,7 @@ public void execute(TaskListener listener) {
7077

7178
private void cleanOrphanedFips() {
7279
for (JCloudsCloud cloud : JCloudsCloud.getClouds()) {
80+
if ((System.currentTimeMillis() - cloud.getLastCleanTime()) < cloud.getCleanfreqToMillis()) continue;
7381
Openstack openstack = cloud.getOpenstack();
7482

7583
List<String> leaked = openstack.getFreeFipIds();
@@ -87,11 +95,20 @@ private void cleanOrphanedFips() {
8795
}
8896
}
8997

98+
private void setCloudLastCleanTime() {
99+
for (JCloudsCloud cloud : JCloudsCloud.getClouds()) {
100+
if ((System.currentTimeMillis() - cloud.getLastCleanTime()) < cloud.getCleanfreqToMillis()) continue;
101+
cloud.setLastCleanTime(System.currentTimeMillis());
102+
}
103+
}
104+
90105
private void terminateNodesPendingDeletion() {
91106
for (final JCloudsComputer comp : JCloudsComputer.getAll()) {
107+
JCloudsCloud cloud = JCloudsCloud.getByName(comp.getId().getCloudName());
108+
if ((System.currentTimeMillis() - cloud.getLastCleanTime()) < cloud.getCleanfreqToMillis()) continue;
92109
if (!comp.isIdle()) continue;
93110

94-
final OfflineCause offlineCause = comp.getFatalOfflineCause();
111+
final OfflineCause offlineCause = comp.getNode().getFatalOfflineCause();
95112
if (comp.isPendingDelete()) {
96113
LOGGER.log(Level.INFO, "Deleting pending node " + comp.getName() + ". Reason: " + comp.getOfflineCause());
97114
deleteComputer(comp);
@@ -156,6 +173,7 @@ private void deleteComputer(JCloudsComputer comp, CauseOfInterruption coi) {
156173
private @Nonnull HashMap<JCloudsCloud, List<Server>> destroyServersOutOfScope() {
157174
HashMap<JCloudsCloud, List<Server>> runningServers = new HashMap<>();
158175
for (JCloudsCloud jc : JCloudsCloud.getClouds()) {
176+
if ((System.currentTimeMillis() - jc.getLastCleanTime()) < jc.getCleanfreqToMillis()) continue;
159177
runningServers.put(jc, new ArrayList<>());
160178
List<Server> servers = jc.getOpenstack().getRunningNodes();
161179
for (Server server : servers) {
@@ -175,6 +193,9 @@ private void deleteComputer(JCloudsComputer comp, CauseOfInterruption coi) {
175193
private void terminatesNodesWithoutServers(@Nonnull HashMap<JCloudsCloud, List<Server>> runningServers) {
176194
Map<String, JCloudsComputer> jenkinsComputers = new HashMap<>();
177195
for (JCloudsComputer computer: JCloudsComputer.getAll()) {
196+
JCloudsCloud cloud = JCloudsCloud.getByName(computer.getId().getCloudName());
197+
if ((System.currentTimeMillis() - cloud.getLastCleanTime()) < cloud.getCleanfreqToMillis()) continue;
198+
178199
JCloudsSlave node = computer.getNode();
179200
if (node != null) {
180201
jenkinsComputers.put(node.getServerId(), computer);

0 commit comments

Comments
 (0)