Merge branch '3.1.x' into 3.2.x
This commit is contained in:
@@ -132,7 +132,7 @@ public final class Util {
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteAndWait(String namespace, @Nullable Deployment deployment, Service service) {
|
||||
public void deleteAndWait(String namespace, @Nullable Deployment deployment, @Nullable Service service) {
|
||||
try {
|
||||
|
||||
long startTime = System.currentTimeMillis();
|
||||
@@ -150,7 +150,10 @@ public final class Util {
|
||||
}
|
||||
System.out.println("Ended deployment delete in " + (System.currentTimeMillis() - startTime) + "ms");
|
||||
|
||||
client.services().inNamespace(namespace).resource(service).delete();
|
||||
if (service != null) {
|
||||
client.services().inNamespace(namespace).resource(service).delete();
|
||||
waitForServiceToBeDeleted(namespace, service);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception e) {
|
||||
@@ -363,6 +366,16 @@ public final class Util {
|
||||
});
|
||||
}
|
||||
|
||||
private void waitForServiceToBeDeleted(String namespace, Service service) {
|
||||
|
||||
String serviceName = service.getMetadata().getName();
|
||||
|
||||
await().pollInterval(Duration.ofSeconds(1)).atMost(30, TimeUnit.SECONDS).until(() -> {
|
||||
Service inner = client.services().inNamespace(namespace).withName(serviceName).get();
|
||||
return inner == null;
|
||||
});
|
||||
}
|
||||
|
||||
private void waitForDeployment(String namespace, Deployment deployment) {
|
||||
String deploymentName = deploymentName(deployment);
|
||||
await().pollInterval(Duration.ofSeconds(2))
|
||||
|
||||
@@ -209,9 +209,13 @@ public final class Util {
|
||||
waitForDeploymentToBeDeleted(deploymentName, namespace);
|
||||
waitForDeploymentPodsToBeDeleted(podLabels, namespace);
|
||||
|
||||
service.getMetadata().setNamespace(namespace);
|
||||
coreV1Api.deleteNamespacedService(service.getMetadata().getName(), service.getMetadata().getNamespace(),
|
||||
if (service != null) {
|
||||
service.getMetadata().setNamespace(namespace);
|
||||
coreV1Api.deleteNamespacedService(service.getMetadata().getName(), service.getMetadata().getNamespace(),
|
||||
null, null, null, null, null, null);
|
||||
waitForServiceToBeDeleted(service.getMetadata().getName(), namespace);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
@@ -507,6 +511,21 @@ public final class Util {
|
||||
});
|
||||
}
|
||||
|
||||
private void waitForServiceToBeDeleted(String serviceName, String namespace) {
|
||||
await().timeout(Duration.ofSeconds(180)).until(() -> {
|
||||
try {
|
||||
coreV1Api.readNamespacedService(serviceName, namespace, null);
|
||||
return false;
|
||||
}
|
||||
catch (ApiException e) {
|
||||
if (e.getCode() == HttpURLConnection.HTTP_NOT_FOUND) {
|
||||
return true;
|
||||
}
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void waitForDeploymentPodsToBeDeleted(Map<String, String> labels, String namespace) {
|
||||
await().timeout(Duration.ofSeconds(180)).until(() -> {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user