1919import java .util .concurrent .atomic .AtomicInteger ;
2020import oracle .kubernetes .operator .ProcessingConstants ;
2121import oracle .kubernetes .operator .helpers .DomainPresenceInfo ;
22+ import oracle .kubernetes .operator .http .HTTPException ;
2223import oracle .kubernetes .operator .http .HttpClient ;
24+ import oracle .kubernetes .operator .http .Result ;
2325import oracle .kubernetes .operator .logging .LoggingFacade ;
2426import oracle .kubernetes .operator .logging .LoggingFactory ;
2527import oracle .kubernetes .operator .logging .LoggingFilter ;
@@ -96,6 +98,7 @@ private static String getRetrieveHealthSearchPayload() {
9698 static final class ReadHealthWithHttpClientStep extends Step {
9799 private final V1Service service ;
98100 private final V1Pod pod ;
101+ static final String OVERALL_HEALTH_FOR_SERVER_ERROR = "Not available" ;
99102
100103 ReadHealthWithHttpClientStep (V1Service service , V1Pod pod , Step next ) {
101104 super (next );
@@ -138,16 +141,14 @@ public NextAction apply(Packet packet) {
138141 serverConfig .getAdminProtocolChannelName (),
139142 serverConfig .getListenPort ());
140143 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 );
149150
150- ServerHealth health = parseServerHealthJson ( jsonResult );
151+ ServerHealth health = createServerHealthFromResult ( result );
151152
152153 @ SuppressWarnings ("unchecked" )
153154 ConcurrentMap <String , ServerHealth > serverHealthMap =
@@ -171,6 +172,17 @@ public NextAction apply(Packet packet) {
171172 }
172173 }
173174
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+
174186 private ServerHealth parseServerHealthJson (String jsonResult ) throws IOException {
175187 if (jsonResult == null ) return null ;
176188
0 commit comments