Skip to content

Commit 7bad9bd

Browse files
committed
Merge branch 'develop' into owls-69919-domain-resource-properties
2 parents c10d1ec + e41de3d commit 7bad9bd

File tree

16 files changed

+180
-115
lines changed

16 files changed

+180
-115
lines changed

integration-tests/src/test/java/oracle/kubernetes/operator/ITOperator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,9 @@ private Domain testAllUseCasesForADomain(Operator operator, String domainYamlFil
288288
logger.info("Creating Domain & verifing the domain creation");
289289
// create domain1
290290
Domain domain = testDomainCreation(domainYamlFile);
291+
testClusterScaling(operator, domain);
291292
testDomainLifecyle(operator, domain);
292293
testOperatorLifecycle(operator, domain);
293-
testClusterScaling(operator, domain);
294294
return domain;
295295
}
296296

integration-tests/src/test/resources/wldf/wldf.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from java.io import File
44
import sys, socket
55
import os
6+
import time as systime
67
hostname = socket.gethostname()
78

89
k8s_master_host=os.environ.get('KUBERNETES_SERVICE_HOST')
@@ -63,4 +64,22 @@
6364
wh1.addNotification(scriptAct)
6465

6566
save()
66-
activate()
67+
activate(block='true')
68+
69+
print "wait for harvester watch to become active"
70+
71+
domainRuntime()
72+
73+
cd('ServerRuntimes/admin-server/WLDFRuntime/WLDFRuntime/WLDFWatchNotificationRuntime/WatchNotification')
74+
75+
numWatchEval=cmo.getTotalHarvesterWatchEvaluations()
76+
maxwait=300
77+
78+
while(numWatchEval < 1) and (maxwait > 0):
79+
print numWatchEval
80+
maxwait -= 1
81+
systime.sleep(1)
82+
numWatchEval=cmo.getTotalHarvesterWatchEvaluations()
83+
84+
print "wldf.py done numWatchEval is ", numWatchEval, " maxwait is ", maxwait
85+

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
@@ -631,6 +631,8 @@ public String toString() {
631631
.appendSuper(super.toString())
632632
.append("domainUID", domainUID)
633633
.append("domainName", domainName)
634+
.append("domainHome", domainHome)
635+
.append("domainHomeInImage", domainHomeInImage)
634636
.append("adminSecret", adminSecret)
635637
.append("asName", asName)
636638
.append("asPort", asPort)
@@ -655,6 +657,8 @@ public int hashCode() {
655657
.appendSuper(super.hashCode())
656658
.append(domainUID)
657659
.append(domainName)
660+
.append(domainHome)
661+
.append(domainHomeInImage)
658662
.append(adminSecret)
659663
.append(asName)
660664
.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
@@ -19,6 +19,7 @@
1919
import io.kubernetes.client.util.Watch;
2020
import java.lang.reflect.ParameterizedType;
2121
import java.lang.reflect.Type;
22+
import java.util.concurrent.TimeUnit;
2223
import java.util.function.BiFunction;
2324
import oracle.kubernetes.operator.TuningParameters;
2425
import oracle.kubernetes.operator.helpers.ClientPool;
@@ -98,6 +99,9 @@ private class ListNamespacedServiceCall implements BiFunction<ApiClient, CallPar
9899

99100
@Override
100101
public Call apply(ApiClient client, CallParams callParams) {
102+
// Ensure that client doesn't time out before call or watch
103+
client.getHttpClient().setReadTimeout(callParams.getTimeoutSeconds(), TimeUnit.SECONDS);
104+
101105
try {
102106
return new CoreV1Api(client)
103107
.listNamespacedServiceCall(
@@ -140,6 +144,9 @@ private class ListPodCall implements BiFunction<ApiClient, CallParams, Call> {
140144

141145
@Override
142146
public Call apply(ApiClient client, CallParams callParams) {
147+
// Ensure that client doesn't time out before call or watch
148+
client.getHttpClient().setReadTimeout(callParams.getTimeoutSeconds(), TimeUnit.SECONDS);
149+
143150
try {
144151
return new CoreV1Api(client)
145152
.listNamespacedPodCall(
@@ -182,6 +189,9 @@ private class ListEventCall implements BiFunction<ApiClient, CallParams, Call> {
182189

183190
@Override
184191
public Call apply(ApiClient client, CallParams callParams) {
192+
// Ensure that client doesn't time out before call or watch
193+
client.getHttpClient().setReadTimeout(callParams.getTimeoutSeconds(), TimeUnit.SECONDS);
194+
185195
try {
186196
return new CoreV1Api(client)
187197
.listNamespacedEventCall(
@@ -224,6 +234,9 @@ private class ListIngressCall implements BiFunction<ApiClient, CallParams, Call>
224234

225235
@Override
226236
public Call apply(ApiClient client, CallParams callParams) {
237+
// Ensure that client doesn't time out before call or watch
238+
client.getHttpClient().setReadTimeout(callParams.getTimeoutSeconds(), TimeUnit.SECONDS);
239+
227240
try {
228241
return new ExtensionsV1beta1Api(client)
229242
.listNamespacedIngressCall(
@@ -266,6 +279,9 @@ private class ListDomainsCall implements BiFunction<ApiClient, CallParams, Call>
266279

267280
@Override
268281
public Call apply(ApiClient client, CallParams callParams) {
282+
// Ensure that client doesn't time out before call or watch
283+
client.getHttpClient().setReadTimeout(callParams.getTimeoutSeconds(), TimeUnit.SECONDS);
284+
269285
try {
270286
return new WeblogicApi(client)
271287
.listWebLogicOracleV2NamespacedDomainCall(
@@ -311,6 +327,9 @@ private class ListNamespacedConfigMapCall implements BiFunction<ApiClient, CallP
311327

312328
@Override
313329
public Call apply(ApiClient client, CallParams callParams) {
330+
// Ensure that client doesn't time out before call or watch
331+
client.getHttpClient().setReadTimeout(callParams.getTimeoutSeconds(), TimeUnit.SECONDS);
332+
314333
try {
315334
return new CoreV1Api(client)
316335
.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
}

0 commit comments

Comments
 (0)