Skip to content

Commit fa65a3a

Browse files
authored
Merge branch 'master' into ib/changelog-2.18.0
2 parents 14652a0 + 05d75ae commit fa65a3a

File tree

113 files changed

+1076
-427
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+1076
-427
lines changed

.github/workflows/build.yml

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ jobs:
2020
- name: Check PR labels
2121
id: check
2222
run: |
23-
labels=$(jq -r '.pull_request.labels | map(.name) | join(",")' $GITHUB_EVENT_PATH)
24-
if [[ "$labels" == *"[no ci]"* ]]; then
25-
echo "skip=true" >> $GITHUB_OUTPUT
23+
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
24+
labels=$(jq -r '.pull_request.labels | map(.name) | join(",")' "$GITHUB_EVENT_PATH")
25+
if [[ "$labels" == *"[no ci]"* ]]; then
26+
echo "skip=true" >> $GITHUB_OUTPUT
27+
else
28+
echo "skip=false" >> $GITHUB_OUTPUT
29+
fi
2630
else
2731
echo "skip=false" >> $GITHUB_OUTPUT
28-
fi
29-
if [[ "$labels" == *"don't test"* ]]; then
30-
echo "skip_tests=true" >> $GITHUB_OUTPUT
31-
else
3232
echo "skip_tests=false" >> $GITHUB_OUTPUT
3333
fi
3434
@@ -73,9 +73,4 @@ jobs:
7373
- name: Build and test with Maven
7474
env:
7575
SKIP_DOCKER_TESTS: "true"
76-
run: |
77-
if [[ "${{ needs.check-labels.outputs.skip_tests }}" == "true" ]]; then
78-
./mvnw -s .github/settings.xml -B clean install -Pgha -Pdocker -P${{ matrix.profile }} -DskipTests
79-
else
80-
./mvnw -s .github/settings.xml -B clean install -Pgha -Pdocker -Pit -P${{ matrix.profile }}
81-
fi
76+
run: ./mvnw -s .github/settings.xml -B clean install -Pgha -Pdocker -Pit -P${{ matrix.profile }}

agent-operator/pom.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,6 @@
8888
<groupId>javax.xml.bind</groupId>
8989
<artifactId>jaxb-api</artifactId>
9090
</dependency>
91-
<dependency>
92-
<groupId>com.sun.xml.bind</groupId>
93-
<artifactId>jaxb-core</artifactId>
94-
</dependency>
9591
<dependency>
9692
<groupId>com.sun.xml.bind</groupId>
9793
<artifactId>jaxb-impl</artifactId>

agent-operator/src/main/java/com/walmartlabs/concord/agentoperator/processqueue/ProcessQueueClient.java

Lines changed: 46 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* *****
55
* Concord
66
* -----
7-
* Copyright (C) 2017 - 2019 Walmart Inc.
7+
* Copyright (C) 2017 - 2024 Walmart Inc.
88
* -----
99
* Licensed under the Apache License, Version 2.0 (the "License");
1010
* you may not use this file except in compliance with the License.
@@ -26,32 +26,39 @@
2626
import com.google.common.escape.Escaper;
2727
import com.google.common.net.UrlEscapers;
2828
import com.walmartlabs.concord.agentoperator.scheduler.QueueSelector;
29-
import okhttp3.*;
29+
import com.walmartlabs.concord.sdk.Constants;
3030

3131
import javax.net.ssl.SSLContext;
32-
import javax.net.ssl.SSLSocketFactory;
3332
import javax.net.ssl.TrustManager;
3433
import javax.net.ssl.X509TrustManager;
3534
import java.io.IOException;
36-
import java.util.HashMap;
35+
import java.net.CookieManager;
36+
import java.net.CookiePolicy;
37+
import java.net.URI;
38+
import java.net.http.HttpClient;
39+
import java.net.http.HttpRequest;
40+
import java.net.http.HttpResponse;
41+
import java.security.KeyManagementException;
42+
import java.security.NoSuchAlgorithmException;
43+
import java.security.SecureRandom;
44+
import java.security.cert.X509Certificate;
3745
import java.util.List;
38-
import java.util.Map;
3946

4047
public class ProcessQueueClient {
4148

42-
private static final TypeReference<List<ProcessQueueEntry>> LIST_OF_PROCESS_QUEUE_ENTRIES = new TypeReference<List<ProcessQueueEntry>>() {
49+
private static final TypeReference<List<ProcessQueueEntry>> LIST_OF_PROCESS_QUEUE_ENTRIES = new TypeReference<>() {
4350
};
4451

4552
private final String baseUrl;
4653
private final String apiToken;
47-
private final OkHttpClient client;
4854
private final ObjectMapper objectMapper;
55+
private final HttpClient client;
4956

5057
public ProcessQueueClient(String baseUrl, String apiToken) {
5158
this.baseUrl = baseUrl;
5259
this.apiToken = apiToken;
53-
this.client = initClient();
5460
this.objectMapper = new ObjectMapper();
61+
this.client = initClient();
5562
}
5663

5764
public List<ProcessQueueEntry> query(String processStatus, int limit, QueueSelector queueSelector) throws IOException {
@@ -66,109 +73,58 @@ public List<ProcessQueueEntry> query(String processStatus, int limit, QueueSelec
6673
queryUrl.append("&").append(escapeQueryParam(queryParam));
6774
}
6875
}
69-
Request req = new Request.Builder()
70-
.url(queryUrl.toString())
76+
77+
HttpRequest request = HttpRequest.newBuilder()
78+
.uri(URI.create(queryUrl.toString()))
7179
.header("Authorization", apiToken)
72-
.addHeader("User-Agent", "k8s-agent-operator")
80+
.header("User-Agent", "k8s-agent-operator")
81+
.header(Constants.Headers.ENABLE_HTTP_SESSION, "true")
82+
.GET()
7383
.build();
7484

75-
Call call = client.newCall(req);
76-
try (Response resp = call.execute()) {
77-
if (!resp.isSuccessful()) {
78-
throw new IOException("Error while fetching the process queue data: " + resp.code());
79-
}
80-
81-
ResponseBody body = resp.body();
82-
if (body == null) {
83-
throw new IOException("Error while fetching the process queue data: empty response");
84-
}
85+
HttpResponse<String> response;
86+
try {
87+
response = client.send(request, HttpResponse.BodyHandlers.ofString());
88+
} catch (InterruptedException e) {
89+
Thread.currentThread().interrupt();
90+
throw new IOException("Interrupted while fetching the queue data", e);
91+
}
8592

86-
return objectMapper.readValue(body.byteStream(), LIST_OF_PROCESS_QUEUE_ENTRIES);
93+
if (response.statusCode() != 200) {
94+
throw new IOException("Error while fetching the process queue data: " + response.statusCode());
8795
}
96+
97+
return objectMapper.readValue(response.body(), LIST_OF_PROCESS_QUEUE_ENTRIES);
8898
}
8999

90-
private static OkHttpClient initClient() {
100+
private static HttpClient initClient() {
91101
try {
92102
TrustManager[] trustAllCerts = new TrustManager[]{
93103
new X509TrustManager() {
94-
@Override
95-
public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) {
104+
public X509Certificate[] getAcceptedIssuers() {
105+
return new X509Certificate[0];
96106
}
97107

98-
@Override
99-
public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) {
108+
public void checkClientTrusted(X509Certificate[] certs, String authType) {
100109
}
101110

102-
@Override
103-
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
104-
return new java.security.cert.X509Certificate[]{};
111+
public void checkServerTrusted(X509Certificate[] certs, String authType) {
105112
}
106113
}
107114
};
108115

109116
SSLContext sslContext = SSLContext.getInstance("SSL");
110-
sslContext.init(null, trustAllCerts, new java.security.SecureRandom());
111-
112-
SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();
113-
114-
OkHttpClient.Builder builder = new OkHttpClient.Builder();
115-
builder.sslSocketFactory(sslSocketFactory, (X509TrustManager) trustAllCerts[0]);
116-
builder.hostnameVerifier((hostname, session) -> true);
117-
118-
Map<String, String> cookieJar = new HashMap<>();
119-
builder.addInterceptor(new AddCookiesInterceptor(cookieJar));
120-
builder.addInterceptor(new ReceivedCookiesInterceptor(cookieJar));
121-
122-
return builder.build();
123-
} catch (Exception e) {
124-
throw new RuntimeException(e);
125-
}
126-
}
127-
128-
private static class AddCookiesInterceptor implements Interceptor {
117+
sslContext.init(null, trustAllCerts, new SecureRandom());
129118

130-
private final Map<String, String> cookieJar;
131-
132-
private AddCookiesInterceptor(Map<String, String> cookieJar) {
133-
this.cookieJar = cookieJar;
134-
}
135-
136-
@Override
137-
public Response intercept(Chain chain) throws IOException {
138-
Request.Builder builder = chain.request().newBuilder();
139-
for (Map.Entry<String, String> cookie : cookieJar.entrySet()) {
140-
builder.addHeader("Cookie", cookie.getValue());
141-
}
142-
return chain.proceed(builder.build());
143-
}
144-
}
145-
146-
private static class ReceivedCookiesInterceptor implements Interceptor {
147-
148-
private static final String SESSION_COOKIE_NAME = "JSESSIONID";
149-
150-
private final Map<String, String> cookieJar;
151-
152-
private ReceivedCookiesInterceptor(Map<String, String> cookieJar) {
153-
this.cookieJar = cookieJar;
154-
}
155-
156-
@Override
157-
public Response intercept(Chain chain) throws IOException {
158-
Response resp = chain.proceed(chain.request());
159-
160-
List<String> cookies = resp.headers("Set-Cookie");
161-
if (cookies.isEmpty()) {
162-
return resp;
163-
}
164-
165-
for (String cookie : cookies) {
166-
if (cookie.startsWith(SESSION_COOKIE_NAME)) {
167-
cookieJar.put(SESSION_COOKIE_NAME, cookie);
168-
}
169-
}
119+
CookieManager cookieManager = new CookieManager();
120+
cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
170121

171-
return resp;
122+
return HttpClient.newBuilder()
123+
.sslContext(sslContext)
124+
.cookieHandler(cookieManager)
125+
.build();
126+
} catch (NoSuchAlgorithmException | KeyManagementException e) {
127+
throw new RuntimeException("Error while initializing the HTTP client", e);
172128
}
173129
}
174130

agent/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@
114114
<artifactId>config</artifactId>
115115
</dependency>
116116
<dependency>
117-
<groupId>com.walmartlabs.ollie</groupId>
118-
<artifactId>ollie-config</artifactId>
117+
<groupId>com.walmartlabs.concord</groupId>
118+
<artifactId>concord-config</artifactId>
119119
</dependency>
120120

121121
<!-- Immutables -->

agent/src/assembly/start.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ ${JDK_SPECIFIC_OPTS} \
4141
-Djava.net.preferIPv4Stack=true \
4242
-Djava.security.egd=file:/dev/./urandom \
4343
-Dlogback.configurationFile=com/walmartlabs/concord/agent/logback.xml \
44-
-Dollie.conf=${CONCORD_CFG_FILE} \
44+
-Dconcord.conf=${CONCORD_CFG_FILE} \
4545
-cp "${BASE_DIR}/lib/*" \
4646
com.walmartlabs.concord.agent.Main

agent/src/main/java/com/walmartlabs/concord/agent/AgentModule.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,8 @@
3030
import com.walmartlabs.concord.agent.remote.ApiClientFactory;
3131
import com.walmartlabs.concord.agent.remote.QueueClientProvider;
3232
import com.walmartlabs.concord.common.ObjectMapperProvider;
33+
import com.walmartlabs.concord.config.ConfigModule;
3334
import com.walmartlabs.concord.server.queueclient.QueueClient;
34-
import com.walmartlabs.ollie.config.ConfigurationProcessor;
35-
import com.walmartlabs.ollie.config.Environment;
36-
import com.walmartlabs.ollie.config.EnvironmentSelector;
3735

3836
import javax.inject.Named;
3937

@@ -76,7 +74,6 @@ public void configure(Binder binder) {
7674
}
7775

7876
private static Config loadDefaultConfig() {
79-
Environment env = new EnvironmentSelector().select();
80-
return new ConfigurationProcessor("concord-agent", env, null, null).process();
77+
return ConfigModule.load("concord-agent");
8178
}
8279
}

client/pom.xml

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -190,25 +190,9 @@
190190
<groupId>org.revapi</groupId>
191191
<artifactId>revapi-maven-plugin</artifactId>
192192
<configuration>
193-
<analysisConfiguration>
194-
<revapi.ignore>
195-
<item>
196-
<code>java.field.serialVersionUIDUnchanged</code>
197-
</item>
198-
<item>
199-
<code>java.method.parameterTypeParameterChanged</code>
200-
</item>
201-
<item>
202-
<code>java.method.returnTypeTypeParametersChanged</code>
203-
</item>
204-
<item>
205-
<code>java.class.externalClassExposedInAPI</code>
206-
</item>
207-
<item>
208-
<code>java.method.numberOfParametersChanged</code>
209-
</item>
210-
</revapi.ignore>
211-
</analysisConfiguration>
193+
<!-- lots of incompatible changes due to breaking changes in dependencies -->
194+
<!-- re-enable after release -->
195+
<skip>true</skip>
212196
</configuration>
213197
</plugin>
214198
</plugins>

common/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,6 @@
7979
<artifactId>jaxb-api</artifactId>
8080
<scope>provided</scope>
8181
</dependency>
82-
<dependency>
83-
<groupId>com.sun.xml.bind</groupId>
84-
<artifactId>jaxb-core</artifactId>
85-
<scope>provided</scope>
86-
</dependency>
8782
<dependency>
8883
<groupId>com.sun.xml.bind</groupId>
8984
<artifactId>jaxb-impl</artifactId>

config/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Concord Config
2+
3+
Based on [ollie-config](https://github.com/takari/ollie/tree/master/ollie-config),
4+
minus the environment handling.

config/pom.xml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<parent>
7+
<groupId>com.walmartlabs.concord</groupId>
8+
<artifactId>parent</artifactId>
9+
<version>2.17.1-SNAPSHOT</version>
10+
<relativePath>../pom.xml</relativePath>
11+
</parent>
12+
13+
<artifactId>concord-config</artifactId>
14+
<packaging>jar</packaging>
15+
16+
<dependencies>
17+
<dependency>
18+
<groupId>com.typesafe</groupId>
19+
<artifactId>config</artifactId>
20+
</dependency>
21+
<dependency>
22+
<groupId>javax.inject</groupId>
23+
<artifactId>javax.inject</artifactId>
24+
</dependency>
25+
<dependency>
26+
<groupId>com.google.inject</groupId>
27+
<artifactId>guice</artifactId>
28+
</dependency>
29+
<dependency>
30+
<groupId>org.reflections</groupId>
31+
<artifactId>reflections</artifactId>
32+
</dependency>
33+
<dependency>
34+
<groupId>org.junit.jupiter</groupId>
35+
<artifactId>junit-jupiter-api</artifactId>
36+
<scope>test</scope>
37+
</dependency>
38+
<dependency>
39+
<groupId>org.junit.jupiter</groupId>
40+
<artifactId>junit-jupiter-engine</artifactId>
41+
<scope>test</scope>
42+
</dependency>
43+
</dependencies>
44+
45+
<build>
46+
<plugins>
47+
<plugin>
48+
<groupId>org.eclipse.sisu</groupId>
49+
<artifactId>sisu-maven-plugin</artifactId>
50+
</plugin>
51+
</plugins>
52+
</build>
53+
</project>

0 commit comments

Comments
 (0)