Skip to content

Commit 5a1ea8e

Browse files
committed
Merge branch 'reconciler' into 'main'
Switch to reconciliation model, simplify step processing, and consistently use GenericKubernetesApi See merge request weblogic-cloud/weblogic-kubernetes-operator!4631
2 parents cbe0ad9 + 979e406 commit 5a1ea8e

File tree

253 files changed

+7820
-17355
lines changed

Some content is hidden

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

253 files changed

+7820
-17355
lines changed

common/src/main/java/oracle/kubernetes/common/logging/MessageKeys.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,6 @@ public class MessageKeys {
6464
public static final String WAITING_FOR_POD_READY = "WLSKO-0087";
6565
public static final String POD_IS_READY = "WLSKO-0088";
6666
public static final String POD_IS_FAILED = "WLSKO-0089";
67-
public static final String ASYNC_REQUEST = "WLSKO-0094";
68-
public static final String ASYNC_FAILURE = "WLSKO-0095";
69-
public static final String ASYNC_SUCCESS = "WLSKO-0096";
70-
public static final String ASYNC_NO_RETRY = "WLSKO-0097";
71-
public static final String ASYNC_RETRY = "WLSKO-0098";
72-
public static final String ASYNC_TIMEOUT = "WLSKO-0099";
7367
public static final String WATCH_EVENT = "WLSKO-0101";
7468
public static final String DOMAIN_STATUS = "WLSKO-0102";
7569
public static final String INVALID_MANAGE_SERVER_COUNT = "WLSKO-0103";
@@ -80,7 +74,6 @@ public class MessageKeys {
8074
public static final String NULL_TOKEN_REVIEW_STATUS = "WLSKO-0109";
8175
public static final String NULL_USER_INFO = "WLSKO-0110";
8276
public static final String RESOURCE_BUNDLE_NOT_FOUND = "WLSKO-0111";
83-
public static final String CURRENT_STEPS = "WLSKO-0112";
8477
public static final String CYCLING_SERVERS = "WLSKO-0118";
8578
public static final String ROLLING_SERVERS = "WLSKO-0119";
8679
public static final String ADMIN_POD_PATCHED = "WLSKO-0120";
@@ -109,12 +102,8 @@ public class MessageKeys {
109102
public static final String DOMAIN_VALIDATION_FAILED = "WLSKO-0157";
110103
public static final String NO_INTERNAL_CERTIFICATE = "WLSKO-162";
111104
public static final String NO_EXTERNAL_CERTIFICATE = "WLSKO-163";
112-
public static final String REQUEST_PARAMS_IN_NS = "WLSKO-0165";
113-
public static final String REQUEST_PARAMS_FOR_NAME = "WLSKO-0166";
114-
public static final String REQUEST_PARAMS_WITH = "WLSKO-0167";
115105
public static final String CALL_FAILED = "WLSKO-0168";
116106
public static final String JOB_CREATION_TIMESTAMP_MESSAGE = "WLSKO-0169";
117-
public static final String HTTP_REQUEST_TIMED_OUT = "WLSKO-0170";
118107
public static final String NAMESPACE_IS_MISSING = "WLSKO-0171";
119108
public static final String CM_PATCHED = "WLSKO-0172";
120109
public static final String REPLACE_CRD_FAILED = "WLSKO-0173";

common/src/main/resources/Operator.properties

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,10 @@ WLSKO-0002=The Kubernetes Master URL is set to {0}
44
WLSKO-0003=The following optional operator features are enabled: {0}
55
WLSKO-0005=The Oracle WebLogic Kubernetes Operator is shutting down
66
WLSKO-0006=Exception thrown {0}
7-
WLSKO-0007={0}
87
WLSKO-0012=Create Custom Resource Definition: {0}
98
WLSKO-0018={2} secret ''{0}'' not found in namespace ''{1}''
109
WLSKO-0019=Retrieving secret: {0}
1110
WLSKO-0020=Secret data field not found: {0}
12-
WLSKO-0021=Read server configurations from administration server took {0} ms. Configuration read: {1}
13-
WLSKO-0026=Fail to parse REST response from WLS. Json response is {0}. Exception is {1}
1411
WLSKO-0028=No servers configured in WebLogic cluster with name {0}
1512
WLSKO-0029=Verifying that operator service account can access required operations on required resources in namespace {0}
1613
WLSKO-0030=Access denied for operator service account for operation {0} on resource {1}
@@ -58,12 +55,6 @@ WLSKO-0085=Operator service account is: {0}
5855
WLSKO-0087=Waiting for pod {0} to be ready
5956
WLSKO-0088=Pod {0} is ready
6057
WLSKO-0089=Pod {0} has failed
61-
WLSKO-0094=Async call {0} invoking: {1}, namespace: {2}, name: {3}, body: {4}, fieldSelector: {5}, labelSelector: {6}, resourceVersion: {7}
62-
WLSKO-0095=Async call {0} invoking: {1}, failed: {2}, code: {3}, headers {4}, namespace: {5}, name: {6}, body: {7}, fieldSelector: {8}, labelSelector: {9}, resourceVersion: {10}, response body: {11}
63-
WLSKO-0096=Async call {0} invoking: {1} succeeded: {2}, code: {3}, headers {4}
64-
WLSKO-0097=Async call {0} invoking: {1}, will not be retried: {2}, code: {3}, headers {4}, namespace: {5}, name: {6}, body: {7}, fieldSelector: {8}, labelSelector: {9}, resourceVersion: {10}, response body: {11}
65-
WLSKO-0098=Async call {0} will be retried after delay: {1} ms: {2}, namespace: {3}, name: {4}
66-
WLSKO-0099=Async call {0} timed-out invoking: {1}, namespace: {2}, name: {3}, body: {4}, fieldSelector: {5}, labelSelector: {6}, resourceVersion: {7}
6758
WLSKO-0101=Watch event: {0}, object: {1}
6859
WLSKO-0102=Status for Domain with UID {0} is now: {1}
6960
WLSKO-0103=Specified managed server count parameter of {0} is invalid. Please specify a positive managed server count for scaling
@@ -74,13 +65,11 @@ WLSKO-0108=Null domainUID
7465
WLSKO-0109=Null V1TokenReviewStatus
7566
WLSKO-0110=Null userInfo {0}
7667
WLSKO-0111=Could not find the resource bundle
77-
WLSKO-0112=Steps on current fiber {0}
7868
WLSKO-0118=Cycling of servers for Domain with UID {0} in the list {1} now
7969
WLSKO-0119=Rolling of servers for Domain with UID {0} in the list {1} now with ready servers {2}
8070
WLSKO-0120=Patching administration server Pod for WebLogic domain with UID: {0}. Administration server name: {1}.
8171
WLSKO-0121=Patching managed server Pod for WebLogic domain with UID: {0}. Managed server name: {1}.
8272
WLSKO-0122=Pod for domain with domainUID {0} in namespace {1} and with server name {2} deleted; validating domain
83-
WLSKO-0126=Reloading tuning parameters from Operator's config map
8473
WLSKO-0127=Failed to read health information from server {0}
8574
WLSKO-0133=Cannot find WebLogic server template with name {0} which is referenced by WebLogic cluster {1}
8675
WLSKO-0134=Loading scripts into domain control config map for namespace: {0}
@@ -92,7 +81,6 @@ WLSKO-0140=Job {0} is completed with status: {1}
9281
WLSKO-0141=Failed to parse WebLogic Domain topology due to exception: {0}
9382
WLSKO-0142=Failed to parse results from domain introspector for domain {0} due to exception: {1}
9483
WLSKO-0143=Failed to parse file {0} from domain introspector for domain {1} due to exception: {2}
95-
WLSKO-0144=Unable to start domain with domainUID {0} in namespace {1} after {2} attempts due to exception: {3}
9684
WLSKO-0145=Replacing pod {0}
9785
WLSKO-0146=Replica request of {0} exceeds the maximum dynamic server count of {1} configured for cluster {2}
9886
WLSKO-0148=Current Pod dump [{0}] vs expected pod [{1}].
@@ -114,12 +102,8 @@ WLSKO-0156=Access denied for operator service account for operation {0} on resou
114102
WLSKO-0157=Domain {0} is not valid: {1}
115103
WLSKO-162=Unable to read internal certificate at path {0}
116104
WLSKO-163=No external certificate configured for REST endpoint. Endpoint will be disabled.
117-
WLSKO-0165=in namespace {0}
118-
WLSKO-0166=for {0}
119-
WLSKO-0167=with {0}
120105
WLSKO-0168={0}: {1}
121106
WLSKO-0169=Job {0} is created at {1}
122-
WLSKO-0170=HTTP timeout: {0}.
123107
WLSKO-0171=Namespace {0} is in operator's domain namespaces list but doesn't exist
124108
WLSKO-0173=Replace custom resource definition failed: {0}
125109
WLSKO-0174=Create custom resource definition failed: {0}

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItIntrospectVersion.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1369,7 +1369,6 @@ private static void verifyMemberHealth(String adminServerPodName, List<String> m
13691369
} else {
13701370
// In non-internal OKE env, verifyMemberHealth using adminSvcExtHost by sending HTTP request from local VM
13711371

1372-
// TEST, HERE
13731372
String extSvcPodName = getExternalServicePodName(adminServerPodName);
13741373
logger.info("**** adminServerPodName={0}", adminServerPodName);
13751374
logger.info("**** extSvcPodName={0}", extSvcPodName);

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiDomainModelInPV.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,6 @@ void testMiiDomainWithModelAndApplicationInPV(Parameters params) {
259259
logger.info("Creating domain custom resource with domainUid {0} and image {1}",
260260
domainUid, image);
261261

262-
// HERE -- looking for where nodePort value is set
263-
264262
DomainResource domainCR = CommonMiiTestUtils.createDomainResource(domainUid, domainNamespace,
265263
image, adminSecretName, createSecretsForImageRepos(domainNamespace), encryptionSecretName,
266264
2, List.of(clusterName), true, params.nodePort);
@@ -361,7 +359,6 @@ private static void verifyMemberHealth(String adminServerPodName, List<String> m
361359
} else {
362360
// In non-internal OKE env, verifyMemberHealth using adminSvcExtHost by sending HTTP request from local VM
363361

364-
// TEST, HERE
365362
String extSvcPodName = getExternalServicePodName(adminServerPodName);
366363
logger.info("**** adminServerPodName={0}", adminServerPodName);
367364
logger.info("**** extSvcPodName={0}", extSvcPodName);

operator/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,11 @@
415415
<artifactId>client-java</artifactId>
416416
</dependency>
417417

418+
<dependency>
419+
<groupId>io.kubernetes</groupId>
420+
<artifactId>client-java-extended</artifactId>
421+
</dependency>
422+
418423
<dependency>
419424
<groupId>io.kubernetes</groupId>
420425
<artifactId>client-java-api-fluent</artifactId>

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

Lines changed: 15 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2022, 2023, Oracle and/or its affiliates.
1+
// Copyright (c) 2022, 2024, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.kubernetes.operator;
@@ -24,11 +24,8 @@
2424
import java.util.concurrent.ThreadFactory;
2525
import java.util.concurrent.TimeUnit;
2626
import java.util.concurrent.atomic.AtomicReference;
27-
import javax.annotation.Nonnull;
2827

2928
import oracle.kubernetes.common.logging.MessageKeys;
30-
import oracle.kubernetes.operator.calls.UnrecoverableCallException;
31-
import oracle.kubernetes.operator.helpers.ClientPool;
3229
import oracle.kubernetes.operator.helpers.HelmAccess;
3330
import oracle.kubernetes.operator.http.BaseServer;
3431
import oracle.kubernetes.operator.http.metrics.MetricsServer;
@@ -38,13 +35,10 @@
3835
import oracle.kubernetes.operator.logging.LoggingFactory;
3936
import oracle.kubernetes.operator.tuning.TuningParameters;
4037
import oracle.kubernetes.operator.utils.PathSupport;
41-
import oracle.kubernetes.operator.work.Component;
42-
import oracle.kubernetes.operator.work.Container;
43-
import oracle.kubernetes.operator.work.ContainerResolver;
44-
import oracle.kubernetes.operator.work.Engine;
4538
import oracle.kubernetes.operator.work.Fiber.CompletionCallback;
4639
import oracle.kubernetes.operator.work.Packet;
4740
import oracle.kubernetes.operator.work.Step;
41+
import oracle.kubernetes.operator.work.VirtualScheduledExecutorService;
4842
import oracle.kubernetes.utils.SystemClock;
4943

5044
/** An abstract base main class for the operator and the webhook. */
@@ -56,10 +50,8 @@ public abstract class BaseMain {
5650
static final String GIT_COMMIT_KEY = "git.commit.id.abbrev";
5751
static final String GIT_BUILD_TIME_KEY = "git.build.time";
5852

59-
static final Container container = new Container();
60-
static final ThreadFactory threadFactory = new WrappedThreadFactory();
61-
static ScheduledExecutorService wrappedExecutorService =
62-
Engine.wrappedExecutorService(container); // non-final to allow change in unit tests
53+
static final ThreadFactory threadFactory = Thread.ofVirtual().factory();
54+
static final ScheduledExecutorService executor = new VirtualScheduledExecutorService();
6355
static final AtomicReference<OffsetDateTime> lastFullRecheck =
6456
new AtomicReference<>(SystemClock.now());
6557
static final Semaphore shutdownSignal = new Semaphore(0);
@@ -78,8 +70,6 @@ public abstract class BaseMain {
7870
PrintStream nullOut = new PrintStream(output);
7971
System.setErr(nullOut);
8072

81-
ClientPool.initialize(threadFactory);
82-
8373
// Simplify debugging the operator by allowing the setting of the operator
8474
// top-level directory using either an env variable or a property. In the normal,
8575
// container-based use case these values won't be set and the operator will with the
@@ -96,7 +86,7 @@ public abstract class BaseMain {
9686
}
9787
probesHome = new File(probesHomeLoc);
9888

99-
TuningParameters.initializeInstance(wrappedExecutorService, new File(deploymentHome, "config"));
89+
TuningParameters.initializeInstance(executor, new File(deploymentHome, "config"));
10090
} catch (IOException e) {
10191
LOGGER.warning(MessageKeys.EXCEPTION, e);
10292
throw new RuntimeException(e);
@@ -165,19 +155,18 @@ void markReadyAndStartLivenessThread() {
165155

166156
logStartingLivenessMessage();
167157
// every five seconds we need to update the last modified time on the liveness file
168-
wrappedExecutorService.scheduleWithFixedDelay(
169-
new DeploymentLiveness(delegate), 5, 5, TimeUnit.SECONDS);
158+
delegate.scheduleWithFixedDelay(new DeploymentLiveness(delegate), 5, 5, TimeUnit.SECONDS);
170159
} catch (IOException io) {
171160
LOGGER.severe(MessageKeys.EXCEPTION, io);
172161
}
173162
}
174163

175-
void startRestServer(Container container)
164+
void startRestServer()
176165
throws UnrecoverableKeyException, CertificateException, IOException, NoSuchAlgorithmException,
177166
KeyStoreException, InvalidKeySpecException, KeyManagementException {
178167
BaseRestServer value = createRestServer();
179168
restServer.set(value);
180-
value.start(container);
169+
value.start();
181170
}
182171

183172
abstract BaseRestServer createRestServer();
@@ -191,18 +180,17 @@ void stopRestServer() {
191180
Optional.ofNullable(restServer.getAndSet(null)).ifPresent(BaseServer::stop);
192181
}
193182

194-
@SuppressWarnings("SameParameterValue")
195-
void startMetricsServer(Container container) throws UnrecoverableKeyException, CertificateException, IOException,
183+
void startMetricsServer() throws UnrecoverableKeyException, CertificateException, IOException,
196184
NoSuchAlgorithmException, KeyStoreException, InvalidKeySpecException, KeyManagementException {
197-
startMetricsServer(container, delegate.getMetricsPort());
185+
startMetricsServer(delegate.getMetricsPort());
198186
}
199187

200188
// for test
201-
void startMetricsServer(Container container, int port) throws UnrecoverableKeyException, CertificateException,
189+
void startMetricsServer(int port) throws UnrecoverableKeyException, CertificateException,
202190
IOException, NoSuchAlgorithmException, KeyStoreException, InvalidKeySpecException, KeyManagementException {
203191
BaseServer value = new MetricsServer(port);
204192
metricsServer.set(value);
205-
value.start(container);
193+
value.start();
206194
}
207195

208196
// for test
@@ -253,7 +241,7 @@ void waitForDeath() {
253241
}
254242

255243
void scheduleCheckForShutdownMarker() {
256-
wrappedExecutorService.scheduleWithFixedDelay(
244+
delegate.scheduleWithFixedDelay(
257245
() -> {
258246
File marker = new File(delegate.getDeploymentHome(), CoreDelegate.SHUTDOWN_MARKER_NAME);
259247
if (isFileExists(marker)) {
@@ -268,25 +256,10 @@ private static boolean isFileExists(File file) {
268256

269257
static Packet createPacketWithLoggingContext(String ns) {
270258
Packet packet = new Packet();
271-
packet.getComponents().put(
272-
LoggingContext.LOGGING_CONTEXT_KEY,
273-
Component.createFor(new LoggingContext().namespace(ns)));
259+
packet.put(LoggingContext.LOGGING_CONTEXT_KEY, new LoggingContext().namespace(ns));
274260
return packet;
275261
}
276262

277-
private static class WrappedThreadFactory implements ThreadFactory {
278-
private final ThreadFactory delegate = Thread.ofVirtual().factory();
279-
280-
@Override
281-
public Thread newThread(@Nonnull Runnable r) {
282-
return delegate.newThread(
283-
() -> {
284-
ContainerResolver.getDefault().enterContainer(container);
285-
r.run();
286-
});
287-
}
288-
}
289-
290263
static class NullCompletionCallback implements CompletionCallback {
291264
private final Runnable completionAction;
292265

@@ -303,11 +276,7 @@ public void onCompletion(Packet packet) {
303276

304277
@Override
305278
public void onThrowable(Packet packet, Throwable throwable) {
306-
if (throwable instanceof UnrecoverableCallException uce) {
307-
uce.log();
308-
} else {
309-
LOGGER.severe(MessageKeys.EXCEPTION, throwable);
310-
}
279+
LOGGER.severe(MessageKeys.EXCEPTION, throwable);
311280
}
312281
}
313282
}

0 commit comments

Comments
 (0)