@@ -583,7 +583,9 @@ public static V1Service getService(
583
583
labelSelector = String .format ("%s in (%s)" , key , value );
584
584
logger .info (labelSelector );
585
585
}
586
- V1ServiceList v1ServiceList
586
+ V1ServiceList v1ServiceList = null ;
587
+ try {
588
+ v1ServiceList
587
589
= coreV1Api .listServiceForAllNamespaces (
588
590
Boolean .FALSE , // allowWatchBookmarks requests watch events with type "BOOKMARK".
589
591
null , // continue to query when there is more results to return.
@@ -596,7 +598,20 @@ public static V1Service getService(
596
598
SEND_INITIAL_EVENTS_UNSET , // Boolean | if to send initial events
597
599
null , // Timeout for the list/watch call.
598
600
Boolean .FALSE // Watch for changes to the described resources.
599
- );
601
+ );
602
+ } catch (ApiException aex ) {
603
+ logger .info ("Failed to check whether service {0} in namespace {1} exists! Caught ApiException!" ,
604
+ serviceName , namespace );
605
+ logger .info ("Printing aex.getCode:" );
606
+ aex .getCode ();
607
+ logger .info ("Printing aex.getResponseBody:" );
608
+ aex .getResponseBody ();
609
+ logger .info ("Printing aex.printStackTrace:" );
610
+ aex .printStackTrace ();
611
+
612
+ return null ;
613
+ }
614
+
600
615
for (V1Service service : v1ServiceList .getItems ()) {
601
616
if (service .getMetadata ().getName ().equals (serviceName .trim ())
602
617
&& service .getMetadata ().getNamespace ().equals (namespace .trim ())) {
@@ -612,6 +627,7 @@ public static V1Service getService(
612
627
return service ;
613
628
}
614
629
}
630
+
615
631
return null ;
616
632
}
617
633
0 commit comments