19
19
import java .util .concurrent .atomic .AtomicInteger ;
20
20
import oracle .kubernetes .operator .ProcessingConstants ;
21
21
import oracle .kubernetes .operator .helpers .DomainPresenceInfo ;
22
+ import oracle .kubernetes .operator .http .HTTPException ;
22
23
import oracle .kubernetes .operator .http .HttpClient ;
24
+ import oracle .kubernetes .operator .http .Result ;
23
25
import oracle .kubernetes .operator .logging .LoggingFacade ;
24
26
import oracle .kubernetes .operator .logging .LoggingFactory ;
25
27
import oracle .kubernetes .operator .logging .LoggingFilter ;
@@ -96,6 +98,7 @@ private static String getRetrieveHealthSearchPayload() {
96
98
static final class ReadHealthWithHttpClientStep extends Step {
97
99
private final V1Service service ;
98
100
private final V1Pod pod ;
101
+ static final String OVERALL_HEALTH_FOR_SERVER_ERROR = "Not available" ;
99
102
100
103
ReadHealthWithHttpClientStep (V1Service service , V1Pod pod , Step next ) {
101
104
super (next );
@@ -138,16 +141,14 @@ public NextAction apply(Packet packet) {
138
141
serverConfig .getAdminProtocolChannelName (),
139
142
serverConfig .getListenPort ());
140
143
if (serviceURL != null ) {
141
- String jsonResult =
142
- httpClient
143
- .executePostUrlOnServiceClusterIP (
144
- getRetrieveHealthSearchUrl (),
145
- serviceURL ,
146
- getRetrieveHealthSearchPayload (),
147
- true )
148
- .getResponse ();
144
+ Result result =
145
+ httpClient .executePostUrlOnServiceClusterIP (
146
+ getRetrieveHealthSearchUrl (),
147
+ serviceURL ,
148
+ getRetrieveHealthSearchPayload (),
149
+ false );
149
150
150
- ServerHealth health = parseServerHealthJson ( jsonResult );
151
+ ServerHealth health = createServerHealthFromResult ( result );
151
152
152
153
@ SuppressWarnings ("unchecked" )
153
154
ConcurrentMap <String , ServerHealth > serverHealthMap =
@@ -171,6 +172,17 @@ public NextAction apply(Packet packet) {
171
172
}
172
173
}
173
174
175
+ private ServerHealth createServerHealthFromResult (Result restResult )
176
+ throws IOException , HTTPException {
177
+ if (restResult .isSuccessful ()) {
178
+ return parseServerHealthJson (restResult .getResponse ());
179
+ }
180
+ if (restResult .isServerError ()) {
181
+ return new ServerHealth ().withOverallHealth (OVERALL_HEALTH_FOR_SERVER_ERROR );
182
+ }
183
+ throw new HTTPException (restResult .getStatus ());
184
+ }
185
+
174
186
private ServerHealth parseServerHealthJson (String jsonResult ) throws IOException {
175
187
if (jsonResult == null ) return null ;
176
188
0 commit comments