Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import io.fabric8.kubernetes.api.model.ConfigMap;
import io.fabric8.kubernetes.api.model.NamespaceBuilder;
import io.fabric8.kubernetes.api.model.Pod;
import io.fabric8.kubernetes.api.model.PodListBuilder;
import io.fabric8.kubernetes.api.model.Secret;
import io.fabric8.kubernetes.api.model.Service;
import io.fabric8.kubernetes.api.model.ServiceAccount;
Expand Down Expand Up @@ -151,10 +152,20 @@ public void deleteAndWait(String namespace, @Nullable Deployment deployment, Ser
@Nullable Ingress ingress) {
try {

long startTime = System.currentTimeMillis();
if (deployment != null) {
client.apps().deployments().inNamespace(namespace).resource(deployment).delete();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this really came out of a different thing I am actively working on: I am trying to refactor integration tests, so that they run faster.

While working on my first PR in this direction, I hit an issue where they are still not as fast as I would like them to be. Debugging, showed that the vast majority of time is eaten by the fact that removing deployment and its pods eats the majority of time. This PR fixes that:

  • first find the pods of a deployment, remove those (with --force)
  • then remove deployment

How much that saves us? In the current tests that I am working on, it shows around 30 seconds saving time for each integration test.

List<Pod> deploymentPods = client.pods()
.inNamespace(namespace)
.withLabels(deployment.getSpec().getSelector().getMatchLabels())
.list()
.getItems();

client.resourceList(new PodListBuilder().withItems(deploymentPods).build()).withGracePeriod(0).delete();
client.apps().deployments().inNamespace(namespace).resource(deployment).withGracePeriod(0).delete();
waitForDeploymentToBeDeleted(namespace, deployment);
}
System.out.println("Ended deployment delete in " + (System.currentTimeMillis() - startTime) + "ms");

client.services().inNamespace(namespace).resource(service).delete();

Expand Down
Loading