Skip to content

Commit 02e23eb

Browse files
committed
Preserve server order and squash links
1 parent 650b0af commit 02e23eb

File tree

4 files changed

+26
-37
lines changed

4 files changed

+26
-37
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@ public static void doRollingRestartClusters(String principal, String domainUID,
490490

491491
private static void scheduleDomainStatusUpdating(DomainPresenceInfo info) {
492492
String domainUID = info.getDomain().getSpec().getDomainUID();
493+
493494
AtomicInteger unchangedCount = new AtomicInteger(0);
494495
AtomicReference<ScheduledFuture<?>> statusUpdater = info.getStatusUpdater();
495496
ScheduledFuture<?> existing = statusUpdater.get();

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

Lines changed: 20 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121

2222
import io.kubernetes.client.ApiException;
2323
import io.kubernetes.client.Exec;
24-
import io.kubernetes.client.models.V1ObjectMeta;
2524
import io.kubernetes.client.models.V1Pod;
26-
import oracle.kubernetes.operator.helpers.CallBuilder;
2725
import oracle.kubernetes.operator.helpers.ClientHelper;
2826
import oracle.kubernetes.operator.helpers.ClientHolder;
2927
import oracle.kubernetes.operator.helpers.DomainPresenceInfo;
@@ -35,8 +33,6 @@
3533
import oracle.kubernetes.operator.work.NextAction;
3634
import oracle.kubernetes.operator.work.Packet;
3735
import oracle.kubernetes.operator.work.Step;
38-
import oracle.kubernetes.weblogic.domain.v1.Domain;
39-
import oracle.kubernetes.weblogic.domain.v1.DomainSpec;
4036
import oracle.kubernetes.weblogic.domain.v1.ServerHealth;
4137

4238
/**
@@ -71,27 +67,16 @@ public NextAction apply(Packet packet) {
7167
ConcurrentMap<String, ServerHealth> serverHealthMap = new ConcurrentHashMap<>();
7268
packet.put(ProcessingConstants.SERVER_HEALTH_MAP, serverHealthMap);
7369

74-
Domain domain = info.getDomain();
75-
V1ObjectMeta meta = domain.getMetadata();
76-
DomainSpec spec = domain.getSpec();
77-
78-
String namespace = meta.getNamespace();
79-
String domainUID = spec.getDomainUID();
80-
8170
Collection<StepAndPacket> startDetails = new ArrayList<>();
8271
for (Map.Entry<String, ServerKubernetesObjects> entry : info.getServers().entrySet()) {
8372
String serverName = entry.getKey();
8473
ServerKubernetesObjects sko = entry.getValue();
8574
if (sko != null) {
8675
V1Pod pod = sko.getPod().get();
8776
if (pod != null) {
88-
if (PodWatcher.isReady(pod, true)) {
89-
serverStateMap.put(serverName, "RUNNING");
90-
} else {
91-
Packet p = packet.clone();
92-
startDetails.add(new StepAndPacket(
93-
createServerStatusReaderStep(namespace, domainUID, serverName, timeoutSeconds, null), p));
94-
}
77+
Packet p = packet.clone();
78+
startDetails.add(new StepAndPacket(
79+
createServerStatusReaderStep(pod, serverName, timeoutSeconds, null), p));
9580
}
9681
}
9782
}
@@ -105,38 +90,41 @@ public NextAction apply(Packet packet) {
10590

10691
/**
10792
* Creates asynchronous step to read WebLogic server state from a particular pod
108-
* @param namespace Namespace
109-
* @param domainUID Domain UID
93+
* @param pod The pod
11094
* @param serverName Server name
11195
* @param timeoutSeconds Timeout in seconds
11296
* @param next Next step
11397
* @return Created step
11498
*/
115-
public static Step createServerStatusReaderStep(String namespace, String domainUID,
116-
String serverName, long timeoutSeconds, Step next) {
117-
return new ServerStatusReaderStep(namespace, domainUID, serverName, timeoutSeconds,
99+
public static Step createServerStatusReaderStep(V1Pod pod, String serverName, long timeoutSeconds, Step next) {
100+
return new ServerStatusReaderStep(pod, serverName, timeoutSeconds,
118101
new ServerHealthStep(serverName, timeoutSeconds, next));
119102
}
120103

121104
private static class ServerStatusReaderStep extends Step {
122-
private final String namespace;
123-
private final String domainUID;
105+
private final V1Pod pod;
124106
private final String serverName;
125107
private final long timeoutSeconds;
126108

127-
public ServerStatusReaderStep(String namespace, String domainUID, String serverName,
109+
public ServerStatusReaderStep(V1Pod pod, String serverName,
128110
long timeoutSeconds, Step next) {
129111
super(next);
130-
this.namespace = namespace;
131-
this.domainUID = domainUID;
112+
this.pod = pod;
132113
this.serverName = serverName;
133114
this.timeoutSeconds = timeoutSeconds;
134115
}
135116

136117
@Override
137118
public NextAction apply(Packet packet) {
138-
String podName = CallBuilder.toDNS1123LegalName(domainUID + "-" + serverName);
139-
119+
@SuppressWarnings("unchecked")
120+
ConcurrentMap<String, String> serverStateMap = (ConcurrentMap<String, String>) packet
121+
.get(ProcessingConstants.SERVER_STATE_MAP);
122+
123+
if (PodWatcher.isReady(pod, true)) {
124+
serverStateMap.put(serverName, "RUNNING");
125+
return doNext(packet);
126+
}
127+
140128
// Even though we don't need input data for this call, the API server is
141129
// returning 400 Bad Request any time we set these to false. There is likely some bug in the client
142130
final boolean stdin = true;
@@ -149,7 +137,7 @@ public NextAction apply(Packet packet) {
149137
Process proc = null;
150138
String state = null;
151139
try {
152-
proc = exec.exec(namespace, podName,
140+
proc = exec.exec(pod,
153141
new String[] { "/weblogic-operator/scripts/readState.sh" },
154142
KubernetesConstants.CONTAINER_NAME, stdin, tty);
155143

@@ -168,9 +156,6 @@ public NextAction apply(Packet packet) {
168156
}
169157
}
170158

171-
@SuppressWarnings("unchecked")
172-
ConcurrentMap<String, String> serverStateMap = (ConcurrentMap<String, String>) packet
173-
.get(ProcessingConstants.SERVER_STATE_MAP);
174159
serverStateMap.put(serverName, parseState(state));
175160
fiber.resume(packet);
176161
});
@@ -216,6 +201,7 @@ public NextAction apply(Packet packet) {
216201
ConcurrentMap<String, String> serverStateMap = (ConcurrentMap<String, String>) packet
217202
.get(ProcessingConstants.SERVER_STATE_MAP);
218203
String state = serverStateMap.get(serverName);
204+
219205
if (statesSupportingREST.contains(state)) {
220206
packet.put(ProcessingConstants.SERVER_NAME, serverName);
221207
return doNext(WlsRetriever.readHealthStep(next), packet);

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import java.util.Collection;
1414
import java.util.HashMap;
15+
import java.util.LinkedHashMap;
1516
import java.util.List;
1617
import java.util.Map;
1718

@@ -141,11 +142,11 @@ public static String getRetrieveServersSearchPayload() {
141142
* @return a list containing configuration attributes of each WLS server, each consist of a map of
142143
* (server attribute name, attribute value)
143144
*/
144-
@SuppressWarnings("unchecked")
145+
@SuppressWarnings({ "unchecked", "rawtypes" })
145146
private List<Map<String, Object>> parseJson(String jsonString) {
146147
ObjectMapper mapper = new ObjectMapper();
147148
try {
148-
Map result = mapper.readValue(jsonString, Map.class);
149+
Map result = mapper.readValue(jsonString, LinkedHashMap.class);
149150
Map servers = (Map) result.get("servers");
150151
if (servers != null) {
151152
return (List<Map<String, Object>>) servers.get("items");

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ public NextAction apply(Packet packet) {
210210
String jsonResult = httpClient.executePostUrlOnServiceClusterIP(
211211
getRetrieveHealthSearchUrl(), serviceURL, namespace,
212212
getRetrieveHealthSearchPayload());
213+
213214
ObjectMapper mapper = new ObjectMapper();
214215
JsonNode root = mapper.readTree(jsonResult);
215216

@@ -267,7 +268,7 @@ public static String getRetrieveHealthSearchUrl() {
267268
// overallHealthState, healthState
268269

269270
public static String getRetrieveHealthSearchPayload() {
270-
return "{ fields: [ 'overallHealthState', 'activationTime' ] }";
271+
return "{ fields: [ 'overallHealthState', 'activationTime' ], links: [] }";
271272
}
272273

273274
/**

0 commit comments

Comments
 (0)