2121
2222import io .kubernetes .client .ApiException ;
2323import io .kubernetes .client .Exec ;
24- import io .kubernetes .client .models .V1ObjectMeta ;
2524import io .kubernetes .client .models .V1Pod ;
26- import oracle .kubernetes .operator .helpers .CallBuilder ;
2725import oracle .kubernetes .operator .helpers .ClientHelper ;
2826import oracle .kubernetes .operator .helpers .ClientHolder ;
2927import oracle .kubernetes .operator .helpers .DomainPresenceInfo ;
3533import oracle .kubernetes .operator .work .NextAction ;
3634import oracle .kubernetes .operator .work .Packet ;
3735import oracle .kubernetes .operator .work .Step ;
38- import oracle .kubernetes .weblogic .domain .v1 .Domain ;
39- import oracle .kubernetes .weblogic .domain .v1 .DomainSpec ;
4036import 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 );
0 commit comments