21
21
22
22
import io .kubernetes .client .ApiException ;
23
23
import io .kubernetes .client .Exec ;
24
- import io .kubernetes .client .models .V1ObjectMeta ;
25
24
import io .kubernetes .client .models .V1Pod ;
26
- import oracle .kubernetes .operator .helpers .CallBuilder ;
27
25
import oracle .kubernetes .operator .helpers .ClientHelper ;
28
26
import oracle .kubernetes .operator .helpers .ClientHolder ;
29
27
import oracle .kubernetes .operator .helpers .DomainPresenceInfo ;
35
33
import oracle .kubernetes .operator .work .NextAction ;
36
34
import oracle .kubernetes .operator .work .Packet ;
37
35
import oracle .kubernetes .operator .work .Step ;
38
- import oracle .kubernetes .weblogic .domain .v1 .Domain ;
39
- import oracle .kubernetes .weblogic .domain .v1 .DomainSpec ;
40
36
import oracle .kubernetes .weblogic .domain .v1 .ServerHealth ;
41
37
42
38
/**
@@ -71,27 +67,16 @@ public NextAction apply(Packet packet) {
71
67
ConcurrentMap <String , ServerHealth > serverHealthMap = new ConcurrentHashMap <>();
72
68
packet .put (ProcessingConstants .SERVER_HEALTH_MAP , serverHealthMap );
73
69
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
-
81
70
Collection <StepAndPacket > startDetails = new ArrayList <>();
82
71
for (Map .Entry <String , ServerKubernetesObjects > entry : info .getServers ().entrySet ()) {
83
72
String serverName = entry .getKey ();
84
73
ServerKubernetesObjects sko = entry .getValue ();
85
74
if (sko != null ) {
86
75
V1Pod pod = sko .getPod ().get ();
87
76
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 ));
95
80
}
96
81
}
97
82
}
@@ -105,38 +90,41 @@ public NextAction apply(Packet packet) {
105
90
106
91
/**
107
92
* 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
110
94
* @param serverName Server name
111
95
* @param timeoutSeconds Timeout in seconds
112
96
* @param next Next step
113
97
* @return Created step
114
98
*/
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 ,
118
101
new ServerHealthStep (serverName , timeoutSeconds , next ));
119
102
}
120
103
121
104
private static class ServerStatusReaderStep extends Step {
122
- private final String namespace ;
123
- private final String domainUID ;
105
+ private final V1Pod pod ;
124
106
private final String serverName ;
125
107
private final long timeoutSeconds ;
126
108
127
- public ServerStatusReaderStep (String namespace , String domainUID , String serverName ,
109
+ public ServerStatusReaderStep (V1Pod pod , String serverName ,
128
110
long timeoutSeconds , Step next ) {
129
111
super (next );
130
- this .namespace = namespace ;
131
- this .domainUID = domainUID ;
112
+ this .pod = pod ;
132
113
this .serverName = serverName ;
133
114
this .timeoutSeconds = timeoutSeconds ;
134
115
}
135
116
136
117
@ Override
137
118
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
+
140
128
// Even though we don't need input data for this call, the API server is
141
129
// returning 400 Bad Request any time we set these to false. There is likely some bug in the client
142
130
final boolean stdin = true ;
@@ -149,7 +137,7 @@ public NextAction apply(Packet packet) {
149
137
Process proc = null ;
150
138
String state = null ;
151
139
try {
152
- proc = exec .exec (namespace , podName ,
140
+ proc = exec .exec (pod ,
153
141
new String [] { "/weblogic-operator/scripts/readState.sh" },
154
142
KubernetesConstants .CONTAINER_NAME , stdin , tty );
155
143
@@ -168,9 +156,6 @@ public NextAction apply(Packet packet) {
168
156
}
169
157
}
170
158
171
- @ SuppressWarnings ("unchecked" )
172
- ConcurrentMap <String , String > serverStateMap = (ConcurrentMap <String , String >) packet
173
- .get (ProcessingConstants .SERVER_STATE_MAP );
174
159
serverStateMap .put (serverName , parseState (state ));
175
160
fiber .resume (packet );
176
161
});
@@ -216,6 +201,7 @@ public NextAction apply(Packet packet) {
216
201
ConcurrentMap <String , String > serverStateMap = (ConcurrentMap <String , String >) packet
217
202
.get (ProcessingConstants .SERVER_STATE_MAP );
218
203
String state = serverStateMap .get (serverName );
204
+
219
205
if (statesSupportingREST .contains (state )) {
220
206
packet .put (ProcessingConstants .SERVER_NAME , serverName );
221
207
return doNext (WlsRetriever .readHealthStep (next ), packet );
0 commit comments