Skip to content

Commit cba3b0c

Browse files
committed
Merge branch 'master' into feature/dynamic-cluster and additional cleanup
2 parents eea61ec + 966fc19 commit cba3b0c

31 files changed

+105
-144
lines changed

operator/src/main/java/oracle/kubernetes/operator/authentication/Authenticator.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ public class Authenticator {
3232

3333
private final String _SERVICE_HOST = "KUBERNETES_SERVICE_HOST";
3434
private final String _SERVICE_PORT = "KUBERNETES_SERVICE_PORT";
35-
private final String _TOKEN_PATH = "/var/run/secrets/kubernetes.io/serviceaccount/token";
36-
private final String _CACERT_PATH = "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt";
35+
//private final String _TOKEN_PATH = "/var/run/secrets/kubernetes.io/serviceaccount/token";
36+
//private final String _CACERT_PATH = "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt";
3737
private static final LoggingFacade LOGGER = LoggingFactory.getLogger("Operator", "Operator");
3838

3939
/**
@@ -46,7 +46,6 @@ public class Authenticator {
4646
public Authenticator() throws IOException {
4747
this.apiClient = Config.defaultClient();
4848
this.helper = new Helpers(this);
49-
SecretHelper.addCustomGsonToClient(this.apiClient);
5049
}
5150

5251
/**
@@ -167,7 +166,6 @@ private ApiClient authenticateByServiceAccount(V1ServiceAccount serviceAccount)
167166
newClient.setBasePath(serviceUrl);
168167
newClient.setApiKey("Bearer " + token);
169168
newClient.setSslCaCert(new ByteArrayInputStream(caCert));
170-
SecretHelper.addCustomGsonToClient(newClient);
171169

172170
LOGGER.exiting(newClient);
173171
return newClient;

operator/src/main/java/oracle/kubernetes/operator/authentication/Helpers.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
*/
2525
public class Helpers {
2626

27+
@SuppressWarnings("unused")
2728
private final Authenticator authenticator;
2829
private final ApiClient apiClient;
2930
private final CoreV1Api coreApi;

operator/src/main/java/oracle/kubernetes/operator/builders/UncheckedApiException.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* An exception used to bypass functional programming incompatability with checked exceptions. This is thrown
1010
* by a function object and the underlying ApiException is then rethrown by the caller of the function object.
1111
*/
12+
@SuppressWarnings("serial")
1213
class UncheckedApiException extends RuntimeException {
1314
UncheckedApiException(ApiException e) {
1415
super(e);

operator/src/main/java/oracle/kubernetes/operator/builders/WatchBuilder.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import java.lang.reflect.Type;
2828
import java.util.function.BiFunction;
2929

30-
@SuppressWarnings("WeakerAccess")
3130
public class WatchBuilder {
3231
/** Always true for watches. */
3332
private static final boolean WATCH = true;
@@ -244,10 +243,6 @@ public WatchBuilder withLabelSelectors(String... labelSelectors) {
244243
return this;
245244
}
246245

247-
private String asList(String... selectors) {
248-
return String.join(",", selectors);
249-
}
250-
251246
public WatchBuilder withLimit(Integer limit) {
252247
callParams.setLimit(limit);
253248
return this;

operator/src/main/java/oracle/kubernetes/operator/helpers/ClientPool.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,7 @@ private ApiClient getApiClient() {
4646
}
4747
LOGGER.info(MessageKeys.K8S_MASTER_URL, client != null ? client.getBasePath() : null);
4848

49-
// Temporarily set a custom Gson for secret support
50-
// TODO:
51-
SecretHelper.addCustomGsonToClient(client);
52-
53-
// TEST
49+
// Ensure that client doesn't time out before call or watch
5450
client.getHttpClient().setReadTimeout(5, TimeUnit.MINUTES);
5551

5652
LOGGER.exiting(client);

operator/src/main/java/oracle/kubernetes/operator/helpers/SecretHelper.java

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,7 @@
33

44
package oracle.kubernetes.operator.helpers;
55

6-
import com.google.gson.Gson;
7-
import com.google.gson.GsonBuilder;
8-
import com.google.gson.JsonDeserializationContext;
9-
import com.google.gson.JsonDeserializer;
10-
import com.google.gson.JsonElement;
11-
import com.google.gson.JsonParseException;
12-
import com.google.gson.JsonPrimitive;
13-
import com.google.gson.JsonSerializationContext;
14-
import com.google.gson.JsonSerializer;
15-
import io.kubernetes.client.ApiClient;
166
import io.kubernetes.client.ApiException;
17-
import io.kubernetes.client.JSON;
187
import io.kubernetes.client.models.V1Secret;
198
import oracle.kubernetes.operator.logging.LoggingFacade;
209
import oracle.kubernetes.operator.logging.LoggingFactory;
@@ -24,11 +13,6 @@
2413
import oracle.kubernetes.operator.work.Packet;
2514
import oracle.kubernetes.operator.work.Step;
2615

27-
import org.joda.time.DateTime;
28-
29-
import java.lang.reflect.Type;
30-
import java.util.Base64;
31-
import java.util.Date;
3216
import java.util.HashMap;
3317
import java.util.List;
3418
import java.util.Map;
@@ -174,43 +158,4 @@ private static Map<String, byte[]> harvestAdminSecretData(V1Secret secret) {
174158
return secretData;
175159
}
176160

177-
// Due to issue with kubernetes-client/java (com.google.gson.JsonSyntaxException when deserialize V1Secret)
178-
// Issue #131
179-
// Add a custom Gson to the client so secrets can be decoded.
180-
181-
/**
182-
* Add custom Gson to client
183-
* @param apiClient API client
184-
*/
185-
public static void addCustomGsonToClient(ApiClient apiClient) {
186-
187-
LOGGER.entering();
188-
189-
JSON.DateTypeAdapter dateTypeAdapter = new JSON.DateTypeAdapter();
190-
JSON.SqlDateTypeAdapter sqlDateTypeAdapter = new JSON.SqlDateTypeAdapter();
191-
JSON.DateTimeTypeAdapter dateTimeTypeAdapter = new JSON.DateTimeTypeAdapter();
192-
193-
Gson customGson =
194-
(new GsonBuilder()).registerTypeAdapter(
195-
Date.class, dateTypeAdapter).registerTypeAdapter(
196-
java.sql.Date.class, sqlDateTypeAdapter).registerTypeAdapter(
197-
DateTime.class, dateTimeTypeAdapter).registerTypeAdapter(
198-
byte[].class, new ByteArrayBase64StringTypeAdapter()).create();
199-
200-
apiClient.getJSON().setGson(customGson);
201-
202-
LOGGER.exiting();
203-
}
204-
205-
private static class ByteArrayBase64StringTypeAdapter implements JsonSerializer<byte[]>, JsonDeserializer<byte[]> {
206-
207-
public byte[] deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
208-
return Base64.getUrlDecoder().decode(json.getAsString());
209-
}
210-
211-
public JsonElement serialize(byte[] src, Type typeOfSrc, JsonSerializationContext context) {
212-
return new JsonPrimitive(Base64.getUrlEncoder().encodeToString(src));
213-
}
214-
}
215-
216161
}

operator/src/main/java/oracle/kubernetes/operator/rest/BaseDebugLoggingFilter.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import java.util.ArrayList;
1616
import java.util.Date;
1717
import java.util.List;
18-
import java.util.logging.Level;
1918

2019
/**
2120
* BaseDebugLoggingFilter provides utilities shared by RequestDebugLoggingFilter and
@@ -48,7 +47,7 @@ protected String getLoggableHeaders(ContainerRequestContext req) {
4847

4948
// Make a copy of all of the request headers
5049
MultivaluedHashMap<String,String> loggableHeaders =
51-
new MultivaluedHashMap(req.getHeaders());
50+
new MultivaluedHashMap<String, String>(req.getHeaders());
5251

5352
// Authorization headers contain credentials. These credentials should not be
5453
// debug logged since they contain sensitive data.
@@ -58,7 +57,7 @@ protected String getLoggableHeaders(ContainerRequestContext req) {
5857
for (String key : loggableHeaders.keySet()) {
5958
if (atz.equals(key.toLowerCase())) {
6059
// make a copy of all the atz header values
61-
List<String> vals = new ArrayList(loggableHeaders.get(key));
60+
List<String> vals = new ArrayList<>(loggableHeaders.get(key));
6261
// hide the sensitive data in the atz header values
6362
for (int i = 0; i < vals.size(); i++) {
6463
// By definition, the value of an Authorization header should be in the form

operator/src/main/java/oracle/kubernetes/operator/rest/RestServer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public class RestServer {
6060

6161
private RestConfig config;
6262

63-
private String baseHttpUri;
63+
//private String baseHttpUri;
6464
private String baseExternalHttpsUri;
6565
private String baseInternalHttpsUri;
6666

@@ -155,12 +155,12 @@ public void start(Container container) throws Exception {
155155
public void stop() {
156156
LOGGER.entering();
157157
if (externalHttpsServer != null) {
158-
externalHttpsServer.stop();
158+
externalHttpsServer.shutdownNow();
159159
externalHttpsServer = null;
160160
LOGGER.info("Stopped the external ssl REST server"); // TBD .fine ?
161161
}
162162
if (internalHttpsServer != null) {
163-
internalHttpsServer.stop();
163+
internalHttpsServer.shutdownNow();
164164
internalHttpsServer = null;
165165
LOGGER.info("Stopped the internal ssl REST server"); // TBD .fine ?
166166
}
@@ -281,7 +281,7 @@ private ResourceConfig createResourceConfig() {
281281
.register(ResponseDebugLoggingFilter.class)
282282
.register(ExceptionMapper.class)
283283
.packages("oracle.kubernetes.operator.rest.resource");
284-
Map<String, Object> extraProps = new HashMap();
284+
Map<String, Object> extraProps = new HashMap<>();
285285

286286
// attach the rest backend impl to the resource config
287287
// so that the resource impls can find it

operator/src/main/java/oracle/kubernetes/operator/rest/resource/SwaggerResource.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import java.io.InputStream;
77

88
import javax.ws.rs.GET;
9-
import javax.ws.rs.Path;
109
import javax.ws.rs.Produces;
1110
import javax.ws.rs.core.MediaType;
1211

operator/src/main/java/oracle/kubernetes/operator/wlsconfig/WlsClusterConfig.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,11 @@ public WlsClusterConfig(String clusterName, WlsDynamicServersConfig dynamicServe
5555
*
5656
* @return A new WlsClusterConfig object created based on the JSON result
5757
*/
58+
@SuppressWarnings("unchecked")
5859
static WlsClusterConfig create(Map<String, Object> clusterConfigMap, Map<String, WlsServerConfig> serverTemplates, String domainName) {
5960
String clusterName = (String) clusterConfigMap.get("name");
6061
WlsDynamicServersConfig dynamicServersConfig =
61-
WlsDynamicServersConfig.create((Map) clusterConfigMap.get("dynamicServers"), serverTemplates, clusterName, domainName);
62+
WlsDynamicServersConfig.create((Map<String, Object>) clusterConfigMap.get("dynamicServers"), serverTemplates, clusterName, domainName);
6263
// set dynamicServersConfig only if the cluster contains dynamic servers, i.e., its dynamic servers configuration
6364
// contains non-null server template name
6465
if (dynamicServersConfig.getServerTemplate() == null) {

0 commit comments

Comments
 (0)