Skip to content

Commit c60bbb7

Browse files
committed
Merge branch 'develop' into domain-introspector
Conflicts: operator/src/main/java/oracle/kubernetes/operator/steps/ManagedServersUpStep.java
2 parents 5ac0155 + e41de3d commit c60bbb7

File tree

14 files changed

+161
-111
lines changed

14 files changed

+161
-111
lines changed

model/src/main/java/oracle/kubernetes/weblogic/domain/v2/DomainSpec.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,8 @@ public String toString() {
627627
.appendSuper(super.toString())
628628
.append("domainUID", domainUID)
629629
.append("domainName", domainName)
630+
.append("domainHome", domainHome)
631+
.append("domainHomeInImage", domainHomeInImage)
630632
.append("adminSecret", adminSecret)
631633
.append("asName", asName)
632634
.append("asPort", asPort)
@@ -653,6 +655,8 @@ public int hashCode() {
653655
.appendSuper(super.hashCode())
654656
.append(domainUID)
655657
.append(domainName)
658+
.append(domainHome)
659+
.append(domainHomeInImage)
656660
.append(adminSecret)
657661
.append(asName)
658662
.append(asPort)
@@ -683,6 +687,8 @@ public boolean equals(Object other) {
683687
.appendSuper(super.equals(other))
684688
.append(domainUID, rhs.domainUID)
685689
.append(domainName, rhs.domainName)
690+
.append(domainHome, rhs.domainHome)
691+
.append(domainHomeInImage, rhs.domainHomeInImage)
686692
.append(adminSecret, rhs.adminSecret)
687693
.append(asName, rhs.asName)
688694
.append(asPort, rhs.asPort)

operator/src/main/java/oracle/kubernetes/operator/Main.java

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import oracle.kubernetes.operator.steps.ConfigMapAfterStep;
4848
import oracle.kubernetes.operator.work.Component;
4949
import oracle.kubernetes.operator.work.Container;
50+
import oracle.kubernetes.operator.work.ContainerResolver;
5051
import oracle.kubernetes.operator.work.Engine;
5152
import oracle.kubernetes.operator.work.Fiber.CompletionCallback;
5253
import oracle.kubernetes.operator.work.NextAction;
@@ -58,20 +59,32 @@
5859

5960
/** A Kubernetes Operator for WebLogic. */
6061
public class Main {
61-
62-
private static ThreadFactory getThreadFactory() {
63-
return ThreadFactorySingleton.getInstance();
64-
}
65-
6662
private static final LoggingFacade LOGGER = LoggingFactory.getLogger("Operator", "Operator");
6763

6864
private static final String DPI_MAP = "DPI_MAP";
6965

66+
private static final Container container = new Container();
67+
68+
private static class WrappedThreadFactory implements ThreadFactory {
69+
private final ThreadFactory delegate = ThreadFactorySingleton.getInstance();
70+
71+
@Override
72+
public Thread newThread(Runnable r) {
73+
return delegate.newThread(
74+
() -> {
75+
ContainerResolver.getDefault().enterContainer(container);
76+
r.run();
77+
});
78+
}
79+
}
80+
81+
private static final ThreadFactory threadFactory = new WrappedThreadFactory();
82+
7083
static final TuningParameters tuningAndConfig;
7184

7285
static {
7386
try {
74-
TuningParameters.initializeInstance(getThreadFactory(), "/operator/config");
87+
TuningParameters.initializeInstance(threadFactory, "/operator/config");
7588
tuningAndConfig = TuningParameters.getInstance();
7689
} catch (IOException e) {
7790
LOGGER.warning(MessageKeys.EXCEPTION, e);
@@ -81,7 +94,6 @@ private static ThreadFactory getThreadFactory() {
8194

8295
private static final CallBuilderFactory callBuilderFactory = new CallBuilderFactory();
8396

84-
private static final Container container = new Container();
8597
private static final ScheduledExecutorService wrappedExecutorService =
8698
Engine.wrappedExecutorService("operator", container);
8799

@@ -96,7 +108,7 @@ private static ThreadFactory getThreadFactory() {
96108
TuningParameters.class,
97109
tuningAndConfig,
98110
ThreadFactory.class,
99-
getThreadFactory(),
111+
threadFactory,
100112
callBuilderFactory));
101113
}
102114

@@ -428,7 +440,7 @@ private static void waitForDeath() {
428440

429441
private static EventWatcher createEventWatcher(String ns, String initialResourceVersion) {
430442
return EventWatcher.create(
431-
getThreadFactory(),
443+
threadFactory,
432444
ns,
433445
READINESS_PROBE_FAILURE_EVENT_FILTER,
434446
initialResourceVersion,
@@ -438,7 +450,7 @@ private static EventWatcher createEventWatcher(String ns, String initialResource
438450

439451
private static PodWatcher createPodWatcher(String ns, String initialResourceVersion) {
440452
return PodWatcher.create(
441-
getThreadFactory(),
453+
threadFactory,
442454
ns,
443455
initialResourceVersion,
444456
processor::dispatchPodWatch,
@@ -447,7 +459,7 @@ private static PodWatcher createPodWatcher(String ns, String initialResourceVers
447459

448460
private static ServiceWatcher createServiceWatcher(String ns, String initialResourceVersion) {
449461
return ServiceWatcher.create(
450-
getThreadFactory(),
462+
threadFactory,
451463
ns,
452464
initialResourceVersion,
453465
processor::dispatchServiceWatch,
@@ -456,13 +468,22 @@ private static ServiceWatcher createServiceWatcher(String ns, String initialReso
456468

457469
private static IngressWatcher createIngressWatcher(String ns, String initialResourceVersion) {
458470
return IngressWatcher.create(
459-
getThreadFactory(),
471+
threadFactory,
460472
ns,
461473
initialResourceVersion,
462474
processor::dispatchIngressWatch,
463475
isNamespaceStopping(ns));
464476
}
465477

478+
private static DomainWatcher createDomainWatcher(String ns, String initialResourceVersion) {
479+
return DomainWatcher.create(
480+
threadFactory,
481+
ns,
482+
initialResourceVersion,
483+
processor::dispatchDomainWatch,
484+
isNamespaceStopping(ns));
485+
}
486+
466487
static String getOperatorNamespace() {
467488
String namespace = System.getenv("OPERATOR_NAMESPACE");
468489
if (namespace == null) {
@@ -582,15 +603,6 @@ public NextAction onSuccess(Packet packet, CallResponse<DomainList> callResponse
582603
String getResourceVersion(DomainList result) {
583604
return result != null ? result.getMetadata().getResourceVersion() : "";
584605
}
585-
586-
private static DomainWatcher createDomainWatcher(String ns, String initialResourceVersion) {
587-
return DomainWatcher.create(
588-
getThreadFactory(),
589-
ns,
590-
initialResourceVersion,
591-
processor::dispatchDomainWatch,
592-
isNamespaceStopping(ns));
593-
}
594606
}
595607

596608
private static class ServiceListStep extends ResponseStep<V1ServiceList> {

operator/src/main/java/oracle/kubernetes/operator/TuningParametersImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ private void update() {
5151
MainTuning main =
5252
new MainTuning(
5353
(int) readTuningParameter("domainPresenceFailureRetrySeconds", 10),
54-
(int) readTuningParameter("domainPresenceRecheckIntervalSeconds", 60),
54+
(int) readTuningParameter("domainPresenceRecheckIntervalSeconds", 120),
5555
(int) readTuningParameter("statusUpdateTimeoutSeconds", 10),
5656
(int) readTuningParameter("statusUpdateUnchangedCountToDelayStatusRecheck", 10),
5757
readTuningParameter("statusUpdateInitialShortDelay", 3),
@@ -63,7 +63,7 @@ private void update() {
6363
(int) readTuningParameter("callMaxRetryCount", 5),
6464
(int) readTuningParameter("callTimeoutSeconds", 10));
6565

66-
WatchTuning watch = new WatchTuning((int) readTuningParameter("watchLifetime", 45));
66+
WatchTuning watch = new WatchTuning((int) readTuningParameter("watchLifetime", 300));
6767

6868
PodTuning pod =
6969
new PodTuning(

operator/src/main/java/oracle/kubernetes/operator/Watcher.java

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,9 @@ private boolean isError(Watch.Response<T> item) {
141141
}
142142

143143
private void handleRegularUpdate(Watch.Response<T> item) {
144-
if (isFresh(item.type, item.object)) {
145-
LOGGER.fine(MessageKeys.WATCH_EVENT, item.type, item.object);
146-
trackResourceVersion(item.type, item.object);
147-
if (listener != null) listener.receivedResponse(item);
148-
}
144+
LOGGER.fine(MessageKeys.WATCH_EVENT, item.type, item.object);
145+
trackResourceVersion(item.type, item.object);
146+
if (listener != null) listener.receivedResponse(item);
149147
}
150148

151149
private void handleErrorResponse(Watch.Response<T> item) {
@@ -176,8 +174,9 @@ private void trackResourceVersion(String type, Object object) {
176174
}
177175

178176
private long getNewResourceVersion(String type, Object object) {
179-
if (type.equalsIgnoreCase("DELETED")) return 1 + resourceVersion;
180-
else return getResourceVersionFromMetadata(object);
177+
long newResourceVersion = getResourceVersionFromMetadata(object);
178+
if (type.equalsIgnoreCase("DELETED")) return 1 + newResourceVersion;
179+
else return newResourceVersion;
181180
}
182181

183182
private long getResourceVersionFromMetadata(Object object) {
@@ -192,14 +191,6 @@ private long getResourceVersionFromMetadata(Object object) {
192191
}
193192
}
194193

195-
private boolean isFresh(String type, Object object) {
196-
if (resourceVersion == 0) return true;
197-
long newResourceVersion = getResourceVersionFromMetadata(object);
198-
return type.equalsIgnoreCase("DELETED")
199-
? newResourceVersion >= resourceVersion
200-
: newResourceVersion > resourceVersion;
201-
}
202-
203194
private void updateResourceVersion(long newResourceVersion) {
204195
if (resourceVersion == 0) resourceVersion = newResourceVersion;
205196
else if (newResourceVersion > resourceVersion) resourceVersion = newResourceVersion;

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import io.kubernetes.client.util.Watch;
2222
import java.lang.reflect.ParameterizedType;
2323
import java.lang.reflect.Type;
24+
import java.util.concurrent.TimeUnit;
2425
import java.util.function.BiFunction;
2526
import oracle.kubernetes.operator.TuningParameters;
2627
import oracle.kubernetes.operator.helpers.ClientPool;
@@ -100,6 +101,9 @@ private class ListNamespacedServiceCall implements BiFunction<ApiClient, CallPar
100101

101102
@Override
102103
public Call apply(ApiClient client, CallParams callParams) {
104+
// Ensure that client doesn't time out before call or watch
105+
client.getHttpClient().setReadTimeout(callParams.getTimeoutSeconds(), TimeUnit.SECONDS);
106+
103107
try {
104108
return new CoreV1Api(client)
105109
.listNamespacedServiceCall(
@@ -142,6 +146,9 @@ private class ListPodCall implements BiFunction<ApiClient, CallParams, Call> {
142146

143147
@Override
144148
public Call apply(ApiClient client, CallParams callParams) {
149+
// Ensure that client doesn't time out before call or watch
150+
client.getHttpClient().setReadTimeout(callParams.getTimeoutSeconds(), TimeUnit.SECONDS);
151+
145152
try {
146153
return new CoreV1Api(client)
147154
.listNamespacedPodCall(
@@ -226,6 +233,9 @@ private class ListEventCall implements BiFunction<ApiClient, CallParams, Call> {
226233

227234
@Override
228235
public Call apply(ApiClient client, CallParams callParams) {
236+
// Ensure that client doesn't time out before call or watch
237+
client.getHttpClient().setReadTimeout(callParams.getTimeoutSeconds(), TimeUnit.SECONDS);
238+
229239
try {
230240
return new CoreV1Api(client)
231241
.listNamespacedEventCall(
@@ -268,6 +278,9 @@ private class ListIngressCall implements BiFunction<ApiClient, CallParams, Call>
268278

269279
@Override
270280
public Call apply(ApiClient client, CallParams callParams) {
281+
// Ensure that client doesn't time out before call or watch
282+
client.getHttpClient().setReadTimeout(callParams.getTimeoutSeconds(), TimeUnit.SECONDS);
283+
271284
try {
272285
return new ExtensionsV1beta1Api(client)
273286
.listNamespacedIngressCall(
@@ -310,6 +323,9 @@ private class ListDomainsCall implements BiFunction<ApiClient, CallParams, Call>
310323

311324
@Override
312325
public Call apply(ApiClient client, CallParams callParams) {
326+
// Ensure that client doesn't time out before call or watch
327+
client.getHttpClient().setReadTimeout(callParams.getTimeoutSeconds(), TimeUnit.SECONDS);
328+
313329
try {
314330
return new WeblogicApi(client)
315331
.listWebLogicOracleV2NamespacedDomainCall(
@@ -355,6 +371,9 @@ private class ListNamespacedConfigMapCall implements BiFunction<ApiClient, CallP
355371

356372
@Override
357373
public Call apply(ApiClient client, CallParams callParams) {
374+
// Ensure that client doesn't time out before call or watch
375+
client.getHttpClient().setReadTimeout(callParams.getTimeoutSeconds(), TimeUnit.SECONDS);
376+
358377
try {
359378
return new CoreV1Api(client)
360379
.listNamespacedConfigMapCall(

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import io.kubernetes.client.Configuration;
99
import io.kubernetes.client.util.Config;
1010
import java.io.IOException;
11-
import java.util.concurrent.TimeUnit;
1211
import java.util.concurrent.atomic.AtomicBoolean;
1312
import oracle.kubernetes.operator.logging.LoggingFacade;
1413
import oracle.kubernetes.operator.logging.LoggingFactory;
@@ -26,6 +25,8 @@ public static ClientPool getInstance() {
2625
return SINGLETON;
2726
}
2827

28+
private final AtomicBoolean isFirst = new AtomicBoolean(true);
29+
2930
private ClientPool() {}
3031

3132
@Override
@@ -52,10 +53,10 @@ private ApiClient getApiClient() {
5253
} catch (Throwable e) {
5354
LOGGER.warning(MessageKeys.EXCEPTION, e);
5455
}
55-
LOGGER.info(MessageKeys.K8S_MASTER_URL, client != null ? client.getBasePath() : null);
5656

57-
// Ensure that client doesn't time out before call or watch
58-
client.getHttpClient().setReadTimeout(5, TimeUnit.MINUTES);
57+
if (isFirst.compareAndSet(true, false)) {
58+
LOGGER.info(MessageKeys.K8S_MASTER_URL, client != null ? client.getBasePath() : null);
59+
}
5960

6061
LOGGER.exiting(client);
6162
return client;

operator/src/main/java/oracle/kubernetes/operator/steps/ConfigMapAfterStep.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
import oracle.kubernetes.operator.ConfigMapWatcher;
1212
import oracle.kubernetes.operator.ProcessingConstants;
1313
import oracle.kubernetes.operator.watcher.WatchListener;
14+
import oracle.kubernetes.operator.work.ContainerResolver;
1415
import oracle.kubernetes.operator.work.NextAction;
1516
import oracle.kubernetes.operator.work.Packet;
1617
import oracle.kubernetes.operator.work.Step;
17-
import oracle.kubernetes.operator.work.ThreadFactorySingleton;
1818

1919
public class ConfigMapAfterStep extends Step {
2020
private final String ns;
@@ -46,7 +46,8 @@ public NextAction apply(Packet packet) {
4646
}
4747

4848
private ConfigMapWatcher createConfigMapWatcher(String namespace, String initialResourceVersion) {
49-
ThreadFactory factory = ThreadFactorySingleton.getInstance();
49+
ThreadFactory factory =
50+
ContainerResolver.getInstance().getContainer().getSPI(ThreadFactory.class);
5051

5152
return ConfigMapWatcher.create(factory, namespace, initialResourceVersion, listener, stopping);
5253
}

operator/src/main/java/oracle/kubernetes/operator/steps/ManagedServersUpStep.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,7 @@
44

55
package oracle.kubernetes.operator.steps;
66

7-
import java.util.ArrayList;
8-
import java.util.Collection;
9-
import java.util.Collections;
10-
import java.util.HashMap;
11-
import java.util.List;
12-
import java.util.Map;
13-
import java.util.Optional;
7+
import java.util.*;
148
import javax.annotation.Nonnull;
159
import oracle.kubernetes.operator.DomainStatusUpdater;
1610
import oracle.kubernetes.operator.helpers.DomainPresenceInfo;
@@ -109,12 +103,20 @@ public NextAction apply(Packet packet) {
109103
factory.addServerIfNeeded(serverConfig, null);
110104
}
111105

106+
Set<String> clusteredServers = new HashSet<>();
107+
112108
for (WlsClusterConfig clusterConfig : config.getClusterConfigs().values()) {
113109
for (WlsServerConfig serverConfig : clusterConfig.getServerConfigs()) {
114110
factory.addServerIfNeeded(serverConfig, clusterConfig);
111+
clusteredServers.add(serverConfig.getName());
115112
}
116113
}
117114

115+
for (WlsServerConfig serverConfig : config.getServerConfigs().values()) {
116+
if (!clusteredServers.contains(serverConfig.getName()))
117+
factory.addServerIfNeeded(serverConfig, null);
118+
}
119+
118120
info.setServerStartupInfo(factory.getStartupInfos());
119121
LOGGER.exiting();
120122
return doNext(

0 commit comments

Comments
 (0)