Skip to content

Commit acb0f38

Browse files
committed
Merge branch 'develop' of https://github.com/oracle/weblogic-kubernetes-operator into exportertest
2 parents 964e2b5 + 7e7715a commit acb0f38

File tree

14 files changed

+266
-50
lines changed

14 files changed

+266
-50
lines changed

docs/domains/Domain.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@
407407
"type": "object",
408408
"properties": {
409409
"overallHealth": {
410-
"description": "Server health of this WebLogic server.",
410+
"description": "Server health of this WebLogic server. If the value is \"Not available\", the operator has failed to read the health. If the value is \"Not available (possibly overloaded)\", the operator has failed to read the health of the server possibly due to the server is in overloaded state",
411411
"type": "string"
412412
},
413413
"activationTime": {

docs/domains/Domain.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ Shutdown describes the configuration for shutting down a server instance.
173173
| Name | Type | Description |
174174
| --- | --- | --- |
175175
| `activationTime` | DateTime | RFC 3339 date and time at which the server started. |
176-
| `overallHealth` | string | Server health of this WebLogic server. |
176+
| `overallHealth` | string | Server health of this WebLogic server. If the value is "Not available", the operator has failed to read the health. If the value is "Not available (possibly overloaded)", the operator has failed to read the health of the server possibly due to the server is in overloaded state |
177177
| `subsystems` | array of [Subsystem Health](#subsystem-health) | Status of unhealthy subsystems, if any. |
178178

179179
### Channel

docs/domains/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1327,7 +1327,7 @@
13271327
"type": "object",
13281328
"properties": {
13291329
"overallHealth": {
1330-
"description": "Server health of this WebLogic server.",
1330+
"description": "Server health of this WebLogic server. If the value is \"Not available\", the operator has failed to read the health. If the value is \"Not available (possibly overloaded)\", the operator has failed to read the health of the server possibly due to the server is in overloaded state",
13311331
"type": "string"
13321332
},
13331333
"activationTime": {

model/src/main/java/oracle/kubernetes/weblogic/domain/model/ServerHealth.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ public class ServerHealth {
2323
@Expose
2424
private DateTime activationTime;
2525

26-
@Description("Server health of this WebLogic server.")
26+
@Description(
27+
"Server health of this WebLogic server. If the value is \"Not available\", the operator has "
28+
+ "failed to read the health. If the value is \"Not available (possibly overloaded)\", the "
29+
+ "operator has failed to read the health of the server possibly due to the server is "
30+
+ "in overloaded state")
2731
@SerializedName("overallHealth")
2832
@Expose
2933
private String overallHealth;

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.concurrent.ConcurrentMap;
2222
import java.util.concurrent.ScheduledFuture;
2323
import java.util.concurrent.TimeUnit;
24+
import java.util.concurrent.atomic.AtomicInteger;
2425
import javax.annotation.Nullable;
2526
import oracle.kubernetes.operator.TuningParameters.MainTuning;
2627
import oracle.kubernetes.operator.calls.CallResponse;
@@ -314,7 +315,9 @@ public void run() {
314315
new CompletionCallback() {
315316
@Override
316317
public void onCompletion(Packet packet) {
317-
if (Boolean.TRUE.equals(packet.get(ProcessingConstants.SERVER_HEALTH_READ))) {
318+
AtomicInteger serverHealthRead =
319+
packet.getValue(ProcessingConstants.REMAINING_SERVERS_HEALTH_TO_READ);
320+
if (serverHealthRead == null || serverHealthRead.get() == 0) {
318321
loggingFilter.setFiltering(false).resetLogHistory();
319322
} else {
320323
loggingFilter.setFiltering(true);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ public interface ProcessingConstants {
3232
public static final String DOMAIN_INTROSPECTOR_LOG_RESULT = "domainIntrospectorLogResult";
3333
public static final String SIT_CONFIG_MAP = "sitConfigMap";
3434

35-
public static final String SERVER_HEALTH_READ = "serverHealthRead";
35+
public static final String REMAINING_SERVERS_HEALTH_TO_READ = "serverHealthRead";
3636
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.concurrent.ConcurrentHashMap;
2222
import java.util.concurrent.ConcurrentMap;
2323
import java.util.concurrent.TimeUnit;
24+
import java.util.concurrent.atomic.AtomicInteger;
2425
import java.util.function.Function;
2526
import java.util.stream.Collectors;
2627
import oracle.kubernetes.operator.helpers.ClientPool;
@@ -68,6 +69,9 @@ public NextAction apply(Packet packet) {
6869
packet.put(SERVER_STATE_MAP, new ConcurrentHashMap<String, String>());
6970
packet.put(SERVER_HEALTH_MAP, new ConcurrentHashMap<String, ServerHealth>());
7071

72+
AtomicInteger remainingServerHealthToRead = new AtomicInteger();
73+
packet.put(ProcessingConstants.REMAINING_SERVERS_HEALTH_TO_READ, remainingServerHealthToRead);
74+
7175
Collection<StepAndPacket> startDetails =
7276
info.getServerPods()
7377
.map(pod -> createStatusReaderStep(packet, pod))
@@ -76,6 +80,7 @@ public NextAction apply(Packet packet) {
7680
if (startDetails.isEmpty()) {
7781
return doNext(packet);
7882
} else {
83+
remainingServerHealthToRead.set(startDetails.size());
7984
return doForkJoin(getNext(), packet, startDetails);
8085
}
8186
}

operator/src/main/java/oracle/kubernetes/operator/http/HttpClient.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ public class HttpClient {
3636
private static final String HTTP_PROTOCOL = "http://";
3737
private static final String HTTPS_PROTOCOL = "https://";
3838

39-
// for debugging
40-
private static final String SERVICE_URL =
41-
System.getProperty("oracle.kubernetes.operator.http.HttpClient.SERVICE_URL");
42-
4339
// Please use one of the factory methods to get an instance of HttpClient.
4440
// Constructor is package access for unit testing
4541
HttpClient(Client httpClient, String encodedCredentials) {

operator/src/main/java/oracle/kubernetes/operator/http/Result.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2018, Oracle Corporation and/or its affiliates. All rights reserved.
1+
// Copyright 2018, 2019 Oracle Corporation and/or its affiliates. All rights reserved.
22
// Licensed under the Universal Permissive License v 1.0 as shown at
33
// http://oss.oracle.com/licenses/upl.
44

@@ -37,6 +37,14 @@ public boolean isSuccessful() {
3737
return successful;
3838
}
3939

40+
/**
41+
* @return true if the HTTP status code from the REST request indicates that the server may be
42+
* overloaded
43+
*/
44+
public boolean isServerOverloaded() {
45+
return status == 500 || status == 503;
46+
}
47+
4048
@Override
4149
public String toString() {
4250
return "Result{"

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

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@
1717
import java.util.Iterator;
1818
import java.util.List;
1919
import java.util.concurrent.ConcurrentMap;
20+
import java.util.concurrent.atomic.AtomicInteger;
2021
import oracle.kubernetes.operator.Pair;
2122
import oracle.kubernetes.operator.ProcessingConstants;
23+
import oracle.kubernetes.operator.WebLogicConstants;
2224
import oracle.kubernetes.operator.helpers.DomainPresenceInfo;
2325
import oracle.kubernetes.operator.http.HttpClient;
26+
import oracle.kubernetes.operator.http.Result;
2427
import oracle.kubernetes.operator.logging.LoggingFacade;
2528
import oracle.kubernetes.operator.logging.LoggingFactory;
2629
import oracle.kubernetes.operator.logging.LoggingFilter;
@@ -43,6 +46,10 @@ public class ReadHealthStep extends Step {
4346

4447
private static final LoggingFacade LOGGER = LoggingFactory.getLogger("Operator", "Operator");
4548

49+
public static final String OVERALL_HEALTH_NOT_AVAILABLE = "Not available";
50+
public static final String OVERALL_HEALTH_FOR_SERVER_OVERLOADED =
51+
OVERALL_HEALTH_NOT_AVAILABLE + " (possibly overloaded)";
52+
4653
private ReadHealthStep(Step next) {
4754
super(next);
4855
}
@@ -139,16 +146,14 @@ public NextAction apply(Packet packet) {
139146
serverConfig.getAdminProtocolChannelName(),
140147
serverConfig.getListenPort());
141148
if (serviceURL != null) {
142-
String jsonResult =
143-
httpClient
144-
.executePostUrlOnServiceClusterIP(
145-
getRetrieveHealthSearchUrl(),
146-
serviceURL,
147-
getRetrieveHealthSearchPayload(),
148-
true)
149-
.getResponse();
149+
Result result =
150+
httpClient.executePostUrlOnServiceClusterIP(
151+
getRetrieveHealthSearchUrl(),
152+
serviceURL,
153+
getRetrieveHealthSearchPayload(),
154+
false);
150155

151-
Pair<String, ServerHealth> pair = parseServerHealthJson(jsonResult);
156+
Pair<String, ServerHealth> pair = createServerHealthFromResult(result);
152157

153158
String state = pair.getLeft();
154159
if (state != null && !state.isEmpty()) {
@@ -162,9 +167,12 @@ public NextAction apply(Packet packet) {
162167
ConcurrentMap<String, ServerHealth> serverHealthMap =
163168
(ConcurrentMap<String, ServerHealth>)
164169
packet.get(ProcessingConstants.SERVER_HEALTH_MAP);
170+
165171
serverHealthMap.put(
166172
(String) packet.get(ProcessingConstants.SERVER_NAME), pair.getRight());
167-
packet.put(ProcessingConstants.SERVER_HEALTH_READ, Boolean.TRUE);
173+
AtomicInteger remainingServersHealthToRead =
174+
packet.getValue(ProcessingConstants.REMAINING_SERVERS_HEALTH_TO_READ);
175+
remainingServersHealthToRead.getAndDecrement();
168176
}
169177
}
170178
return doNext(packet);
@@ -179,6 +187,20 @@ public NextAction apply(Packet packet) {
179187
}
180188
}
181189

190+
private Pair<String, ServerHealth> createServerHealthFromResult(Result restResult)
191+
throws IOException {
192+
if (restResult.isSuccessful()) {
193+
return parseServerHealthJson(restResult.getResponse());
194+
}
195+
return new Pair<>(
196+
WebLogicConstants.UNKNOWN_STATE,
197+
new ServerHealth()
198+
.withOverallHealth(
199+
restResult.isServerOverloaded()
200+
? OVERALL_HEALTH_FOR_SERVER_OVERLOADED
201+
: OVERALL_HEALTH_NOT_AVAILABLE));
202+
}
203+
182204
private Pair<String, ServerHealth> parseServerHealthJson(String jsonResult) throws IOException {
183205
if (jsonResult == null) return null;
184206

0 commit comments

Comments
 (0)