Skip to content

Commit 9ff5fa0

Browse files
sankarpnrjeberhard
authored andcommitted
retry the api call when there is an ApiException
1 parent cdd5f0b commit 9ff5fa0

File tree

2 files changed

+36
-20
lines changed

2 files changed

+36
-20
lines changed

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItIntrospectVersion.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -390,11 +390,6 @@ void testDomainIntrospectVersionNotRolling() {
390390
//verify admin server accessibility and the health of cluster members
391391
verifyMemberHealth(adminServerPodName, managedServerNames, wlsUserName, wlsPassword);
392392

393-
// verify each managed server can see other member in the cluster
394-
for (String managedServerName : managedServerNames) {
395-
verifyConnectionBetweenClusterMembers(managedServerName, managedServerNames);
396-
}
397-
398393
//update the global replica count since the test changed the replica count of cluster1 to 3
399394
cluster1ReplicaCount = 3;
400395

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)