Skip to content

Commit e62e133

Browse files
committed
Merge branch 'apiexceptionfix-port-main' into 'main'
porting api getPod exception fix into main See merge request weblogic-cloud/weblogic-kubernetes-operator!4781
2 parents e5f2f26 + 381f442 commit e62e133

File tree

1 file changed

+36
-15
lines changed
  • integration-tests/src/test/java/oracle/weblogic/kubernetes/assertions/impl

1 file changed

+36
-15
lines changed

integration-tests/src/test/java/oracle/weblogic/kubernetes/assertions/impl/Kubernetes.java

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -462,21 +462,42 @@ public static boolean isTraefikPodReady(String namespace) throws ApiException {
462462
* @throws ApiException when there is error in querying the cluster
463463
*/
464464
public static V1Pod getPod(String namespace, String labelSelector, String podName) throws ApiException {
465-
V1PodList v1PodList =
466-
coreV1Api.listNamespacedPod(
467-
namespace, // namespace in which to look for the pods.
468-
Boolean.FALSE.toString(), // // pretty print output.
469-
Boolean.FALSE, // allowWatchBookmarks requests watch events with type "BOOKMARK".
470-
null, // continue to query when there is more results to return.
471-
null, // selector to restrict the list of returned objects by their fields
472-
labelSelector, // selector to restrict the list of returned objects by their labels.
473-
null, // maximum number of responses to return for a list call.
474-
null, // shows changes that occur after that particular version of a resource.
475-
RESOURCE_VERSION_MATCH_UNSET, // String | how to match resource version, leave unset
476-
SEND_INITIAL_EVENTS_UNSET, // Boolean | if to send initial events
477-
null, // Timeout for the list/watch call.
478-
Boolean.FALSE // Watch for changes to the described resources.
479-
);
465+
V1PodList v1PodList = null;
466+
int maxRetries = 3;
467+
int retryCount = 0;
468+
boolean success = false;
469+
while (retryCount < maxRetries && !success) {
470+
try {
471+
v1PodList
472+
= coreV1Api.listNamespacedPod(
473+
namespace, // namespace in which to look for the pods.
474+
Boolean.FALSE.toString(), // // pretty print output.
475+
Boolean.FALSE, // allowWatchBookmarks requests watch events with type "BOOKMARK".
476+
null, // continue to query when there is more results to return.
477+
null, // selector to restrict the list of returned objects by their fields
478+
labelSelector, // selector to restrict the list of returned objects by their labels.
479+
null, // maximum number of responses to return for a list call.
480+
null, // shows changes that occur after that particular version of a resource.
481+
RESOURCE_VERSION_MATCH_UNSET, // String | how to match resource version, leave unset
482+
SEND_INITIAL_EVENTS_UNSET, // Boolean | if to send initial events
483+
null, // Timeout for the list/watch call.
484+
Boolean.FALSE // Watch for changes to the described resources.
485+
);
486+
success = true;
487+
} catch (ApiException ex) {
488+
retryCount++;
489+
if (retryCount >= maxRetries) {
490+
System.out.println("Max retries reached. Giving up.");
491+
throw ex;
492+
} else {
493+
try {
494+
Thread.sleep(1000); // Wait for 1 second
495+
} catch (InterruptedException ie) {
496+
Thread.currentThread().interrupt();
497+
}
498+
}
499+
}
500+
}
480501
for (V1Pod item : v1PodList.getItems()) {
481502
if (item.getMetadata().getName().contains(podName.trim())) {
482503
getLogger().info("Name: {0}, Namespace: {1}, Phase: {2}",

0 commit comments

Comments
 (0)